コード例 #1
0
ファイル: StationModelCanvas.java プロジェクト: ethanrd/IDV
  /**
   * initialize the symbols menu
   *
   * @param m menu
   */
  public void initSymbolsMenu(JMenu m) {
    m.removeAll();
    for (int i = 0; i < glyphs.size(); i++) {
      final MetSymbol metSymbol = (MetSymbol) glyphs.get(i);
      JMenuItem mi = GuiUtils.makeMenuItem(metSymbol.getLabel(), this, "showProperties", metSymbol);
      mi.addMouseListener(
          new MouseAdapter() {
            public void mousePressed(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }

            public void mouseReleased(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }

            public void mouseEntered(MouseEvent e) {
              highlightedMetSymbol = metSymbol;
              StationModelCanvas.this.repaint();
            }

            public void mouseExited(MouseEvent e) {
              highlightedMetSymbol = null;
              StationModelCanvas.this.repaint();
            }
          });
      m.add(mi);
    }
  }
コード例 #2
0
ファイル: StationModelCanvas.java プロジェクト: ethanrd/IDV
 /**
  * Make the edit menu
  *
  * @param editMenu edit menu
  * @return edit menu
  */
 public JMenu makeEditMenu(JMenu editMenu) {
   editMenu.add(GuiUtils.makeDynamicMenu("Symbols", this, "initSymbolsMenu"));
   editMenu.add(
       GuiUtils.makeMenuItem("Set properties on selected", this, "setPropertiesOnSelected"));
   editMenu.addSeparator();
   return super.makeEditMenu(editMenu);
 }
コード例 #3
0
ファイル: StationModelCanvas.java プロジェクト: ethanrd/IDV
  /**
   * _more_
   *
   * @param symbols _more_
   * @param listener _more_
   * @param smm _more_
   * @return _more_
   */
  public static List makeStationModelMenuItems(
      List symbols, final ObjectListener listener, StationModelManager smm) {
    List items = new ArrayList();
    List subMenus = new ArrayList();
    Hashtable categories = new Hashtable();
    for (int i = 0; i < symbols.size(); i++) {
      StationModel sm = (StationModel) symbols.get(i);
      boolean isUsers = smm.isUsers(sm);
      String name = sm.getName();
      if (name.equals("")) continue;
      List toks = StringUtil.split(name, ">", true, true);
      if (toks.size() > 0) {
        name = (String) toks.get(toks.size() - 1);
      }
      JMenuItem item = new JMenuItem(GuiUtils.getLocalName(name, isUsers));
      item.addActionListener(
          new ObjectListener(sm) {
            public void actionPerformed(ActionEvent ae) {
              listener.setObject(this.theObject);
              listener.actionPerformed(ae);
            }
          });

      toks.remove(toks.size() - 1);
      if (toks.size() == 0) {
        items.add(item);
        continue;
      }
      JMenu categoryMenu = null;
      String catSoFar = "";
      String menuCategory = "";
      for (int catIdx = 0; catIdx < toks.size(); catIdx++) {
        String subCat = (String) toks.get(catIdx);
        catSoFar = catSoFar + "/" + subCat;
        JMenu m = (JMenu) categories.get(catSoFar);
        if (m == null) {
          m = new JMenu(subCat);
          menuCategory = catSoFar;
          categories.put(catSoFar, m);
          if (categoryMenu != null) {
            categoryMenu.add(m, 0);
          } else {
            subMenus.add(m);
          }
        }
        categoryMenu = m;
      }
      if (categoryMenu == null) {
        categoryMenu = new JMenu("");
        categories.put(toks.toString(), categoryMenu);
        subMenus.add(categoryMenu);
        menuCategory = toks.toString();
      }
      categoryMenu.add(item);
    }
    items.addAll(subMenus);
    return items;
  }
コード例 #4
0
ファイル: StationModelCanvas.java プロジェクト: ethanrd/IDV
  /**
   * Make the view menu
   *
   * @param viewMenu view menu
   * @return The view menu
   */
  public JMenu makeViewMenu(JMenu viewMenu) {
    showAlignmentPointsMI = new JCheckBoxMenuItem("Show Alignment Points", true);
    viewMenu.add(showAlignmentPointsMI);
    showAlignmentPointsMI.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            repaint();
          }
        });

    viewMenu.addSeparator();
    super.makeViewMenu(viewMenu);
    viewMenu.addSeparator();
    viewMenu.add(makeMenuItem("Black background", CMD_BLACKBG));
    viewMenu.add(makeMenuItem("White background", CMD_WHITEBG));
    return viewMenu;
  }
コード例 #5
0
ファイル: StationModelCanvas.java プロジェクト: ethanrd/IDV
  /**
   * Add the menus into the menu bar
   *
   * @param menuBar The menu bar
   */
  public void initMenuBar(JMenuBar menuBar) {
    stationModelMenu = new JMenu("Layout Models");
    stationModelMenu.addMenuListener(
        new MenuListener() {
          public void menuCanceled(MenuEvent e) {}

          public void menuDeselected(MenuEvent e) {}

          public void menuSelected(MenuEvent e) {
            makeStationModelMenu();
          }
        });

    fileMenu = new JMenu("File");
    fileMenu.addMenuListener(
        new MenuListener() {
          public void menuCanceled(MenuEvent e) {}

          public void menuDeselected(MenuEvent e) {}

          public void menuSelected(MenuEvent e) {
            makeFileMenu();
          }
        });

    menuBar.add(fileMenu);
    super.initMenuBar(menuBar);

    menuBar.add(stationModelMenu);

    JMenu helpMenu = new JMenu("Help");
    JMenuItem helpMenuItem = new JMenuItem("Layout Models");
    helpMenu.add(helpMenuItem);
    helpMenuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            showHelp();
          }
        });

    menuBar.add(helpMenu);
  }
