org.graffiti.plugins.algorithms.reingoldtilford
Class TreeCombinationList

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

public class TreeCombinationList
extends Object

TreeCombinationList is used to compose a Tree layout from the layouts of its children. Trees are inserted at arbitrary positions in the list.

TreeCombinationList consists a 'left' TreeCombinationStack growing to the right and a 'right' TreeCombinationStack growing to the left. Inserting a Tree layout into this TreeCombinationList is implemented by pushing it to the left stack. Moving the pointer that denotes the position where new layouts shall be inserted into this list is implemented by popping the Tree from one stack and pushing it onto the other stack. apply(Tree) is realized by shifting all trees to the left stack and calling TreeCombinationStack.apply(Tree) on the left stack.

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

Constructor Summary
TreeCombinationList(LinkedList<Tree> trees, ReingoldTilfordAlgorithm algorithm)
          Creates a new TreeCombinationList and inserts all tree layouts of trees into it.
TreeCombinationList(ReingoldTilfordAlgorithm algorithm)
          Creates a new TreeCombinationList.
 
Method Summary
 void apply(Tree parent)
          Applies the combined tree layout composed by this TreeCombinationList to the tree layout of parent.
 double bubbleDown(double currentWidth, boolean mayFlip)
           
 double bubbleUp(double currentWidth, boolean mayFlip)
           
 void decPointer()
          Moves the insertion pointer one position to the left.
 int getPointer()
          Returns the current pointer position.
 int getSize()
          Returns the size of the list.
 void incPointer()
          Moves the insertion pointer one position to the right.
 void insert(Tree tree)
          Inserts tree at the current pointer position.
 void movePointer(int index)
          Moves the insertion pointer to the passed position.
 double testInsertion(Tree tree)
          Returns the width of the combined tree layout if tree was added to this list.
 double testWidth()
          Returns the width of the combined tree layout.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeCombinationList

public TreeCombinationList(ReingoldTilfordAlgorithm algorithm)
Creates a new TreeCombinationList.

Parameters:
algorithm - the Reingold-Tilford algorithm.

TreeCombinationList

public TreeCombinationList(LinkedList<Tree> trees,
                           ReingoldTilfordAlgorithm algorithm)
Creates a new TreeCombinationList and inserts all tree layouts of trees into it.

Parameters:
trees - the tree layouts to be inserted into the new list.
algorithm - the Reingold-Tilford algorithm.
Method Detail

insert

public void insert(Tree tree)
Inserts tree at the current pointer position. The pointer can be moved by incPointer(), decPointer() or movePointer(int).

Parameters:
tree - the tree to be inserted.
Throws:
LockedTreeException - if tree is locked.
See Also:
Tree.isLocked()

incPointer

public void incPointer()
Moves the insertion pointer one position to the right. It is realized by popping a tree layout from the right stack and pushing it onto the left stack.

Throws:
IndexOutOfBoundsException - if the pointer is moved out to invalid positions (beneath the end of the list).

decPointer

public void decPointer()
Moves the insertion pointer one position to the left. It is realized by popping a tree layout from the left stack and pushing it onto the right stack.

Throws:
IndexOutOfBoundsException - if the pointer is moved out to invalid positions (below the start of the list).

movePointer

public void movePointer(int index)
Moves the insertion pointer to the passed position. It is realized by calling incPointer() or decPointer() repeatedly until the desired position is reached.

Parameters:
index - the position the insertion pointer is moved to.

getPointer

public int getPointer()
Returns the current pointer position.

Returns:
the current pointer position.

getSize

public int getSize()
Returns the size of the list.

Returns:
the size of the list.

testInsertion

public double testInsertion(Tree tree)
Returns the width of the combined tree layout if tree was added to this list.

Parameters:
tree - the tree layout whose insertion is to be tested.
Returns:
the width of the combined tree layout if tree was added to this list.
Throws:
LockedTreeException - if tree is locked.
See Also:
Tree.isLocked()

testWidth

public double testWidth()
Returns the width of the combined tree layout.

Returns:
the width of the combined tree layout.

apply

public void apply(Tree parent)
Applies the combined tree layout composed by this TreeCombinationList to the tree layout of parent.

Parameters:
parent - the tree layout the combined tree layout composed by this TreeCombinationList is applied to. It must be the parent of the tree layouts inserted into this list.

bubbleDown

public double bubbleDown(double currentWidth,
                         boolean mayFlip)

bubbleUp

public double bubbleUp(double currentWidth,
                       boolean mayFlip)


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