private void setupAttributes() { Color frameColor = (Color) AttributeFigure.getDefaultAttribute("FrameColor"); Color fillColor = (Color) AttributeFigure.getDefaultAttribute("FillColor"); Color textColor = (Color) AttributeFigure.getDefaultAttribute("TextColor"); Integer arrowMode = (Integer) AttributeFigure.getDefaultAttribute("ArrowMode"); String fontName = (String) AttributeFigure.getDefaultAttribute("FontName"); FigureEnumeration k = view().selectionElements(); while (k.hasMoreElements()) { Figure f = k.nextFigure(); frameColor = (Color) f.getAttribute("FrameColor"); fillColor = (Color) f.getAttribute("FillColor"); textColor = (Color) f.getAttribute("TextColor"); arrowMode = (Integer) f.getAttribute("ArrowMode"); fontName = (String) f.getAttribute("FontName"); } fFrameColor.setSelectedIndex(ColorMap.colorIndex(frameColor)); fFillColor.setSelectedIndex(ColorMap.colorIndex(fillColor)); // fTextColor.select(ColorMap.colorIndex(textColor)); if (arrowMode != null) { fArrowChoice.setSelectedIndex(arrowMode.intValue()); } if (fontName != null) { fFontChoice.setSelectedItem(fontName); } }
private String getURL(Figure figure) { String url = (String) figure.getAttribute("URL"); if (url == null) { url = ""; } return url; }
/** * Moves all the given figures by x and y. Doesn't announce any changes. Subclassers override * basicMoveBy. Clients usually call moveBy. * * @see moveBy */ protected void basicMoveBy(int x, int y) { FigureEnumeration k = figures(); while (k.hasMoreElements()) { Figure fig = k.nextFigure(); Figure obsrvd = (Figure) fig.getAttribute("observed.figure"); if (obsrvd == null || !includes(obsrvd)) { fig.moveBy(x, y); } } }
/** * Hook method which can be overriden by subclasses to provide specialised behaviour in the event * of a popup trigger. */ protected void handlePopupMenu(MouseEvent e, int x, int y) { Figure figure = drawing().findFigure(e.getX(), e.getY()); if (figure != null) { Object attribute = figure.getAttribute(Figure.POPUP_MENU); if (attribute == null) { figure = drawing().findFigureInside(e.getX(), e.getY()); } if (figure != null) { showPopupMenu(figure, e.getX(), e.getY(), e.getComponent()); } } }
/** * This method displays a popup menu, if there is one registered with the Figure (the Figure's * attributes are queried for Figure.POPUP_MENU which is used to indicate an association of a * popup menu with the Figure). * * @param figure Figure for which a popup menu should be displayed * @param x x coordinate where the popup menu should be displayed * @param y y coordinate where the popup menu should be displayed * @param component Component which invoked the popup menu */ protected void showPopupMenu(Figure figure, int x, int y, Component comp) { final Object attribute = figure.getAttribute(Figure.POPUP_MENU); if ((attribute != null) && (attribute instanceof JPopupMenu)) { JPopupMenu popup = (JPopupMenu) attribute; if (popup instanceof PopupMenuFigureSelection) { ((PopupMenuFigureSelection) popup).setSelectedFigure(figure); } // calculate offsets for internal MDI frames Point newLocation = new Point(x, y); adjustOffsets(comp.getParent(), newLocation); popup.setLocation(newLocation); popup.setInvoker(comp); popup.setVisible(true); } }