/** * Connects the figure to the new target. If there is no new target the connection reverts to its * original one. */ public void invokeEnd(int x, int y, int anchorX, int anchorY, DrawingView view) { Connector target = findConnectionTarget(x, y, view.drawing()); if (target == null) { target = fOriginalTarget; } setPoint(x, y); connect(target); getConnection().updateConnection(); Connector oldConnector = ((ChangeConnectionHandle.UndoActivity) getUndoActivity()).getOldConnector(); // there has been no change so there is nothing to undo if ((oldConnector == null) || (target() == null) || (oldConnector.owner() == target().owner())) { setUndoActivity(null); } else { getUndoActivity().setAffectedFigures(new SingleFigureEnumerator(getConnection())); } if (getTargetFigure() != null) { getTargetFigure().connectorVisibility(false); setTargetFigure(null); } }
/** * Performs a layout of the connection. This is called when the connection itself changes. By * default the start and end points of the connection are recalculated. */ public void layoutConnection() { if (startConnector != null) { Point start = startConnector.findStart(this); if (start != null) { startPoint(start.x, start.y); } } if (endConnector != null) { Point end = endConnector.findEnd(this); if (end != null) { endPoint(end.x, end.y); } } clearShapeCache(); }
/** * @see CH.ifa.draw.standard.AbstractConnector#findPoint(CH.ifa.draw.framework.ConnectionFigure) */ public Point findEnd(ConnectionFigure connection) { if (connection instanceof FlowConnection) { // Trying to establish a flow connection; forward to the socket's flow connector return socketConnector.findEnd(connection); } return super.findEnd(connection); }
/** Finds a new target of the connection. */ public void invokeStep(int x, int y, int anchorX, int anchorY, DrawingView view) { Point p = new Point(x, y); Figure f = findConnectableFigure(x, y, view.drawing()); // track the figure containing the mouse if (f != getTargetFigure()) { if (getTargetFigure() != null) { getTargetFigure().connectorVisibility(false); } setTargetFigure(f); if (getTargetFigure() != null) { getTargetFigure().connectorVisibility(true); } } Connector target = findConnectionTarget(p.x, p.y, view.drawing()); if (target != null) { p = Geom.center(target.displayBox()); } setPoint(p.x, p.y); }
/** * Gets the end figure of the connection. * * @return The end figure or null if not connected * @see CH.ifa.draw.framework.ConnectionFigure#endFigure() */ public Figure endFigure() { if (endConnector != null) { return endConnector.owner(); } return null; }
/** * Gets the start figure of the connection. * * @return The start figure or null if not connected * @see CH.ifa.draw.framework.ConnectionFigure#startFigure() */ public Figure startFigure() { if (startConnector != null) { return startConnector.owner(); } return null; }