org.graffiti.plugins.algorithms.reingoldtilford
Class LevellingStrategy

java.lang.Object
  extended by org.graffiti.plugins.algorithms.reingoldtilford.LevellingStrategy
All Implemented Interfaces:
Cloneable

public abstract class LevellingStrategy
extends Object
implements Cloneable

Subclasses of LevellingStrategy define at which y-coordinate each Node is placed. The y-coordinate may be calculated individually for each Node or be restricted to certain values (levels). The level to which each nodes belongs depends on its depth (number of edges of the simple path connecting the node and the root) in the tree.

To provide a new levelling policy, create a class extending LevellingStrategy and add a new member to the LevellingPolicy enumeration.

Subclasses of LevellingStrategy must not directly query the dimensions of the nodes but rather use ReingoldTilfordAlgorithm.getNodeDimension(Node).

Version:
$Revision$ $Date$
Author:
Andreas Gleißner
See Also:
ReingoldTilfordAlgorithm, LevellingPolicy, Orientation

Constructor Summary
LevellingStrategy()
           
 
Method Summary
 void calculateLevels(Node root, ReingoldTilfordAlgorithm algorithm)
          Calculates the levels.
abstract  LevellingStrategy create()
          Creates a new LevellingStrategy.
 ArrayList<Double> getLevels()
          Returns the levels.
 boolean ignoreNodeHeight()
          Returns if the height of each node shall be ignored.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LevellingStrategy

public LevellingStrategy()
Method Detail

calculateLevels

public void calculateLevels(Node root,
                            ReingoldTilfordAlgorithm algorithm)
Calculates the levels. The levels can afterwards be queried by getLevels(). The default implementation of this method calls recursivlyCalculateLevels(Node, int, ReingoldTilfordAlgorithm). To define their specific behaviour, subclasses of LevellingStrategy may either override this method or override notifyNodeHeight(int, double), which is called by recursivlyCalculateLevels(Node, int, ReingoldTilfordAlgorithm) for each node of the tree.

Parameters:
root - the root of the tree.
algorithm - the Reingold-Tilford algorithm.

getLevels

public ArrayList<Double> getLevels()
Returns the levels.

Preconditions:
calculateLevels(Node, ReingoldTilfordAlgorithm) must have been called.

Returns:
the levels or null if calculateLevels(Node, ReingoldTilfordAlgorithm) has not been called yet.

ignoreNodeHeight

public boolean ignoreNodeHeight()
Returns if the height of each node shall be ignored. If ignoreNodeHeight returns true and the space between consecutive levels is not big enough to comprise each node placed at these levels, nodes or edges may intersect. If ignoreNodeHeight returns false, the nodes of the subtrees of oversized nodes are moved to consecutive levels until there are no intersecting nodes and edges. The default implementation always returns false. Subclasses of LevellingStrategy may override this method to define their specific behaviour.

Returns:
false.

create

public abstract LevellingStrategy create()
Creates a new LevellingStrategy. Subclasses of LevellingStrategy must implement this method to create an instance of exactly that sublass.

Returns:
a new LevellingStrategy.


Generated at 2012-05-30 11:01:25 PM CEST