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 Object implements IConnectionRouter
Abstract base class for `IConnectionRouter`s implementing a routing strategy that can be specialized by subclasses:

1. Remove anchors previously inserted by the router.
2. Copy connection points before updating the computation parameters.
3. Update computation parameters based on the copied connection points (i.e. not influenced by parameter changes).
4. Record connection point manipulations using `AbstractRouter.ControlPointManipulator`.
5. Apply all recorded changes to the connection.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected static class`
`AbstractRouter.ControlPointManipulator`
A `AbstractRouter.ControlPointManipulator` can be used to record, perform, and roll back control point changes during routing.
`protected static class`
`AbstractRouter.VolatileStaticAnchor`
The `AbstractRouter.VolatileStaticAnchor` is a `StaticAnchor` that may be inserted by an `AbstractRouter` during `route(Connection)`, and, hence, will be removed when routing is performed again.

## Constructor Summary

Constructors
Constructor
Description
`AbstractRouter()`

## Method Summary

Modifier and Type
Method
Description
`protected AbstractRouter.ControlPointManipulator`
`createControlPointManipulator(Connection connection)`
Returns a newly created `AbstractRouter.ControlPointManipulator` that can be used to insert control points into the given `Connection`.
`protected IGeometry`
`getAnchorageGeometry(int index)`
Retrieves the geometry of the anchorage at the given index within the coordinate system of the `Connection`, in case the respective anchor is connected.
`protected abstract Point`
`getAnchoredReferencePoint(List<Point> points, int index)`
Returns the `DynamicAnchor.AnchoredReferencePoint` parameter value (within the coordinate system of the `Connection`) for the anchor specified by the given index.
`protected Connection`
`getConnection()`
Returns the `Connection` of the last `route(Connection)` call.
`protected void`
`insertRouterAnchors(Connection connection)`
Inserts router anchors into the `Connection`.
`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 the `connection's` anchors (if necessary) to satisfy certain routing constraints.
`protected void`
`updateComputationParameters(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 given `Connection`.
`boolean`
`wasInserted(IAnchor anchor)`
Returns `true` if the given `IAnchor` was added by this `IConnectionRouter` during `IConnectionRouter.route(Connection)`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### AbstractRouter

public AbstractRouter()

## Method Details

### createControlPointManipulator

protected AbstractRouter.ControlPointManipulator createControlPointManipulator(Connection connection)
Returns a newly created `AbstractRouter.ControlPointManipulator` that can be used to insert control points into the given `Connection`.

Parameters:
  `connection` - The `Connection` for which to create a `AbstractRouter.ControlPointManipulator`.
Returns:
  The `AbstractRouter.ControlPointManipulator` for the given `Connection`.

### getAnchorageGeometry

protected IGeometry getAnchorageGeometry(int index)
Retrieves the geometry of the anchorage at the given index within the coordinate system of the `Connection`, 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(List<Point> points, int index)
Returns the `DynamicAnchor.AnchoredReferencePoint` parameter value (within the coordinate system of the `Connection`) for the anchor specified by the given index.

Parameters:
  `points` - The list of `Point`s from which the `Connection` is currently constituted.
  `index` - The index of the `IAnchor` for which to compute the `DynamicAnchor.AnchoredReferencePoint` parameter value.
Returns:
  The anchored reference `Point` for the specified anchor.

### getConnection

protected Connection getConnection()
Returns the `Connection` of the last `route(Connection)` call.

Returns:
  The `Connection` passed into `route(Connection)`.

### insertRouterAnchors

protected void insertRouterAnchors(Connection connection)
Inserts router anchors into the `Connection`.

Parameters:
  `connection` - The `Connection`.

### removeVolatileAnchors

protected void removeVolatileAnchors(Connection connection)
Removes volatile anchors (i.e. `inserted by the router`).

Parameters:
  `connection` - The `Connection` from which to remove volatile anchors.

### route

public void route(Connection connection)
Description copied from interface: `IConnectionRouter`
Adjusts the `connection'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 the `computation parameters` of `dynamic anchors`.

Specified by:
  `route` in interface `IConnectionRouter`
Parameters:
  `connection` - The `Connection` to route.

### route

protected Vector route(AbstractRouter.ControlPointManipulator cpm, Vector inDirection, Vector outDirection)
Inserts router anchors where necessary. Returns the `Vector` that points to the next point.

Parameters:
  `cpm` - The `AbstractRouter.ControlPointManipulator` that can be used to insert points.
  `inDirection` - The `Vector` from the previous point to the current point.
  `outDirection` - The `Vector` 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 given `Connection`.

Parameters:
  `connection` - The `Connection`.

### 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` - The `Connection`'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` - The `DynamicAnchor` for which to update the computation parameters.
  `key` - The `AnchorKey`, corresponding to the index, for which to update the computation parameters.

### wasInserted

public boolean wasInserted(IAnchor anchor)
Description copied from interface: `IConnectionRouter`
Returns `true` if the given `IAnchor` was added by this `IConnectionRouter` during `IConnectionRouter.route(Connection)`. Otherwise returns `false`.

Specified by:
  `wasInserted` in interface `IConnectionRouter`
Parameters:
  `anchor` - The `IAnchor` that is tested for implicitness.
Returns:
  `true` if the given `IAnchor` is implicit, otherwise `false`.