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
public abstract class AbstractRouter extends java.lang.Object implements IConnectionRouter
Abstract base class forIConnectionRouters 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 Classes Modifier and Type Class Description protected static classAbstractRouter.ControlPointManipulatorAAbstractRouter.ControlPointManipulatorcan be used to record, perform, and roll back control point changes during routing.protected static classAbstractRouter.VolatileStaticAnchorTheAbstractRouter.VolatileStaticAnchoris aStaticAnchorthat may be inserted by anAbstractRouterduringroute(Connection), and, hence, will be removed when routing is performed again.
-
Constructor Summary
Constructors Constructor Description AbstractRouter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected 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(java.util.List<Point> points, int index)Returns theDynamicAnchor.AnchoredReferencePointparameter value (within the coordinate system of theConnection) for the anchor specified by the given index.protected ConnectiongetConnection()Returns 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(java.util.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).
-
-
-
Method Detail
-
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
protected IGeometry getAnchorageGeometry(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.- 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
protected abstract Point getAnchoredReferencePoint(java.util.List<Point> points, int index)
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
protected Connection getConnection()
Returns theConnectionof the lastroute(Connection)call.- Returns:
- The
Connectionpassed intoroute(Connection).
-
insertRouterAnchors
protected void insertRouterAnchors(Connection connection)
Inserts router anchors into theConnection.- Parameters:
connection- TheConnection.
-
removeVolatileAnchors
protected void removeVolatileAnchors(Connection connection)
Removes volatile anchors (i.e.inserted by the router).- Parameters:
connection- TheConnectionfrom which to remove volatile anchors.
-
route
public void route(Connection connection)
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
protected void updateComputationParameters(Connection connection)
Updates all computation parameters for the anchors of the givenConnection.- Parameters:
connection- TheConnection.
-
updateComputationParameters
protected void updateComputationParameters(java.util.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
public boolean wasInserted(IAnchor anchor)
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.
-
-