Package org.eclipse.draw2d
Class AutomaticRouter
java.lang.Object
org.eclipse.draw2d.AbstractRouter
org.eclipse.draw2d.AutomaticRouter
- All Implemented Interfaces:
ConnectionRouter
- Direct Known Subclasses:
FanRouter
An abstract router implementation which detects when multiple connections are
overlapping. Two connections overlap if the combination of source and target
anchors are equal. Subclasses must implement
handleCollision(PointList, int)
to determine how to avoid the
overlap.
This router can delegate to another connection router. The wrappered router will route the connections first, after which overlapping will be determined.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.eclipse.draw2d.ConnectionRouter
ConnectionRouter.NullConnectionRouter
-
Field Summary
Fields inherited from interface org.eclipse.draw2d.ConnectionRouter
NULL
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetConstraint
(Connection connection) Returns the constraint for the given Connection.protected abstract void
handleCollision
(PointList list, int index) Handles collisions between 2 or more Connections.void
invalidate
(Connection conn) Causes the router to discard any cached information about the given Connection.protected ConnectionRouter
next()
Returns the next router in the chain.void
remove
(Connection conn) Removes the given Connection from this routers list of Connections it is responsible for.void
route
(Connection conn) Routes the given connection.void
setConstraint
(Connection connection, Object constraint) An AutomaticRouter needs no constraints for the connections it routes.protected void
setEndPoints
(Connection conn) Sets the start and end points for the given connection.void
setNextRouter
(ConnectionRouter router) Sets the next router.Methods inherited from class org.eclipse.draw2d.AbstractRouter
getEndPoint, getStartPoint
-
Constructor Details
-
AutomaticRouter
public AutomaticRouter()
-
-
Method Details
-
getConstraint
Description copied from class:AbstractRouter
Returns the constraint for the given Connection.- Specified by:
getConstraint
in interfaceConnectionRouter
- Overrides:
getConstraint
in classAbstractRouter
- Parameters:
connection
- The connection- Returns:
- The constraint
- See Also:
-
handleCollision
Handles collisions between 2 or more Connections. Collisions are currently defined as 2 connections with no bendpoints and whose start and end points coincide. In other words, the 2 connections are the exact same line.- Parameters:
list
- The PointList of a connection that collides with another connectionindex
- The index of the current connection in the list of colliding connections
-
invalidate
Description copied from class:AbstractRouter
Causes the router to discard any cached information about the given Connection.- Specified by:
invalidate
in interfaceConnectionRouter
- Overrides:
invalidate
in classAbstractRouter
- Parameters:
conn
- The connection to invalidate- See Also:
-
next
Returns the next router in the chain.- Returns:
- The next router
- Since:
- 2.0
-
remove
Description copied from class:AbstractRouter
Removes the given Connection from this routers list of Connections it is responsible for.- Specified by:
remove
in interfaceConnectionRouter
- Overrides:
remove
in classAbstractRouter
- Parameters:
conn
- The connection to remove- See Also:
-
route
Routes the given connection. Calls the 'next' router first (if one exists) and if no bendpoints were added by the next router, collisions are dealt with by callinghandleCollision(PointList, int)
.- Parameters:
conn
- The connection to route
-
setConstraint
An AutomaticRouter needs no constraints for the connections it routes. This method invalidates the connections and callssetConstraint(Connection, Object)
on thenext()
router.- Specified by:
setConstraint
in interfaceConnectionRouter
- Overrides:
setConstraint
in classAbstractRouter
- Parameters:
connection
- The connectionconstraint
- The constraint- See Also:
-
setEndPoints
Sets the start and end points for the given connection.- Parameters:
conn
- The connection
-
setNextRouter
Sets the next router.- Parameters:
router
- The ConnectionRouter- Since:
- 2.0
-