Search this API

y.layout.router.polyline
Class GraphPartition

java.lang.Object
  extended by y.layout.router.polyline.GraphPartition
All Implemented Interfaces:
DynamicDecomposition, DynamicDecomposition.Listener, Partition

public class GraphPartition
extends java.lang.Object
implements Partition, DynamicDecomposition, DynamicDecomposition.Listener

A GraphPartition partitions the bounding box of a graph into rectangles using the graph elements as Obstacles.

All Obstacles used during the partitioning are created by GraphPartitionExtensions. GraphPartitionExtensions have been registered before using method GraphPartitionExtension.preparePartition(PathSearchConfiguration, GraphPartition) which is called during the initialization of a GraphPartition.

The core partitioning is delegated to an ObstaclePartition that is initialized with these Obstacles.

If the ObstaclePartition is of type DynamicDecomposition, GraphPartition re-dispatches the decomposition notifications to its extensions.

See Also:
GraphPartitionExtension
 

Nested Class Summary
 
Nested classes/interfaces inherited from interface y.layout.router.polyline.DynamicDecomposition
DynamicDecomposition.Listener
 
Constructor Summary
GraphPartition(ObstaclePartition partition)
          Creates a new GraphPartition instance using the given delegate inner obstacle partition.
 
Method Summary
 void addDynamicDecompositionListener(DynamicDecomposition.Listener listener)
          Adds the given listener to the GraphPartition.
 void clear()
          Clears the partition data such that the GraphPartition can be reused and initialized with a new configuration.
 Obstacle createObstacle(YRectangle bounds, java.lang.Object data)
          Creates and returns a new Obstacle using the given bounds and data.
 YRectangle getBounds()
          Returns the bounds of the original rectangular area that is being partitioned.
 java.util.List getCells(Node node)
          Returns all PartitionCells that are completely covered by the bounds of the given node.
 java.util.List getCells(YRectangle rect)
          Returns a list of all PartitionCells that intersect or cover the given rectangle by delegating to the corresponding method of the inner partition.
 java.util.List getNeighbors(PartitionCell cell)
          Returns a list of all PartitionCells that are neighbors of the given cell, i.e., those cells that have a common border segment with the given cell.
 java.util.List getNodes(PartitionCell cell)
          Returns a list of all Nodes whose bounds intersect or cover the bounds of the given cell.
 Obstacle getObstacle(java.lang.Object data)
          Returns the Obstacle that has been created earlier for the given data object.
 java.util.List getObstacles(PartitionCell cell)
          Returns all Obstacles covering the given PartitionCell by delegating to the corresponding method of the inner partition.
protected  ObstaclePartition getPartition()
          Returns the delegate inner obstacle partition.
 void init(PathSearchConfiguration configuration)
          Initializes the GraphPartition with the given graph instance based on the given configuration used by path search algorithms.
 void onCellCreated(PartitionCell createdCell)
          Re-dispatches the event of the creation of a new PartitionCell to all registered DynamicDecomposition.Listeners.
 void onCellFinalized(PartitionCell finalizedCell)
          Re-dispatches the event of having completed the process of subdivisions of a given PartitionCell to all registered DynamicDecomposition.Listeners.
 void onCellSubdivided(PartitionCell cell, java.util.List subCells)
          Re-dispatches the event of the subdivision of a given PartitionCell into several sub-cells to all registered DynamicDecomposition.Listeners.
 void onCellUnlocked(PartitionCell unlockedCell)
          Re-dispatches the event of having unlocked a previously finalized PartitionCell to all registered DynamicDecomposition.Listeners.
 void removeDynamicDecompositionListener(DynamicDecomposition.Listener listener)
          Removes the given listener from the GraphPartition.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphPartition

public GraphPartition(ObstaclePartition partition)
Creates a new GraphPartition instance using the given delegate inner obstacle partition.

Parameters:
partition - the delegate inner obstacle partition
Method Detail

getPartition

protected ObstaclePartition getPartition()
Returns the delegate inner obstacle partition.

Returns:
the delegate inner obstacle partition

addDynamicDecompositionListener

public void addDynamicDecompositionListener(DynamicDecomposition.Listener listener)
Adds the given listener to the GraphPartition.

The listener will be notified upon dynamic decomposition events. If it is a GraphPartitionExtension, method GraphPartitionExtension.preparePartition(PathSearchConfiguration, GraphPartition) is called during initialization.

Specified by:
addDynamicDecompositionListener in interface DynamicDecomposition
Parameters:
listener - the listener to be added

removeDynamicDecompositionListener

public void removeDynamicDecompositionListener(DynamicDecomposition.Listener listener)
Removes the given listener from the GraphPartition.

The listener will not be notified of dynamic decomposition events anymore.

Specified by:
removeDynamicDecompositionListener in interface DynamicDecomposition
Parameters:
listener - the listener to be removed

init

public void init(PathSearchConfiguration configuration)
Initializes the GraphPartition with the given graph instance based on the given configuration used by path search algorithms.

Before calling this method, any old partitioning information must be cleared.

