/** @see org.tigris.gef.presentation.Fig#translate(int, int) */ public void translate(int dx, int dy) { super.translate(dx, dy); Editor ce = Globals.curEditor(); Selection sel = ce.getSelectionManager().findSelectionFor(this); if (sel instanceof SelectionClass) { ((SelectionClass) sel).hideButtons(); } }
public void actionPerformed(ActionEvent e) { Editor ce = Globals.curEditor(); Guide guide = ce.getGuide(); if (guide instanceof GuideGrid) { ((GuideGrid) guide).gridSize(guideSize); Configuration.setString(Argo.KEY_SNAP, (String) getValue("ID")); } }
/** * Enabled the remove action if an item is selected in anything other then the activity or state * diagrams. */ private void determineRemoveEnabled() { Editor editor = Globals.curEditor(); Collection figs = editor.getSelectionManager().getFigs(); boolean removeEnabled = !figs.isEmpty(); GraphModel gm = editor.getGraphModel(); if (gm instanceof UMLMutableGraphSupport) { removeEnabled = ((UMLMutableGraphSupport) gm).isRemoveFromDiagramAllowed(figs); } removeFromDiagram.setEnabled(removeEnabled); }
/* * @see org.tigris.gef.graph.GraphFactory#makeNode() */ public Object makeNode() { Object node = null; Editor ce = Globals.curEditor(); GraphModel gm = ce.getGraphModel(); if (gm instanceof CollabDiagramGraphModel) { Object collaboration = ((CollabDiagramGraphModel) gm).getHomeModel(); node = Model.getCollaborationsFactory().buildClassifierRole(collaboration); } else { throw new IllegalStateException("Graphmodel is not a " + "collaboration diagram graph model"); } return node; }
protected void saveGraphics(OutputStream s, Editor ce, Rectangle drawingArea) throws IOException { double scale = ce.getScale(); int x = (int) (drawingArea.x * scale); int y = (int) (drawingArea.y * scale); int h = (int) (drawingArea.height * scale); int w = (int) (drawingArea.width * scale); drawingArea = new Rectangle(x, y, w, h); PostscriptWriter ps = new PostscriptWriter(s, drawingArea); ps.scale(scale, scale); ce.print(ps); ps.dispose(); }
@Override public void actionPerformed(ActionEvent ae) { super.actionPerformed(ae); Editor ce = Globals.curEditor(); GraphModel gm = ce.getGraphModel(); if (!(gm instanceof MutableGraphModel)) { return; } String instructions = Translator.localize("misc.message.click-on-diagram-to-add"); Globals.showStatus(instructions); final ModeAddToDiagram placeMode = new ModeAddToDiagram(objects, instructions); Globals.mode(placeMode, false); }
public void redo() { // TODO: Use per-project undo manager, not global UndoManager.getInstance().addMementoLock(this); for (FigNode figNode : nodesPlaced) { editor.add(figNode); mgm.addNode(figNode.getOwner()); } UndoManager.getInstance().removeMementoLock(this); }
AddToDiagramMemento(final Editor ed, final List<FigNode> nodesPlaced) { this.nodesPlaced = nodesPlaced; this.editor = ed; this.mgm = (MutableGraphModel) editor.getGraphModel(); }
public void mousePressed(MouseEvent me) { super.mousePressed(me); Editor ce = Globals.curEditor(); Selection sel = ce.getSelectionManager().findSelectionFor(this); if (sel instanceof SelectionComponentInstance) ((SelectionComponentInstance) sel).hideButtons(); }
/* * @see org.tigris.gef.base.Selection#dragHandle(int, int, int, int, * org.tigris.gef.presentation.Handle) */ public void dragHandle(int mX, int mY, int anX, int anY, Handle hand) { // Don't allow drag outside of bounds of diagram mX = Math.max(mX, 0); mY = Math.max(mY, 0); if (hand.index < 10) { setPaintButtons(false); super.dragHandle(mX, mY, anX, anY, hand); return; } if (!isDraggableHandle(hand.index)) { return; } int cx = getContent().getX(), cy = getContent().getY(); int cw = getContent().getWidth(), ch = getContent().getHeight(); int bx = mX, by = mY; // Remember what handle was clicked for the case where the drag // is released over empty space button = hand.index; switch (hand.index) { case TOP: by = cy; bx = cx + cw / 2; break; case BOTTOM: by = cy + ch; bx = cx + cw / 2; break; case LEFT: by = cy + ch / 2; bx = cx; break; case RIGHT: by = cy + ch / 2; bx = cx + cw; break; case LOWER_LEFT: by = cy + ch; bx = cx; break; default: LOG.log(Level.WARNING, "invalid handle number"); break; } Object nodeType = getNewNodeType(hand.index); Object edgeType = getNewEdgeType(hand.index); boolean reverse = isReverseEdge(hand.index); if (edgeType != null && nodeType != null) { Editor ce = Globals.curEditor(); ModeCreateEdgeAndNode m = getNewModeCreateEdgeAndNode(ce, edgeType, isEdgePostProcessRequested(), this); m.setup((FigNode) getContent(), getContent().getOwner(), bx, by, reverse); ce.pushMode(m); } }
/** * Compute handle selection, if any, from cursor location. * * @param cursor cursor point represented by a 0-size rectangle * @param h handle in which to return selected Handle information (output parameter). A handle * index of -1 indicates that the cursor is not over any handle. * <p>If GEF had any API documentation you could see the following: * @see org.tigris.gef.base.SelectionResize#hitHandle(java.awt.Rectangle, * org.tigris.gef.presentation.Handle) */ public void hitHandle(Rectangle cursor, Handle h) { super.hitHandle(cursor, h); if (h.index != -1) { // super implementation found a hit return; } if (!isPaintButtons()) { return; } Icon[] icons = getIcons(); if (icons == null) { return; } Editor ce = Globals.curEditor(); SelectionManager sm = ce.getSelectionManager(); if (sm.size() != 1) { return; } ModeManager mm = ce.getModeManager(); if (mm.includes(ModeModify.class) && getPressedButton() == -1) { return; } int cx = getContent().getX(); int cy = getContent().getY(); int cw = getContent().getWidth(); int ch = getContent().getHeight(); /* * Crazy numbering scheme at work here. Here's how the handle numbers * are laid out. Values 0-7 are defined by GEF and go left to * right, top to bottom (ie not clockwise or counterclockwise). * Values 10-14 zigzag North, South, West, East, Southwest. * If you can correctly guess where 15 will go, you should buy * a lottery ticket immediately. * <pre> * 10 * 0-------1-------2 * | | * 12 3 4 13 * | | * 14 5-------6-------7 * 11 * </pre> */ if (icons[0] != null && hitAbove(cx + cw / 2, cy, icons[0].getIconWidth(), icons[0].getIconHeight(), cursor)) { h.index = TOP; } else if (icons[1] != null && hitBelow( cx + cw / 2, cy + ch, icons[1].getIconWidth(), icons[1].getIconHeight(), cursor)) { h.index = BOTTOM; } else if (icons[2] != null && hitLeft(cx, cy + ch / 2, icons[2].getIconWidth(), icons[2].getIconHeight(), cursor)) { h.index = LEFT; } else if (icons[3] != null && hitRight( cx + cw, cy + ch / 2, icons[3].getIconWidth(), icons[3].getIconHeight(), cursor)) { h.index = RIGHT; } else if (icons[4] != null && hitLeft(cx, cy + ch, icons[4].getIconWidth(), icons[4].getIconHeight(), cursor)) { h.index = LOWER_LEFT; } else { h.index = -1; } if (h.index == -1) { h.instructions = getInstructions(15); } else { h.instructions = getInstructions(h.index); } }