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 voidhandleCollision(PointList list, int index) Handles collisions between 2 or more Connections.voidinvalidate(Connection conn) Causes the router to discard any cached information about the given Connection.protected ConnectionRouternext()Returns the next router in the chain.voidremove(Connection conn) Removes the given Connection from this routers list of Connections it is responsible for.voidroute(Connection conn) Routes the given connection.voidsetConstraint(Connection connection, Object constraint) An AutomaticRouter needs no constraints for the connections it routes.protected voidsetEndPoints(Connection conn) Sets the start and end points for the given connection.voidsetNextRouter(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:AbstractRouterReturns the constraint for the given Connection.- Specified by:
getConstraintin interfaceConnectionRouter- Overrides:
getConstraintin 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:AbstractRouterCauses the router to discard any cached information about the given Connection.- Specified by:
invalidatein interfaceConnectionRouter- Overrides:
invalidatein 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:AbstractRouterRemoves the given Connection from this routers list of Connections it is responsible for.- Specified by:
removein interfaceConnectionRouter- Overrides:
removein 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:
setConstraintin interfaceConnectionRouter- Overrides:
setConstraintin 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
-