public static Rectangle rectangleFromOPPNode(OPPNode node) { Rectangle r = new Rectangle(); r.setX(node.getX()); r.setY(node.getY()); r.setWidth(node.getWidth()); r.setHeight(node.getHeight()); return r; }
/** * Detach all links from the node and from the other connecting node, storing the connection * information in local data structures. */ private void detachLinks() { links = new ArrayList<OPPLink>(); linkSources = new HashMap<OPPLink, OPPNode>(); linkTargets = new HashMap<OPPLink, OPPNode>(); links.addAll(node.getIncomingLinks()); links.addAll(node.getOutgoingLinks()); for (OPPLink link : links) { linkSources.put(link, link.getSource()); linkTargets.put(link, link.getTarget()); link.setSource(null); link.setTarget(null); link.setOpd(null); } }
public static int right(OPPNode node) { return node.getX() + node.getWidth(); }
public static int left(OPPNode node) { return node.getX(); }
public static int top(OPPNode node) { return node.getY(); }
public static int bottom(OPPNode node) { return node.getY() + node.getHeight(); }
public static boolean isNodeAboveNode(OPPNode node1, Rectangle node2) { return node1.getY() + node1.getHeight() + 10 < node2.y; }
public static Point getCenter(OPPNode node) { int x = node.getX() + node.getWidth() / 2; int y = node.getY() + node.getHeight() / 2; return new Point(x, y); }
/** * Set the node to delete from the diagram. * * @param node the Node to delete from the diagram. */ public void setNode(final OPPNode node) { this.node = node; this.container = node.getContainer(); }
@Override public void undo() { reattachLinks(); node.setContainer(container); }
@Override public void execute() { detachLinks(); node.setContainer(null); }