Home / Development / Documentation / 2.0.44 / NodeLadderizeComparable
TreeGraph 2
 


info.bioinfweb.treegraph.document
Class NodeLadderizeComparable

java.lang.Object
  extended by info.bioinfweb.treegraph.document.NodeLadderizeComparable
All Implemented Interfaces:
Comparable<NodeLadderizeComparable>

public class NodeLadderizeComparable
extends Object
implements Comparable<NodeLadderizeComparable>

This class is a wrapper class for Node-objects that allowws them to be compared by their number of terminal subnodes. It is used to ladderize a tree.

Author:
Ben Stöver

Field Summary
static String CHILD_COUNT_KEY
           
private  boolean ladderizeDown
           
private  Node node
           
 
Constructor Summary
NodeLadderizeComparable(Node node, boolean ladderizeDown)
           
 
Method Summary
static void addToNode(NodeLadderizeComparable[] elements, Node root)
          This method is used to reinsert sorted elements in the a subtree.
 int compareTo(NodeLadderizeComparable other)
          Compares which node has more (or less) nodes in its subtree.
static int countNodes(Node root)
          Sets all the childCount values of the contained Node-objects.
static NodeLadderizeComparable[] encloseSubnodes(Node root, boolean ladderizeDown)
          Encloses all direct subelements of root with a NodeLadderizeComparable- object and adds this objects to an array that is returned.
 Node getNode()
           
 boolean isLadderizeDown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHILD_COUNT_KEY

public static final String CHILD_COUNT_KEY
See Also:
Constant Field Values

node

private Node node

ladderizeDown

private boolean ladderizeDown
Constructor Detail

NodeLadderizeComparable

public NodeLadderizeComparable(Node node,
                               boolean ladderizeDown)
Method Detail

isLadderizeDown

public boolean isLadderizeDown()

getNode

public Node getNode()

compareTo

public int compareTo(NodeLadderizeComparable other)
Compares which node has more (or less) nodes in its subtree. Note that countNodes() has to be called first.

Specified by:
compareTo in interface Comparable<NodeLadderizeComparable>
Parameters:
other - an other NodeLadderizeComparable that should be compared
See Also:
info.bioinfweb.treegraph.document.Node#getChildCount(), info.bioinfweb.treegraph.document.NodeLadderizeComparable#countNodes()

encloseSubnodes

public static NodeLadderizeComparable[] encloseSubnodes(Node root,
                                                        boolean ladderizeDown)
Encloses all direct subelements of root with a NodeLadderizeComparable- object and adds this objects to an array that is returned.

Parameters:
root - the parent element of the subelements to enclose
ladderizeDown - whether the elements will be ladderized down
Returns:
the array of NodeLadderizeComparable-objects

addToNode

public static void addToNode(NodeLadderizeComparable[] elements,
                             Node root)
This method is used to reinsert sorted elements in the a subtree.

Parameters:
elements - the elements to insert
root - the future parent element of the elements to insert

countNodes

public static int countNodes(Node root)
Sets all the childCount values of the contained Node-objects. This methode is used to perform ladderization.

Returns:
the count of nodes in the subtree under root
See Also:
info.bioinfweb.treegraph.document.Node#getChildCount(), LadderizeEdit, LadderizeAction