Search this API

y.layout.router.polyline
Class PathSearchExtension

java.lang.Object
  extended by y.layout.router.polyline.PathSearchExtension

public abstract class PathSearchExtension
extends Object

Extensions are added to a PathSearch to influence the search process.

It contains several callback methods that are used by the PathSearch to e.g. calculate the costs for the next possible steps (i.e. entering the next partition cell) and to decide when the target is reached.

The PathSearch uses the callbacks in the following order:

  1. initialize
  2. initializeEdges
  3. initializeCurrentEdge
  4. appendStartEntrances
  5. calculateStartEntranceCost
  6. calculateCosts
  7. calculateHeuristicCosts
  8. isValidTargetEntrance
  9. finalizePath
  10. finalizeCurrentEdge or cancelCurrentEdge
  11. finalizeEdges
  12. finalizePathSearchResult
  13. cleanup

See Also:
PathSearch.addPathSearchExtension(PathSearchExtension), PathSearchContext.getCurrentEdge()

Constructor Summary
PathSearchExtension()
           
 
Method Summary
protected  void appendStartEntrances(List allStartEntrances)
          Appends additional start entrances for the path search of the current edge to the given list of all previously generated entrances.
protected  double calculateCosts(CellEntrance currentEntrance, PartitionCell enteredCell, OrthogonalInterval enterInterval, EdgeCellInfo edgeCellInfo, double maxAllowedCosts)
          Calculate the costs for entering the enteredCell via the enterInterval.
protected  double calculateHeuristicCosts(CellEntrance entrance)
          Calculates the heuristic costs for the given entrance that describe the minimal costs that will arise to finish the path if the given cell entrance is used as next step.
protected  double calculateStartEntranceCost(CellEntrance startEntrance)
          Returns the cost for starting the path in the given entrance.
protected  void cancelCurrentEdge(PathSearchContext context)
          This callback notifies the extension when the path search for the current edge is cancelled.
protected  void cleanup()
          Cleans the extension up from the path searches with the current configuration.
protected  void finalizeCurrentEdge(PathSearchContext context)
          This callback notifies the extension when enough paths are found for the current edge.
protected  void finalizeEdges(PathSearchContext context)
          This callback notifies the extension if enough paths have been found for all edges in the context's edge list.
protected  void finalizePath(Path path)
          After finding a valid target entrance and creating a Path, the extension is notified about the found path.
protected  void finalizePathSearchResult(PathSearchResult pathSearchResult)
          Callback notifying the extension about the paths chosen for the edges in the current context.
protected  PathSearchConfiguration getConfiguration()
          Returns the configuration used for the path search.
protected  PathSearchContext getContext()
          Returns the current context of the path search.
protected  void initialize(PathSearchConfiguration configuration)
          Initializes this extension for path searches using the given configuration.
protected  void initializeCurrentEdge(PathSearchContext context)
          Initializes this extension with the current edge set in the given context.
protected  void initializeEdges(PathSearchContext context)
          Initializes this extension with the context that contains the list of edges for which paths are calculated.
protected  boolean isValidTargetEntrance(CellEntrance entrance)
          Determines whether this extension considers the given entrance a valid target entrance, i.e. the path may end with this entrance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathSearchExtension

public PathSearchExtension()
Method Detail

getConfiguration

protected PathSearchConfiguration getConfiguration()
Returns the configuration used for the path search. This property is initialized in the init method.

Returns:
the configuration used for the path search.

getContext

protected PathSearchContext getContext()
Returns the current context of the path search. This property is initialized in the initEdges method.

Returns:
the current context of the path search.

initialize

protected void initialize(PathSearchConfiguration configuration)
Initializes this extension for path searches using the given configuration.

This method is the first one to be called by the PathSearch.

Parameters:
configuration - The configuration to use for the following path searches.

initializeEdges

protected void initializeEdges(PathSearchContext context)
Initializes this extension with the context that contains the list of edges for which paths are calculated. May be called several times during a path search. Each call will be balanced by calls to finalizeEdges(PathSearchContext) and finalizePathSearchResult(PathSearchResult).

Parameters:
context - The context containing the list of edges, paths shall be found for.
See Also:
PathSearchContext.getEdges()

initializeCurrentEdge

protected void initializeCurrentEdge(PathSearchContext context)
Initializes this extension with the current edge set in the given context. Called for each of the context's egdes. Each call will be balanced by a call to either finalizeCurrentEdge(PathSearchContext) or cancelCurrentEdge(PathSearchContext).

Parameters:
context - The context containing the current edge.
See Also:
PathSearchContext.getCurrentEdge()

appendStartEntrances

protected void appendStartEntrances(List allStartEntrances)
Appends additional start entrances for the path search of the current edge to the given list of all previously generated entrances.

