Ejemplo n.º 1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   for (Options option : Options.values())
     if (e.getActionCommand().equals(option.getCaption())) this.option = option;
   for (Tool tool : Tool.values())
     if (e.getActionCommand().equals(tool.name())) {
       try {
         Method m = BusLaneAdderWindow.class.getMethod(tool.function, new Class[] {});
         m.invoke(this, new Object[] {});
       } catch (SecurityException e1) {
         e1.printStackTrace();
       } catch (NoSuchMethodException e1) {
         e1.printStackTrace();
       } catch (IllegalArgumentException e1) {
         e1.printStackTrace();
       } catch (IllegalAccessException e1) {
         e1.printStackTrace();
       } catch (InvocationTargetException e1) {
         e1.printStackTrace();
       }
       setVisible(true);
       repaint();
     }
   if (e.getActionCommand().equals(READY_TO_EXIT)) {
     setVisible(false);
     readyToExit = true;
   }
 }
Ejemplo n.º 2
0
 // Methods
 public BusLaneAdderWindow(
     String title,
     Network network,
     File imageFile,
     double[] upLeft,
     double[] downRight,
     String finalNetworkFile,
     CoordinateTransformation coordinateTransformation)
     throws IOException {
   setTitle(title);
   this.finalNetworkFile = finalNetworkFile;
   this.network = network;
   NetworkTwoNodesPainter networkPainter = new NetworkTwoNodesPainter(network, Color.BLACK);
   setDefaultCloseOperation(EXIT_ON_CLOSE);
   this.setLocation(0, 0);
   this.setLayout(new BorderLayout());
   layersPanels.put(
       PanelIds.ONE,
       new BusLaneAdderPanel(
           this, networkPainter, imageFile, upLeft, downRight, coordinateTransformation));
   this.add(layersPanels.get(PanelIds.ONE), BorderLayout.CENTER);
   option = Options.ZOOM;
   JPanel toolsPanel = new JPanel();
   toolsPanel.setLayout(new GridBagLayout());
   for (Tool tool : Tool.values()) {
     JButton toolButton = new JButton(tool.caption);
     toolButton.setActionCommand(tool.name());
     toolButton.addActionListener(this);
     GridBagConstraints gbc = new GridBagConstraints();
     gbc.gridx = tool.gx;
     gbc.gridy = tool.gy;
     gbc.gridwidth = tool.sx;
     gbc.gridheight = tool.sy;
     toolsPanel.add(toolButton, gbc);
   }
   this.add(toolsPanel, BorderLayout.NORTH);
   JPanel buttonsPanel = new JPanel();
   buttonsPanel.setLayout(new GridLayout(Options.values().length, 1));
   for (Options option : Options.values()) {
     JButton optionButton = new JButton(option.getCaption());
     optionButton.setActionCommand(option.getCaption());
     optionButton.addActionListener(this);
     buttonsPanel.add(optionButton);
   }
   this.add(buttonsPanel, BorderLayout.EAST);
   JPanel infoPanel = new JPanel();
   infoPanel.setLayout(new BorderLayout());
   readyButton = new JButton("Ready to exit");
   readyButton.addActionListener(this);
   readyButton.setActionCommand(READY_TO_EXIT);
   infoPanel.add(readyButton, BorderLayout.WEST);
   JPanel labelsPanel = new JPanel();
   labelsPanel.setLayout(new GridLayout(1, Labels.values().length));
   labelsPanel.setBorder(new TitledBorder("Information"));
   labels = new JTextField[Labels.values().length];
   for (int i = 0; i < Labels.values().length; i++) {
     labels[i] = new JTextField("");
     labels[i].setEditable(false);
     labels[i].setBackground(null);
     labels[i].setBorder(null);
     labelsPanel.add(labels[i]);
   }
   infoPanel.add(labelsPanel, BorderLayout.CENTER);
   JPanel coordsPanel = new JPanel();
   coordsPanel.setLayout(new GridLayout(1, 2));
   coordsPanel.setBorder(new TitledBorder("Coordinates"));
   coordsPanel.add(lblCoords[0]);
   coordsPanel.add(lblCoords[1]);
   infoPanel.add(coordsPanel, BorderLayout.EAST);
   this.add(infoPanel, BorderLayout.SOUTH);
   super.setSize(
       Toolkit.getDefaultToolkit().getScreenSize().width,
       Toolkit.getDefaultToolkit().getScreenSize().height);
 }