Ejemplo n.º 1
0
 public void enterGlyph(Glyph g) {
   g.highlight(true, null);
 }
Ejemplo n.º 2
0
 public void exitGlyph(Glyph g) {
   g.highlight(false, null);
 }
Ejemplo n.º 3
0
  /**
   * 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;
  }