Parameters:
allStartEntrances - a list of all previously generated entrances

calculateStartEntranceCost

protected double calculateStartEntranceCost(CellEntrance startEntrance)
Returns the cost for starting the path in the given entrance. This method is called called for each start entrance of the current edge.

Parameters:
startEntrance - The start entrance to calculate the cost for.
Returns:
The cost for starting the path in the given entrance.

calculateCosts

protected double calculateCosts(CellEntrance currentEntrance,
                                PartitionCell enteredCell,
                                OrthogonalInterval enterInterval,
                                EdgeCellInfo edgeCellInfo,
                                double maxAllowedCosts)
Calculate the costs for entering the enteredCell via the enterInterval.

The given EdgeCellInfo describes how the partition cell, that has been entered by the current entrance, would be traversed if this enter interval to the neighbor cell would be chosen.

The maxAllowedCosts describe the maximum costs the entering of the neighbor cell via this enter intervals may induce. If the maximum cost is exceeded, calculations that may further increase its cost may be skipped because this interval won't be chosen anyway.

Parameters:
currentEntrance - The entrance that was used to enter the current cell.
enteredCell - The neighbor cell that shall be entered.
enterInterval - The interval that shall be used to enter the neighbor cell.
edgeCellInfo - Information about how the current cell would be traversed if the neighbor cell would be entered by this enter interval.
maxAllowedCosts - The maximum allowed costs for this enter intervals.
Returns:
The costs for entering the neighbor cell via the enter interval.

calculateHeuristicCosts

protected double calculateHeuristicCosts(CellEntrance entrance)
Calculates the heuristic costs for the given entrance that describe the minimal costs that will arise to finish the path if the given cell entrance is used as next step.

After evaluating the costs for each enter interval to a neighbor cell, this method is called for each of the resulting CellEntrances.

Parameters:
entrance - The entrance to calculate the heuristic costs for the rest of the path.
Returns:
The minimal costs that will arise to finish the path if the given cell entrance is used as next step.

isValidTargetEntrance

protected boolean isValidTargetEntrance(CellEntrance entrance)
Determines whether this extension considers the given entrance a valid target entrance, i.e. the path may end with this entrance.

Each time a CellEntrance is chosen as next step, all registered extension are asked if this entrance is a valid target entrance. Only if none of the extensions returns false, a Path is created.

Parameters:
entrance - The entrance to decide if it is a valid target entrance.
Returns:
true, if the path may end with this entrance; false otherwise.

finalizePath

protected void finalizePath(Path path)
After finding a valid target entrance and creating a Path, the extension is notified about the found path.

If the path search is configured to calculate several possible paths for an edge, the path search proceeds with choosing another unhandled CellEntrance.

Parameters:
path - The path found for the current edge in the context.
See Also:
PathSearchContext.getCurrentEdge()

cancelCurrentEdge

protected void cancelCurrentEdge(PathSearchContext context)
This callback notifies the extension when the path search for the current edge is cancelled.

After that, the path search will proceed with altering the penalties of the current edge and reinitializing it again.

Parameters:
context - The context containing the current edge the path search has been finished for.
See Also:
initializeCurrentEdge(y.layout.router.polyline.PathSearchContext), finalizeEdges(PathSearchContext)

finalizeCurrentEdge

protected void finalizeCurrentEdge(PathSearchContext context)
This callback notifies the extension when enough paths are found for the current edge.

After that, the path search either proceed with initializing the next current edge in the context's edge list or calls finalizeEdges(PathSearchContext) if all edges in this list have been handled.

Parameters:
context - The context containing the current edge the path search has been finished for.
See Also:
initializeCurrentEdge(y.layout.router.polyline.PathSearchContext), finalizeEdges(PathSearchContext)

finalizeEdges

protected void finalizeEdges(PathSearchContext context)
This callback notifies the extension if enough paths have been found for all edges in the context's edge list.

Parameters:
context - The context containing the list of edges, paths have been found for.
See Also:
PathSearchContext.getEdges()

finalizePathSearchResult

protected void finalizePathSearchResult(PathSearchResult pathSearchResult)
Callback notifying the extension about the paths chosen for the edges in the current context.

After calling finalizeEdges, the PathSearch decides, which of the found paths to use for each edge and adds them to the PathSearchResult.

With this callback the registered extensions are notified about this result before the path search either initializes the next list of edges to route or ends the path search by calling cleanup().

Parameters:
pathSearchResult - The path search result for the edge in the current context's edge list.
See Also:
initializeEdges(y.layout.router.polyline.PathSearchContext), cleanup()

cleanup

protected void cleanup()
Cleans the extension up from the path searches with the current configuration.


© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.