Eclipse Draw2d
3.1

org.eclipse.draw2d.graph
Class ShortestPathRouter

java.lang.Object
  extended byorg.eclipse.draw2d.graph.ShortestPathRouter

public class ShortestPathRouter
extends Object

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 Summary
ShortestPathRouter()
          Creates a new shortest path routing.
 
Method Summary
 boolean addObstacle(Rectangle rect)
          Adds an obstacle with the given bounds to the obstacles.
 void addPath(Path path)
          Adds a path to the routing.
 boolean removeObstacle(Rectangle rect)
          Removes the obstacle with the rectangle's bounds from the routing.
 boolean removePath(Path path)
          Removes the given path from the routing.
 List solve()
          Updates the points in the paths in order to represent the current solution with the given paths and obstacles.
 boolean updateObstacle(Rectangle oldBounds, Rectangle newBounds)
          Updates the position of an existing obstacle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShortestPathRouter

public ShortestPathRouter()
Creates a new shortest path routing.

Method Detail

addObstacle

public boolean addObstacle(Rectangle rect)
Adds an obstacle with the given bounds to the obstacles.

Parameters:
rect - the bounds of this obstacle
Returns:
true if the added obstacle has dirtied one or more paths

addPath

public void addPath(Path path)
Adds a path to the routing.

Parameters:
path - the path to add.

removeObstacle

public boolean removeObstacle(Rectangle rect)
Removes the obstacle with the rectangle's bounds from the routing.

Parameters:
rect - the bounds of the obstacle to remove
Returns:
true if the removal has dirtied one or more paths

removePath

public boolean removePath(Path path)
Removes the given path from the routing.

Parameters:
path - the path to remove.
Returns:
true if the removal may have affected one of the remaining paths

solve

public List solve()
Updates 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.

updateObstacle

public boolean updateObstacle(Rectangle oldBounds,
                              Rectangle newBounds)
Updates the position of an existing obstacle.

Parameters:
oldBounds - the old bounds(used to find the obstacle)
newBounds - the new bounds
Returns:
true if the change the current results to become stale

Eclipse Draw2d
3.1

Copyright (c) IBM Corp. and others 2000, 2005. All Rights Reserved.