org.graffiti.plugins.algorithms.reingoldtilford
Class Tree

java.lang.Object
  extended by org.graffiti.plugins.algorithms.reingoldtilford.Tree

public class Tree
extends Object

Represents a tree layout of a subtree.

ReingoldTilfordAlgorithm constructs a tree layout for the complete tree by passing the root Node to the constructor Tree(Node, Edge, Tree, int, ReingoldTilfordAlgorithm, TreeVisitor)

The constructor Tree(Tree) is used by Tree internally to create a mirrored version of an existing Tree.

Some fields of Tree are illustrated in the following figure:

Version:
$Revision$ $Date$
Author:
Andreas Gleißner

Method Summary
 void draw(ReingoldTilfordAlgorithm algorithm, double xOrigin, double yOrigin)
           
 Tree find(TreeVisitor<Boolean> visitor)
           
 int getChildIndex()
          Returns the position of this Tree in the LinkedList children of the parent of this tree layout.
 LinkedList<Tree> getChildren()
          Returns the children of this node.
 Edge getEdge()
          Returns the edge that connects node with its parent.
 Tree getFlipped()
          Returns the flipped counterpart of this tree.
 double getHeight()
          Returns the height of this tree layout.
 double getLeft()
          Returns the x-coordinate of this tree layout relative to parent.
 org.graffiti.plugins.algorithms.reingoldtilford.BasicContourNodeList getLeftContour()
          Returns the left contour.
 Node getNode()
          Returns the node that is the root of the tree this layout represents.
 double getNodeHeight()
          Returns the height of node.
 double getNodeLeft()
          Returns the x-coordinate of node within the coordinate system of this tree layout.
 double getNodeWidth()
          Returns the width of node.
 Tree getParent()
          Returns the parent of this tree layout.
 org.graffiti.plugins.algorithms.reingoldtilford.BasicContourNodeList getRightContour()
          Returns the right contour.
 double getVerticalNodeDistance()
           
 double getWidth()
          Returns the width of this tree layout.
 boolean hasRoundShape()
           
 boolean isRoot()
          Returns if node is the root.
 boolean isShallow()
           
 void setLeftContour(org.graffiti.plugins.algorithms.reingoldtilford.BasicContourNodeList leftContour)
          Sets the left contour.
 void setRightContour(org.graffiti.plugins.algorithms.reingoldtilford.BasicContourNodeList rightContour)
          Sets the right contour.
 void updateChildIndices()
          Sets the childIndex field of each child according to its position in the LinkedList children.
 void writeToDebugImage(org.graffiti.plugins.tools.debug.DebugImage image, double xOrigin, double yOrigin, boolean showContour, ReingoldTilfordAlgorithm algorithm)
           
 void writeToDebugSession(org.graffiti.plugins.tools.debug.DebugSession session, ReingoldTilfordAlgorithm algorithm)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isRoot

public boolean isRoot()
Returns if node is the root.

Returns:
true if node is the root.

getChildren

public LinkedList<Tree> getChildren()
Returns the children of this node. The only allowed modifications to the returned ArrayList are flipping and reordering its elements. Then updateChildIndices() must be called.

Returns:
the children of this node.

getNode

public Node getNode()
Returns the node that is the root of the tree this layout represents.

Returns:
the node that is the root of the tree this layout represents.
See Also:
node

getEdge

public Edge getEdge()
Returns the edge that connects node with its parent.

Returns:
the edge that connects node with its parent.

updateChildIndices

public void updateChildIndices()
Sets the childIndex field of each child according to its position in the LinkedList children.

See Also:
setChildIndex(int)

getChildIndex

public int getChildIndex()
Returns the position of this Tree in the LinkedList children of the parent of this tree layout.

Returns:
position of this in the LinkedList or -1 if the index has not been set yet.
See Also:
childIndex, setChildIndex(int)

getParent

public Tree getParent()
Returns the parent of this tree layout.

Returns:
the parent of this tree layout or null if node is the root.
See Also:
parent

getLeftContour

public org.graffiti.plugins.algorithms.reingoldtilford.BasicContourNodeList getLeftContour()
Returns the left contour. Must only be called by methods implementing EdgeLayoutStrategy.calculateContours(Tree, ReingoldTilfordAlgorithm) .

Returns:
the left contour.
See Also:
leftContour, setLeftContour(BasicContourNodeList)

getRightContour

public org.graffiti.plugins.algorithms.reingoldtilford.BasicContourNodeList getRightContour()
Returns the right contour. Must only be called by methods implementing EdgeLayoutStrategy.calculateContours(Tree, ReingoldTilfordAlgorithm) .

Returns:
the right contour.
See Also:
rightContour, setRightContour(BasicContourNodeList)

setLeftContour

public void setLeftContour(org.graffiti.plugins.algorithms.reingoldtilford.BasicContourNodeList leftContour)
Sets the left contour. Must only be called by methods implementing EdgeLayoutStrategy.calculateContours(Tree, ReingoldTilfordAlgorithm) .

Parameters:
leftContour - the new left contour.
See Also:
leftContour, getLeftContour()

setRightContour

public void setRightContour(org.graffiti.plugins.algorithms.reingoldtilford.BasicContourNodeList rightContour)
Sets the right contour. Must only be called by methods implementing EdgeLayoutStrategy.calculateContours(Tree, ReingoldTilfordAlgorithm) .

Parameters:
rightContour - the new right contour.
See Also:
rightContour, getRightContour()

getNodeWidth

public double getNodeWidth()
Returns the width of node.

Returns:
the width of node.
See Also:
nodeWidth

getNodeHeight

public double getNodeHeight()
Returns the height of node.

Returns:
the height of node.

getNodeLeft

public double getNodeLeft()
Returns the x-coordinate of node within the coordinate system of this tree layout.

Returns:
the x-coordinate of node within the coordinate system of this tree layout.

getLeft

public double getLeft()
Returns the x-coordinate of this tree layout relative to parent.

Returns:
x-coordinate of this tree layout relative to parent.
See Also:
left, setLeft(double)

getWidth

public double getWidth()
Returns the width of this tree layout.

Returns:
the width of this tree layout.
See Also:
width, setWidth(double)

getHeight

public double getHeight()
Returns the height of this tree layout.

Returns:
the heught of this tree layout.
See Also:
height, setHeight(double)

draw

public void draw(ReingoldTilfordAlgorithm algorithm,
                 double xOrigin,
                 double yOrigin)

hasRoundShape

public boolean hasRoundShape()

isShallow

public boolean isShallow()
Returns:
true if all children are leaves or there are no children;
false otherwise.

getFlipped

public Tree getFlipped()
Returns the flipped counterpart of this tree.

Returns:
the flipped counterpart of this tree.
Throws:
LockedTreeException - if tree is locked.
See Also:
isLocked()

getVerticalNodeDistance

public double getVerticalNodeDistance()

find

public Tree find(TreeVisitor<Boolean> visitor)

writeToDebugSession

public void writeToDebugSession(org.graffiti.plugins.tools.debug.DebugSession session,
                                ReingoldTilfordAlgorithm algorithm)

writeToDebugImage

public void writeToDebugImage(org.graffiti.plugins.tools.debug.DebugImage image,
                              double xOrigin,
                              double yOrigin,
                              boolean showContour,
                              ReingoldTilfordAlgorithm algorithm)


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