Search this API

y.layout.router.polyline
Class PathSearchExtension

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

public abstract class PathSearchExtension
extends java.lang.Object

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

An extension 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(PathSearchConfiguration)
  2. initializeEdges(PathSearchContext)
  3. initializeCurrentEdge(PathSearchContext)
  4. initializeCurrentPathRequest(PathSearchContext)
  5. appendStartEntrances(List)
  6. calculateStartEntranceCost(CellEntrance)
  7. calculateCosts(CellEntrance, PartitionCell, OrthogonalInterval, EdgeCellInfo, double)
  8. calculateHeuristicCosts(CellEntrance)
  9. isValidTargetEntrance(CellEntrance)
  10. finalizePath(Path) or cancelCurrentPathRequest(PathSearchContext)
  11. finalizeCurrentEdge(PathSearchContext) or cancelCurrentEdge(PathSearchContext)
  12. finalizeEdges(PathSearchContext)
  13. finalizePathSearchResult(PathSearchResult)
  14. cleanup()

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

Constructor Summary
PathSearchExtension()
          Creates a new instance of PathSearchExtension.
 
Method Summary
protected  void appendStartEntrances(java.util.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)
          Calculates the costs for entering the given PartitionCell via the given enter OrthogonalInterval.
protected  double calculateHeuristicCosts(CellEntrance entrance)
          Calculates the heuristic costs for the given CellEntrance 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)
          Handles the cancellation of the path search for the current edge.
protected  void cancelCurrentPathRequest(PathSearchContext context)
          Handles the cancellation of the path search for the current PathRequest.
protected  void cleanup()
          Cleans up the extension from the path searches with the current configuration and context.
protected  void finalizeCurrentEdge(PathSearchContext context)
          Handles the completion of the path search for the current edge.
protected  void finalizeEdges(PathSearchContext context)
          Handles the completion of all marked edges.
protected  void finalizePath(Path path)
          After finding a valid target entrance and creating a Path, the extension is notified of the found path.
protected  void finalizePathSearchResult(PathSearchResult pathSearchResult)
          Completes the path search result.
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 initializeCurrentPathRequest(PathSearchContext context)
          Initializes this extension with the current PathRequest 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 or not this extension considers the given CellEntrance as a valid target entrance, i.e., the path may end with the given entrance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathSearchExtension

public PathSearchExtension()
Creates a new instance of PathSearchExtension.

Method Detail

getConfiguration

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

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 initializeEdges(PathSearchContext).

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. It may be overridden to initialize this extension with necessary settings like Grouping.

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. This method may be called several times during a path search. Each call will be balanced by calls to finalizeEdges(PathSearchContext) and finalizePathSearchResult(PathSearchResult).

It may be overridden to initialize/reset the settings for the routed edges (e.g. minimum distances).

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

initializeCurrentEdge

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

It may be overridden to initialize/reset the settings for the current edge (e.g. minimum distances).

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

initializeCurrentPathRequest

protected void initializeCurrentPathRequest(PathSearchContext context)
Initializes this extension with the current PathRequest set in the given context.

This method is called for each request of the context's current edge. Each call will be balanced by a call to either finalizePath(Path) or cancelCurrentPathRequest(PathSearchContext).

This method may be overridden to modify settings and data that should be individual for each PathRequest.

Parameters:
context - the context containing the current path request
See Also:
PathSearchContext.getCurrentRequest()

appendStartEntrances

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

This method is called before starting the actual path search to determine possible starting points. The current implementation doesn't add any CellEntrances. It may be overridden to add CellEntrances with specific enter intervals, e.g., to consider PortConstraints.

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 for each start entrance of the current edge.

The current implementation doesn't add any costs for the given CellEntrance. It may be overridden to make start entrances with less specific intervals more expensive. For example, intervals that allow more than just the PortConstraint location to connect to the source node become more expensive.

Parameters:
startEntrance - the start entrance for which the cost is calculated
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)
Calculates the costs for entering the given PartitionCell via the given enter OrthogonalInterval.

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 neighboring cell would be chosen.

The maxAllowedCosts describe the maximum costs that entering the neighboring cell via the given enter interval 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.

This implementation doesn't add any costs. It may be overridden to add costs, e.g., if entering through the given interval would create a bend.

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

calculateHeuristicCosts

protected double calculateHeuristicCosts(CellEntrance entrance)
Calculates the heuristic costs for the given CellEntrance 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 neighboring cell, this method is called for each of the resulting CellEntrances.

This implementation doesn't add any costs. It may be overridden to add some heuristic costs, e.g., if the edge would have to bend to reach the target node from the given CellEntrance.

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 or not this extension considers the given CellEntrance as a valid target entrance, i.e., the path may end with the given entrance.

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

This implementation accepts all CellEntrances as valid targets. It may be overridden to only activate the target if the route fulfills a certain condition.

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

cancelCurrentPathRequest

protected void cancelCurrentPathRequest(PathSearchContext context)
Handles the cancellation of the path search for the current PathRequest.

This callback notifies the extension when the path search for the current request is canceled. In case that not all requests of an edge are successful, then also the path search for that edge will be canceled.

This implementation does nothing. It may be overridden to process or reset PathRequest-specific data like e.g., previously registered listeners.

Parameters:
context - the context containing the request for which the path search has been canceled
See Also:
initializeCurrentPathRequest(PathSearchContext), PathSearchContext.getCurrentRequest()

finalizePath

protected void finalizePath(Path path)
After finding a valid target entrance and creating a Path, the extension is notified of 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.

This implementation does nothing. It may be overridden to collect some information about the given path that may influence the path search of later edges.

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

cancelCurrentEdge

protected void cancelCurrentEdge(PathSearchContext context)
Handles the cancellation of the path search for the current edge.

This callback notifies the extension when the path search for the current edge is canceled. Then, the path search will proceed with altering the penalties of the current edge and reinitializing it again.

This implementation does nothing. It may be overridden to reset some edge specific information, e.g., removing previously added listeners.

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

finalizeCurrentEdge

protected void finalizeCurrentEdge(PathSearchContext context)
Handles the completion of the path search for the current edge.

This callback notifies the extension when enough paths are found for the current edge. After that, the path search either proceeds 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.

This implementation does nothing. It may be overridden to add/reset some edge specific information, e.g., removing previously added listeners or adding new start entrances.

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

finalizeEdges

protected void finalizeEdges(PathSearchContext context)
Handles the completion of all marked edges. 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 for which paths have been found
See Also:
PathSearchContext.getEdges()

finalizePathSearchResult

protected void finalizePathSearchResult(PathSearchResult pathSearchResult)
Completes the path search result.

This callback notifies the extensions of 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 of this result before the path search either initializes the next list of edges to route or ends the path search by calling cleanup(). This implementation does nothing.

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 up the extension from the path searches with the current configuration and context.


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