void installPopupMenu(String name, Program pgm) {
   Hashtable h = pgm.getMenus();
   if (h == null) return;
   String[] commands = (String[]) h.get(name);
   if (commands == null) return;
   PopupMenu popup = Menus.getPopupMenu();
   if (popup == null) return;
   popup.removeAll();
   for (int i = 0; i < commands.length; i++) {
     if (commands[i].equals("-")) popup.addSeparator();
     else {
       MenuItem mi = new MenuItem(commands[i]);
       mi.addActionListener(this);
       popup.add(mi);
     }
   }
 }
Exemplo n.º 2
0
 public void actionPerformed(ActionEvent e) {
   String command = e.getActionCommand();
   if (command == null) return;
   if (command.equals(moreLabel)) {
     Point bloc = moreButton.getLocation();
     pm.show(this, bloc.x, bloc.y);
   } else if (command.equals("Convert to RGB")) IJ.doCommand("Stack to RGB");
   else IJ.doCommand(command);
 }
Exemplo n.º 3
0
 protected void handlePopupMenu(MouseEvent e) {
   if (disablePopupMenu) return;
   if (IJ.debugMode) IJ.log("show popup: " + (e.isPopupTrigger() ? "true" : "false"));
   int x = e.getX();
   int y = e.getY();
   Roi roi = imp.getRoi();
   if (roi != null
       && (roi.getType() == Roi.POLYGON
           || roi.getType() == Roi.POLYLINE
           || roi.getType() == Roi.ANGLE)
       && roi.getState() == roi.CONSTRUCTING) {
     roi.handleMouseUp(x, y); // simulate double-click to finalize
     roi.handleMouseUp(x, y); // polygon or polyline selection
     return;
   }
   PopupMenu popup = Menus.getPopupMenu();
   if (popup != null) {
     add(popup);
     if (IJ.isMacOSX()) IJ.wait(10);
     popup.show(this, x, y);
   }
 }
Exemplo n.º 4
0
 void addPopupItem(String s) {
   MenuItem mi = new MenuItem(s);
   mi.addActionListener(this);
   pm.add(mi);
 }