This initialization method calls GraphPartitionExtension.preparePartition(PathSearchConfiguration, GraphPartition) of all registered extensions. Then, the inner delegate partition is initialized passing all added obstacles as well as the given graph's bounds extended by a small padding.

In the case where the delegate partition is of type DynamicDecomposition, this GraphPartition will also be added as DynamicDecomposition.Listener to it.

Parameters:
configuration - the configuration used by path search algorithms
See Also:
clear(), GraphPartitionExtension.preparePartition(PathSearchConfiguration, GraphPartition), DynamicDecomposition.addDynamicDecompositionListener(Listener)

getNeighbors

public java.util.List getNeighbors(PartitionCell cell)
Returns a list of all PartitionCells that are neighbors of the given cell, i.e., those cells that have a common border segment with the given cell.

Specified by:
getNeighbors in interface Partition
Parameters:
cell - the cell whose neighbors will be returned
Returns:
a list of PartitionCells that are neighbors of the given cell

getNodes

public java.util.List getNodes(PartitionCell cell)
Returns a list of all Nodes whose bounds intersect or cover the bounds of the given cell.

Parameters:
cell - the cell
Returns:
a list of Nodes that are intersected by the given cell

getObstacles

public java.util.List getObstacles(PartitionCell cell)
Returns all Obstacles covering the given PartitionCell by delegating to the corresponding method of the inner partition.

Parameters:
cell - the cell whose obstacles will be returned
Returns:
a list of Obstacles that cover the given cell
See Also:
ObstaclePartition.getObstacles(PartitionCell)

getCells

public java.util.List getCells(Node node)
Returns all PartitionCells that are completely covered by the bounds of the given node.

Parameters:
node - the node for which the covered cells will be returned
Returns:
an unmodifiable list of PartitionCell instances that are completely covered by the bounds of the given node
Throws:
java.lang.IllegalArgumentException - if the node is unknown

getCells

public java.util.List getCells(YRectangle rect)
Returns a list of all PartitionCells that intersect or cover the given rectangle by delegating to the corresponding method of the inner partition.

Specified by:
getCells in interface Partition
Parameters:
rect - the rectangular area whose (partially) covered cells will be returned
Returns:
a list containing (partially) covered PartitionCells
See Also:
Partition.getCells(YRectangle)

getBounds

public YRectangle getBounds()
Returns the bounds of the original rectangular area that is being partitioned. This method delegates to the corresponding method of the inner partition.

Specified by:
getBounds in interface Partition
Returns:
the bounds of the original rectangular area
See Also:
Partition.getBounds()

clear

public void clear()
Clears the partition data such that the GraphPartition can be reused and initialized with a new configuration.

All GraphPartitionExtensions are cleaned up; partition listeners and obstacles are removed.

See Also:
init(PathSearchConfiguration)

onCellSubdivided

public void onCellSubdivided(PartitionCell cell,
                             java.util.List subCells)
Re-dispatches the event of the subdivision of a given PartitionCell into several sub-cells to all registered DynamicDecomposition.Listeners.

This method is a callback after a PartitionCell has been subdivided into several sub-cells.

Specified by:
onCellSubdivided in interface DynamicDecomposition.Listener
Parameters:
cell - the cell that has been subdivided
subCells - the sub-cells resulting from the subdivision of the given PartitionCell

onCellFinalized

public void onCellFinalized(PartitionCell finalizedCell)
Re-dispatches the event of having completed the process of subdivisions of a given PartitionCell to all registered DynamicDecomposition.Listeners.

This method is a callback after a PartitionCell has been finalized and won't be further subdivided.

Specified by:
onCellFinalized in interface DynamicDecomposition.Listener
Parameters:
finalizedCell - the cell that has been finalized

onCellUnlocked

public void onCellUnlocked(PartitionCell unlockedCell)
Re-dispatches the event of having unlocked a previously finalized PartitionCell to all registered DynamicDecomposition.Listeners.

This method is a callback after a previously finalized PartitionCell has been unlocked again.

Specified by:
onCellUnlocked in interface DynamicDecomposition.Listener
Parameters:
unlockedCell - the cell that has been unlocked

onCellCreated

public void onCellCreated(PartitionCell createdCell)
Re-dispatches the event of the creation of a new PartitionCell to all registered DynamicDecomposition.Listeners.

This method is a callback after a PartitionCell has been created.

Specified by:
onCellCreated in interface DynamicDecomposition.Listener
Parameters:
createdCell - the newly created PartitionCell

createObstacle

public Obstacle createObstacle(YRectangle bounds,
                               java.lang.Object data)
Creates and returns a new Obstacle using the given bounds and data.

All obstacles created via this method are delegated to the inner partition upon initialization.

Parameters:
bounds - the bounds of the obstacle
data - the additional data that should be associated with the obstacle
Returns:
a new Obstacle using the given bounds and data

getObstacle

public Obstacle getObstacle(java.lang.Object data)
Returns the Obstacle that has been created earlier for the given data object.

Parameters:
data - the given data for which the obstacle will be returned
Returns:
the Obstacle that has been created earlier for the given data object

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