TreeDraw
Class LabelledTreeImpl

java.lang.Object
  extended by TreeDraw.LabelledTreeImpl
All Implemented Interfaces:
LabelledTree, Tree

 class LabelledTreeImpl
extends java.lang.Object
implements LabelledTree

Sample implementation of a labelled tree, used to test the tree drawer.


Field Summary
private  LabelledTreeImpl[] children
          The node's children.
private  java.lang.String label
          The node's label.
 
Constructor Summary
LabelledTreeImpl(java.lang.String label, LabelledTreeImpl[] children)
          Builds a tree node.
 
Method Summary
 void addChild(LabelledTreeImpl child)
          Adds a child to this node.
 Tree getChild(int i)
          Returns the i'th child (subtree) of this tree (node).
 java.lang.String getLabel()
          Returns this tree node's label.
 int numChildren()
          Returns the number of children of this tree node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

children

private LabelledTreeImpl[] children
The node's children.


label

private java.lang.String label
The node's label.

Constructor Detail

LabelledTreeImpl

public LabelledTreeImpl(java.lang.String label,
                        LabelledTreeImpl[] children)
Builds a tree node.

Parameters:
label - The new node's label.
children - The new node's children.
Method Detail

addChild

public void addChild(LabelledTreeImpl child)
Adds a child to this node. Note that this tree implementation is not optimized for this operation.

Parameters:
child - The child to add to the node.

numChildren

public int numChildren()
Returns the number of children of this tree node.

Specified by:
numChildren in interface Tree

getChild

public Tree getChild(int i)
Returns the i'th child (subtree) of this tree (node).

Specified by:
getChild in interface Tree

getLabel

public java.lang.String getLabel()
Returns this tree node's label.

Specified by:
getLabel in interface LabelledTree