Package org.eclipse.gef.fx.nodes
Class AbstractRouter
java.lang.Object
org.eclipse.gef.fx.nodes.AbstractRouter
- All Implemented Interfaces:
IConnectionRouter
- Direct Known Subclasses:
OrthogonalRouter,StraightRouter
Abstract base class for
IConnectionRouters implementing a routing
strategy that can be specialized by subclasses:
- Remove anchors previously inserted by the router.
- Copy connection points before updating the computation parameters.
- Update computation parameters based on the copied connection points (i.e. not influenced by parameter changes).
- Record connection point manipulations using
AbstractRouter.ControlPointManipulator. - Apply all recorded changes to the connection.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classAAbstractRouter.ControlPointManipulatorcan be used to record, perform, and roll back control point changes during routing.protected static classTheAbstractRouter.VolatileStaticAnchoris aStaticAnchorthat may be inserted by anAbstractRouterduringroute(Connection), and, hence, will be removed when routing is performed again. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AbstractRouter.ControlPointManipulatorcreateControlPointManipulator(Connection connection) Returns a newly createdAbstractRouter.ControlPointManipulatorthat can be used to insert control points into the givenConnection.protected IGeometrygetAnchorageGeometry(int index) Retrieves the geometry of the anchorage at the given index within the coordinate system of theConnection, in case the respective anchor is connected.protected abstract PointgetAnchoredReferencePoint(List<Point> points, int index) Returns theDynamicAnchor.AnchoredReferencePointparameter value (within the coordinate system of theConnection) for the anchor specified by the given index.protected ConnectionReturns theConnectionof the lastroute(Connection)call.protected voidinsertRouterAnchors(Connection connection) Inserts router anchors into theConnection.protected voidremoveVolatileAnchors(Connection connection) Removes volatile anchors (i.e.protected Vectorroute(AbstractRouter.ControlPointManipulator cpm, Vector inDirection, Vector outDirection) Inserts router anchors where necessary.voidroute(Connection connection) Adjusts theconnection'sanchors (if necessary) to satisfy certain routing constraints.protected voidupdateComputationParameters(List<Point> points, int index, DynamicAnchor anchor, AnchorKey key) Update's the reference point of the anchor with the given index.protected voidupdateComputationParameters(Connection connection) Updates all computation parameters for the anchors of the givenConnection.booleanwasInserted(IAnchor anchor) Returnstrueif the givenIAnchorwas added by thisIConnectionRouterduringIConnectionRouter.route(Connection).
-
Constructor Details
-
AbstractRouter
public AbstractRouter()
-
-
Method Details
-
createControlPointManipulator
protected AbstractRouter.ControlPointManipulator createControlPointManipulator(Connection connection) Returns a newly createdAbstractRouter.ControlPointManipulatorthat can be used to insert control points into the givenConnection.- Parameters:
connection- TheConnectionfor which to create aAbstractRouter.ControlPointManipulator.- Returns:
- The
AbstractRouter.ControlPointManipulatorfor the givenConnection.
-
getAnchorageGeometry
Retrieves the geometry of the anchorage at the given index within the coordinate system of theConnection, in case the respective anchor is connected.- Parameters:
index- The index of the anchor whose anchorage geometry is to be retrieved.- Returns:
- A geometry resembling the anchorage reference geometry of the
anchor at the given index, or
nullif the anchor is not connected.
-
getAnchoredReferencePoint
Returns theDynamicAnchor.AnchoredReferencePointparameter value (within the coordinate system of theConnection) for the anchor specified by the given index.- Parameters:
points- The list ofPoints from which theConnectionis currently constituted.index- The index of theIAnchorfor which to compute theDynamicAnchor.AnchoredReferencePointparameter value.- Returns:
- The anchored reference
Pointfor the specified anchor.
-
getConnection
Returns theConnectionof the lastroute(Connection)call.- Returns:
- The
Connectionpassed intoroute(Connection).
-
insertRouterAnchors
Inserts router anchors into theConnection.- Parameters:
connection- TheConnection.
-
removeVolatileAnchors
Removes volatile anchors (i.e.inserted by the router).- Parameters:
connection- TheConnectionfrom which to remove volatile anchors.
-
route
Description copied from interface:IConnectionRouterAdjusts theconnection'sanchors (if necessary) to satisfy certain routing constraints. This includes insertion of 'implicit' anchors, as well as updating the positions of existing anchors (which includes manipulating thecomputation parametersofdynamic anchors.- Specified by:
routein interfaceIConnectionRouter- Parameters:
connection- TheConnectionto route.
-
route
protected Vector route(AbstractRouter.ControlPointManipulator cpm, Vector inDirection, Vector outDirection) Inserts router anchors where necessary. Returns theVectorthat points to the next point.- Parameters:
cpm- TheAbstractRouter.ControlPointManipulatorthat can be used to insert points.inDirection- TheVectorfrom the previous point to the current point.outDirection- TheVectorfrom the current point to the next point.- Returns:
- The adjusted
Vectorfrom the current point to the next point.
-
updateComputationParameters
Updates all computation parameters for the anchors of the givenConnection.- Parameters:
connection- TheConnection.
-
updateComputationParameters
protected void updateComputationParameters(List<Point> points, int index, DynamicAnchor anchor, AnchorKey key) Update's the reference point of the anchor with the given index.- Parameters:
points- TheConnection's points (snapshot taken before parameters are updated, i.e. independent from the parameter changes).index- The index of the connection anchor (and anchor key) for which the computation parameters are updated.anchor- TheDynamicAnchorfor which to update the computation parameters.key- TheAnchorKey, corresponding to the index, for which to update the computation parameters.
-
wasInserted
Description copied from interface:IConnectionRouterReturnstrueif the givenIAnchorwas added by thisIConnectionRouterduringIConnectionRouter.route(Connection). Otherwise returnsfalse.- Specified by:
wasInsertedin interfaceIConnectionRouter- Parameters:
anchor- TheIAnchorthat is tested for implicitness.- Returns:
trueif the givenIAnchoris implicit, otherwisefalse.
-