|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.router.polyline.PathSearchExtension
public abstract class PathSearchExtension
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:
initialize(PathSearchConfiguration)
initializeEdges(PathSearchContext)
initializeCurrentEdge(PathSearchContext)
initializeCurrentPathRequest(PathSearchContext)
appendStartEntrances(List)
calculateStartEntranceCost(CellEntrance)
calculateCosts(CellEntrance, PartitionCell, OrthogonalInterval, EdgeCellInfo, double)
calculateHeuristicCosts(CellEntrance)
isValidTargetEntrance(CellEntrance)
finalizePath(Path)
or cancelCurrentPathRequest(PathSearchContext)
finalizeCurrentEdge(PathSearchContext)
or cancelCurrentEdge(PathSearchContext)
finalizeEdges(PathSearchContext)
finalizePathSearchResult(PathSearchResult)
cleanup()
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 |
---|
public PathSearchExtension()
PathSearchExtension
.
Method Detail |
---|
protected PathSearchConfiguration getConfiguration()
initialize(PathSearchConfiguration)
.
protected PathSearchContext getContext()
initializeEdges(PathSearchContext)
.
protected void initialize(PathSearchConfiguration 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
.
configuration
- the configuration to use for the following path searchesprotected void initializeEdges(PathSearchContext context)
finalizeEdges(PathSearchContext)
and finalizePathSearchResult(PathSearchResult)
.
It may be overridden to initialize/reset the settings for the routed edges (e.g. minimum distances).
context
- the context containing the list of edges for which paths shall be foundPathSearchContext.getEdges()
protected void initializeCurrentEdge(PathSearchContext context)
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).
context
- the context containing the current edgePathSearchContext.getCurrentEdge()
protected void initializeCurrentPathRequest(PathSearchContext context)
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
.
context
- the context containing the current path requestPathSearchContext.getCurrentRequest()
protected void appendStartEntrances(java.util.List allStartEntrances)
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 CellEntrance
s. It may be overridden to add CellEntrance
s with
specific enter intervals, e.g., to consider PortConstraint
s.
allStartEntrances
- a list of all previously generated entrancesprotected double calculateStartEntranceCost(CellEntrance startEntrance)
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.
startEntrance
- the start entrance for which the cost is calculated
protected double calculateCosts(CellEntrance currentEntrance, PartitionCell enteredCell, OrthogonalInterval enterInterval, EdgeCellInfo edgeCellInfo, double maxAllowedCosts)
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.
currentEntrance
- the entrance that was used for entering the current cellenteredCell
- the neighboring cell that shall be enteredenterInterval
- the interval that shall be used for entering the neighboring celledgeCellInfo
- the information about how the current cell would be traversed if the neighboring cell would be
entered by this enter intervalmaxAllowedCosts
- the maximum allowed costs for this enter interval
protected double calculateHeuristicCosts(CellEntrance entrance)
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 CellEntrance
s.
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
.
entrance
- the entrance to calculate the heuristic costs for the rest of the path
protected boolean isValidTargetEntrance(CellEntrance entrance)
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 CellEntrance
s as valid targets. It may be overridden to only activate the
target if the route fulfills a certain condition.
entrance
- the entrance to decide if it is a valid target entrance
true
if the path may end with this entrance, false
otherwiseprotected void cancelCurrentPathRequest(PathSearchContext context)
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.
context
- the context containing the request for which the path search has been canceledinitializeCurrentPathRequest(PathSearchContext)
,
PathSearchContext.getCurrentRequest()
protected void finalizePath(Path path)
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.
path
- the path found for the current edge in the contextPathSearchContext.getCurrentEdge()
protected void cancelCurrentEdge(PathSearchContext context)
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.
context
- the context containing the current edge for which the path search has been canceledinitializeCurrentEdge(y.layout.router.polyline.PathSearchContext)
,
finalizeEdges(PathSearchContext)
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 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.
context
- the context containing the current edge for which the path search has been finishedinitializeCurrentEdge(y.layout.router.polyline.PathSearchContext)
,
finalizeEdges(PathSearchContext)
protected void finalizeEdges(PathSearchContext context)
context
- the context containing the list of edges for which paths have been foundPathSearchContext.getEdges()
protected void finalizePathSearchResult(PathSearchResult pathSearchResult)
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.
pathSearchResult
- the path search result for the edge in the current context's edge listinitializeEdges(y.layout.router.polyline.PathSearchContext)
,
cleanup()
protected void cleanup()
configuration
and context
.
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |