Пример #1
0
  public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
    boolean none = true;
    robotMap.clear();
    for (RemoteRobot robot : net.getRobots()) {
      none = false;
      JMenuItem b = new JMenuItem(robot.name());
      robotMap.put(b, robot);
      b.addActionListener(this);
      robotMenu.add(b);
    }

    if (none) robotMenu.add("None available");
  }
Пример #2
0
  public void actionPerformed(ActionEvent e) {

    if (e.getSource() instanceof JButton) {
      JButton b = (JButton) e.getSource();
      if (b == robotButton) {
        // show popup menu for selecting robots
        robotMenu.show(b, b.getWidth(), 0);
      } else {
        if (!typeMap.containsKey(b))
          // error?
          return;
        // retrieve the type of data selected
        retrieveType(typeMap.get(b));
      }
    } else if (e.getSource() instanceof JMenuItem) {
      JMenuItem m = (JMenuItem) e.getSource();
      if (!robotMap.containsKey(m))
        // error?
        return;
      // select the given robot for future data retrievals
      selectedRobot = robotMap.get(m);
      robotButton.setText(selectedRobot.name());
      robotMenu.setVisible(false);
    }
  }
Пример #3
0
  public void retrieveType(DataType t) {
    if (selectedRobot == null) return;

    TOOLImage i;
    switch (t) {
      case IMAGE:
        TOOL.CONSOLE.message("Requesting a raw image");
        i = selectedRobot.retrieveImage();
        if (i != null) imagePanel.updateImage(i);
        break;
      case THRESH:
        TOOL.CONSOLE.message("Requesting a thresholded image");
        i = selectedRobot.retrieveThresh();
        if (i != null) imagePanel.updateImage(i);
        break;
    }
  }