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`

public abstract class AutomaticRouter extends AbstractRouter
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
Constructor
Description
`AutomaticRouter()`

## Method Summary

Modifier and Type
Method
Description
`Object`
`getConstraint(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`

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

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

## Constructor Details

### AutomaticRouter

public AutomaticRouter()

## Method Details

### getConstraint

public Object getConstraint(Connection connection)
Description copied from class: `AbstractRouter`
Returns the constraint for the given Connection.

Specified by:
  `getConstraint` in interface `ConnectionRouter`
Overrides:
  `getConstraint` in class `AbstractRouter`
Parameters:
  `connection` - The connection
Returns:
  The constraint
See Also:
  - `ConnectionRouter.getConstraint(Connection)`

### handleCollision

protected abstract void handleCollision(PointList list, int index)
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 connection
  `index` - The index of the current connection in the list of colliding connections

### invalidate

public void invalidate(Connection conn)
Description copied from class: `AbstractRouter`
Causes the router to discard any cached information about the given Connection.

Specified by:
  `invalidate` in interface `ConnectionRouter`
Overrides:
  `invalidate` in class `AbstractRouter`
Parameters:
  `conn` - The connection to invalidate
See Also:
  - `ConnectionRouter.invalidate(Connection)`

### next

protected ConnectionRouter next()
Returns the next router in the chain.

Returns:
  The next router
Since:
  2.0

### remove

public void remove(Connection conn)
Description copied from class: `AbstractRouter`
Removes the given Connection from this routers list of Connections it is responsible for.

Specified by:
  `remove` in interface `ConnectionRouter`
Overrides:
  `remove` in class `AbstractRouter`
Parameters:
  `conn` - The connection to remove
See Also:
  - `ConnectionRouter.remove(Connection)`

### route

public void route(Connection conn)
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 calling `handleCollision(PointList, int)`.

Parameters:
  `conn` - The connection to route

### setConstraint

public void setConstraint(Connection connection, Object constraint)
An AutomaticRouter needs no constraints for the connections it routes. This method invalidates the connections and calls `setConstraint(Connection, Object)` on the `next()` router.

Specified by:
  `setConstraint` in interface `ConnectionRouter`
Overrides:
  `setConstraint` in class `AbstractRouter`
Parameters:
  `connection` - The connection
  `constraint` - The constraint
See Also:
  - `ConnectionRouter.setConstraint(Connection, Object)`

### setEndPoints

protected void setEndPoints(Connection conn)
Sets the start and end points for the given connection.

Parameters:
  `conn` - The connection

### setNextRouter

public void setNextRouter(ConnectionRouter router)
Sets the next router.

Parameters:
  `router` - The ConnectionRouter
Since:
  2.0