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 Object
implements Partition, DynamicDecomposition, DynamicDecomposition.Listener

Partitions the bounding box of a graph in rectangles using graph elements as obstacles.

All Obstacles used during the partitioning are created by GraphPartitionExtensions, that have been registered before, in their prepare method which is called during the GraphPartitions initialization.

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

If the ObstaclePartition implements DynamicDecomposition, GraphPartition redispatches 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 instance.
 
Method Summary
 void addDynamicDecompositionListener(DynamicDecomposition.Listener listener)
          Adds the given listener to the Partition.
 void clear()
          Clears the partition data so the GraphPartition can be reused and initialized with a new configuration.
 Obstacle createObstacle(YRectangle bounds, Object data)
          Creates and returns a new Obstacle using the given bounds and data.
 YRectangle getBounds()
          The rectangular area that is partitioned.
 List getCells(Node node)
          Returns a list of all PartitionCells whose bounds intersect or cover the bounds of the given node.
 List getCells(YRectangle rect)
          Returns a list of all PartitionCells that intersect or cover the given rectangle. Note: this call is delegated to Partition.getCells(y.geom.YRectangle).
 List getNeighbors(PartitionCell cell)
          Returns a list of all PartitionCells that are neighbors of the given cell, this means those cells have a common border segment with the given cell.
 List getNodes(PartitionCell cell)
          Returns a list of all Nodes whose bounds intersect or cover the bounds of the given cell.
 Obstacle getObstacle(Object data)
          Returns the obstacle that has earlier been created for the given data object.
 List getObstacles(PartitionCell cell)
          Returns all obstacles covering the given PartitionCell by delegating to the inner partition's ObstaclePartition.getObstacles(PartitionCell) method.
protected  ObstaclePartition getPartition()
          Returns the inner obstacle partition.
 void init(PathSearchConfiguration configuration)
          Initializes the partition with the given graph instance.
 void onCellCreated(PartitionCell createdCell)
          Callback after a new PartitionCell has been created.
 void onCellFinalized(PartitionCell finalizedCell)
          Callback after a PartitionCell has been decided to be final and won't be subdivided further.
 void onCellSubdivided(PartitionCell cell, List subCells)
          Callback after a PartitionCell has been subdivided into several sub cells.
 void removeDynamicDecompositionListener(DynamicDecomposition.Listener listener)
          Removes the given listener from the Partition.
 
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 instance.

Parameters:
partition - The inner obstacle partition used by this graph partition to delegate the partitioning to.
Method Detail

getPartition

protected ObstaclePartition getPartition()
Returns the inner obstacle partition.

Returns:
the inner obstacle partition.

addDynamicDecompositionListener

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

Specified by:
addDynamicDecompositionListener in interface DynamicDecomposition
Parameters:
listener - The listener that shall be notified upon dynamic decomposition events. If it is a GraphPartitionExtension, its preparePartition method is called during initialization.

removeDynamicDecompositionListener

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

Specified by:
removeDynamicDecompositionListener in interface DynamicDecomposition
Parameters:
listener - The listener that shall not be notified anymore upon dynamic decomposition events.

init

public void init(PathSearchConfiguration configuration)
Initializes the partition with the given graph instance.

After clearing any old partitioning information, the GraphPartitionExtension.preparePartition(PathSearchConfiguration, GraphPartition) method of all registered extensions is called. Finally the inner ObstaclePartition is initialized passing all added obstacles as well as the given graph's bounds extended by a small padding.

Parameters:
configuration -

getNeighbors

public List getNeighbors(PartitionCell cell)
Description copied from interface: Partition
Returns a list of all PartitionCells that are neighbors of the given cell, this means those cells have a common border segment with the given cell.

Specified by:
getNeighbors in interface Partition
Parameters:
cell - The cell to get the neighbors for.
Returns:
A list of PartitionCells that are neighbors of the given cell.

getNodes

public 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 to get the nodes for.
Returns:
A list of Nodes that are intersected by the given cell.

getObstacles

public List getObstacles(PartitionCell cell)
Returns all obstacles covering the given PartitionCell by delegating to the inner partition's ObstaclePartition.getObstacles(PartitionCell) method.

Parameters:
cell - The cell to get the obstacles for.
Returns:
A list of Obstacles that cover the given cell.

getCells

public List getCells(Node node)
Returns a list of all PartitionCells whose bounds intersect or cover the bounds of the given node.

Parameters:
node - The node to get the cells for.
Returns:
A list of PartitionCells that are intersected by the given node.

getCells

public List getCells(YRectangle rect)
Returns a list of all PartitionCells that intersect or cover the given rectangle. Note: this call is delegated to Partition.getCells(y.geom.YRectangle).

Specified by:
getCells in interface Partition
Parameters:
rect - The rectangular area to get (partially) covered cells for.
Returns:
A list containing (partially) covered PartitionCells.

getBounds

public YRectangle getBounds()
Description copied from interface: Partition
The rectangular area that is partitioned.

Specified by:
getBounds in interface Partition
Returns:
The bounds of the original rectangular area.

clear

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


onCellSubdivided

public void onCellSubdivided(PartitionCell cell,
                             List subCells)
Callback after a PartitionCell has been subdivided into several sub cells.

This class redispatches this event to all registered DynamicDecomposition.Listeners.

Specified by:
onCellSubdivided in interface DynamicDecomposition.Listener
Parameters:
cell - The cell that has been subdivided.
subCells - The new sub cells of the divided cell.

onCellFinalized

public void onCellFinalized(PartitionCell finalizedCell)
Callback after a PartitionCell has been decided to be final and won't be subdivided further.

This class redispatches this event to all registered DynamicDecomposition.Listeners.

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

onCellCreated

public void onCellCreated(PartitionCell createdCell)
Callback after a new PartitionCell has been created.

This class redispatches this event to all registered DynamicDecomposition.Listeners.

Specified by:
onCellCreated in interface DynamicDecomposition.Listener
Parameters:
createdCell - The newly created cell.

createObstacle

public Obstacle createObstacle(YRectangle bounds,
                               Object data)
Creates and returns a new Obstacle using the given bounds and data. All obstacles created via this method are given to the inner ObstaclePartition upon initialization.

Parameters:
bounds - The bounds of the obstacle.
data - The additional data that shall be associated with the obstacle.
Returns:
A new Obstacle using the given bounds and data.

getObstacle

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

Parameters:
data - The data to get the obstacle for.
Returns:
The obstacle that has been created for the given data object.

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