コード例 #6
0
ファイル: StationModelCanvas.java プロジェクト: ethanrd/IDV
 /** Make the view menu */
 private void makeStationModelMenu() {
   stationModelMenu.removeAll();
   List symbols = smm.getResources();
   List items = new ArrayList();
   ObjectListener listener =
       new ObjectListener(null) {
         public void actionPerformed(ActionEvent ae) {
           if (!okToChange()) {
             return;
           }
           setStationModel((StationModel) theObject, true);
         }
       };
   GuiUtils.makeMenu(stationModelMenu, makeStationModelMenuItems(symbols, listener, smm));
 }
コード例 #7
0
ファイル: StationModelCanvas.java プロジェクト: ethanrd/IDV
  /**
   * Make menu items for the given glyph
   *
   * @param metSymbol The glyph
   * @param l List ot put items in
   * @param forPopup Is this for a popup menu
   * @return The list
   */
  protected List doMakeMetSymbolMenu(final MetSymbol metSymbol, List l, boolean forPopup) {
    if (l == null) {
      l = new ArrayList();
    }
    JMenuItem mi;
    if (!forPopup) {
      l = super.doMakeMenuItems(metSymbol, l);
    }

    l.add(mi = new JMenuItem(metSymbol.getActive() ? "Hide" : "Show"));
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            metSymbol.setActive(!metSymbol.getActive());
          }
        });

    if (metSymbol.doAlignmentMenu()) {
      JMenu rectPtMenu =
          new JMenu("Alignment Point (" + Glyph.getRectPointName(metSymbol.getRectPoint()) + ")");
      l.add(rectPtMenu);
      for (int i = 0; i < Glyph.RECTPOINTNAMES.length; i++) {
        rectPtMenu.add(mi = new JMenuItem(Glyph.RECTPOINTNAMES[i]));
        mi.addActionListener(
            new ObjectListener(Glyph.RECTPOINTS[i]) {
              public void actionPerformed(ActionEvent ae) {
                metSymbol.setRectPoint(theObject.toString());
                setHaveChanged(true);
                repaint();
              }
            });
      }
    }

    JMenu alignMenu = new JMenu("Center");
    l.add(alignMenu);

    alignMenu.add(mi = new JMenuItem("Center"));
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Rectangle b = metSymbol.getBounds();
            Point2D rp = Glyph.getPointOnRect(metSymbol.getRectPoint(), b);
            metSymbol.moveBy((int) -(rp.getX()), (int) -(rp.getY()));
            repaint();
            setHaveChanged(true);
          }
        });

    alignMenu.add(mi = new JMenuItem("Center Vertically"));
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Rectangle b = metSymbol.getBounds();
            Point2D rp = Glyph.getPointOnRect(metSymbol.getRectPoint(), b);
            metSymbol.moveBy(0, (int) -(rp.getY()));
            repaint();
            setHaveChanged(true);
          }
        });
    alignMenu.add(mi = new JMenuItem("Center Horizontally"));
    mi.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            Rectangle b = metSymbol.getBounds();
            Point2D rp = Glyph.getPointOnRect(metSymbol.getRectPoint(), b);
            metSymbol.moveBy((int) -(rp.getX()), 0);
            repaint();
            setHaveChanged(true);
          }
        });

    if (forPopup) {
      l.add(GuiUtils.MENU_SEPARATOR);
      l.add(mi = new JMenuItem("Properties..."));
      mi.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
              showProperties(metSymbol);
            }
          });
    }

    return l;
  }
コード例 #8
0
ファイル: StationModelCanvas.java プロジェクト: ethanrd/IDV
 /** Make the file menu */
 private void makeFileMenu() {
   fileMenu.removeAll();
   fileMenu.add(makeMenuItem("New", 'n', GuiUtils.CMD_NEW));
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Save", 's', GuiUtils.CMD_SAVE));
   fileMenu.add(makeMenuItem("Save As...", GuiUtils.CMD_SAVEAS));
   fileMenu.add(makeMenuItem("Rename...", GuiUtils.CMD_RENAME));
   fileMenu.addSeparator();
   JMenuItem removeMenuItem = makeMenuItem("Remove", GuiUtils.CMD_REMOVE);
   removeMenuItem.setEnabled(smm.isUsers(stationModel));
   fileMenu.add(removeMenuItem);
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Import...", GuiUtils.CMD_IMPORT));
   fileMenu.add(makeMenuItem("Export...", GuiUtils.CMD_EXPORT));
   fileMenu.addSeparator();
   fileMenu.add(makeMenuItem("Close", GuiUtils.CMD_CLOSE));
 }