Package org.eclipse.draw2d.graph
Class ShortestPathRouter
java.lang.Object
org.eclipse.draw2d.graph.ShortestPathRouter
Bends a collection of 
Paths around rectangular obstacles. This
 class maintains a list of paths and obstacles. Updates can be made to the
 paths and/or obstacles, and then an incremental solve can be invoked.
 The algorithm will attempt to find the shortest non-intersecting path between each path's start and end points. Once all paths have been found, they will be offset based on how many paths bend around the same corner of each obstacle.
The worst-case performance of this algorithm is p * s * n^2, where p is the number of paths, n is the number of obstacles, and s is the average number of segments in each path's final solution.
This class is not intended to be subclassed.
- Since:
- 3.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanaddObstacle(Rectangle rect) Adds an obstacle with the given bounds to the obstacles.voidAdds a path to the routing.intReturns the spacing maintained between paths.booleanremoveObstacle(Rectangle rect) Removes the obstacle with the rectangle's bounds from the routing.booleanremovePath(Path path) Removes the given path from the routing.voidsetSpacing(int spacing) Sets the default spacing between paths.solve()Updates the points in the paths in order to represent the current solution with the given paths and obstacles.booleanupdateObstacle(Rectangle oldBounds, Rectangle newBounds) Updates the position of an existing obstacle.
- 
Constructor Details- 
ShortestPathRouterpublic ShortestPathRouter()Creates a new shortest path routing.
 
- 
- 
Method Details- 
addObstacleAdds an obstacle with the given bounds to the obstacles.- Parameters:
- rect- the bounds of this obstacle
- Returns:
- trueif the added obstacle has dirtied one or more paths
 
- 
addPathAdds a path to the routing.- Parameters:
- path- the path to add.
 
- 
getSpacingpublic int getSpacing()Returns the spacing maintained between paths.- Returns:
- the default path spacing
- Since:
- 3.2
- See Also:
 
- 
removeObstacleRemoves the obstacle with the rectangle's bounds from the routing.- Parameters:
- rect- the bounds of the obstacle to remove
- Returns:
- trueif the removal has dirtied one or more paths
 
- 
removePathRemoves the given path from the routing.- Parameters:
- path- the path to remove.
- Returns:
- trueif the removal may have affected one of the remaining paths
 
- 
setSpacingpublic void setSpacing(int spacing) Sets the default spacing between paths. The spacing is the minimum distance that path should be offset from other paths or obstacles. The default value is 4. When this value can not be satisfied, paths will be squeezed together uniformly.- Parameters:
- spacing- the path spacing
- Since:
- 3.2
 
- 
solveUpdates the points in the paths in order to represent the current solution with the given paths and obstacles.- Returns:
- returns the list of paths which were updated.
 
- 
updateObstacleUpdates the position of an existing obstacle.- Parameters:
- oldBounds- the old bounds(used to find the obstacle)
- newBounds- the new bounds
- Returns:
- trueif the change the current results to become stale
 
 
-