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 forIConnectionRouter
s 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 class
AbstractRouter.ControlPointManipulator
AAbstractRouter.ControlPointManipulator
can be used to record, perform, and roll back control point changes during routing.protected static class
AbstractRouter.VolatileStaticAnchor
TheAbstractRouter.VolatileStaticAnchor
is aStaticAnchor
that may be inserted by anAbstractRouter
duringroute(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.ControlPointManipulator
createControlPointManipulator(Connection connection)
Returns a newly createdAbstractRouter.ControlPointManipulator
that can be used to insert control points into the givenConnection
.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.protected abstract Point
getAnchoredReferencePoint(java.util.List<Point> points, int index)
Returns theDynamicAnchor.AnchoredReferencePoint
parameter value (within the coordinate system of theConnection
) for the anchor specified by the given index.protected Connection
getConnection()
Returns theConnection
of the lastroute(Connection)
call.protected void
insertRouterAnchors(Connection connection)
Inserts router anchors into theConnection
.protected void
removeVolatileAnchors(Connection connection)
Removes volatile anchors (i.e.protected Vector
route(AbstractRouter.ControlPointManipulator cpm, Vector inDirection, Vector outDirection)
Inserts router anchors where necessary.void
route(Connection connection)
Adjusts theconnection's
anchors (if necessary) to satisfy certain routing constraints.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.protected void
updateComputationParameters(Connection connection)
Updates all computation parameters for the anchors of the givenConnection
.boolean
wasInserted(IAnchor anchor)
Returnstrue
if the givenIAnchor
was added by thisIConnectionRouter
duringIConnectionRouter.route(Connection)
.
-
-
-
Method Detail
-
createControlPointManipulator
protected AbstractRouter.ControlPointManipulator createControlPointManipulator(Connection connection)
Returns a newly createdAbstractRouter.ControlPointManipulator
that can be used to insert control points into the givenConnection
.- Parameters:
connection
- TheConnection
for which to create aAbstractRouter.ControlPointManipulator
.- Returns:
- The
AbstractRouter.ControlPointManipulator
for 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
null
if the anchor is not connected.
-
getAnchoredReferencePoint
protected abstract Point getAnchoredReferencePoint(java.util.List<Point> points, int index)
Returns theDynamicAnchor.AnchoredReferencePoint
parameter value (within the coordinate system of theConnection
) for the anchor specified by the given index.- Parameters:
points
- The list ofPoint
s from which theConnection
is currently constituted.index
- The index of theIAnchor
for which to compute theDynamicAnchor.AnchoredReferencePoint
parameter value.- Returns:
- The anchored reference
Point
for the specified anchor.
-
getConnection
protected Connection getConnection()
Returns theConnection
of the lastroute(Connection)
call.- Returns:
- The
Connection
passed 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
- TheConnection
from which to remove volatile anchors.
-
route
public void route(Connection connection)
Description copied from interface:IConnectionRouter
Adjusts theconnection's
anchors (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 parameters
ofdynamic anchors
.- Specified by:
route
in interfaceIConnectionRouter
- Parameters:
connection
- TheConnection
to route.
-
route
protected Vector route(AbstractRouter.ControlPointManipulator cpm, Vector inDirection, Vector outDirection)
Inserts router anchors where necessary. Returns theVector
that points to the next point.- Parameters:
cpm
- TheAbstractRouter.ControlPointManipulator
that can be used to insert points.inDirection
- TheVector
from the previous point to the current point.outDirection
- TheVector
from the current point to the next point.- Returns:
- The adjusted
Vector
from 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
- TheDynamicAnchor
for 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:IConnectionRouter
Returnstrue
if the givenIAnchor
was added by thisIConnectionRouter
duringIConnectionRouter.route(Connection)
. Otherwise returnsfalse
.- Specified by:
wasInserted
in interfaceIConnectionRouter
- Parameters:
anchor
- TheIAnchor
that is tested for implicitness.- Returns:
true
if the givenIAnchor
is implicit, otherwisefalse
.
-
-