TreeDraw
Class TreeDrawingInstructions

java.lang.Object
  extended by TreeDraw.TreeDrawingInstructions
All Implemented Interfaces:
Tree

 class TreeDrawingInstructions
extends java.lang.Object
implements Tree

Instances of this class are trees which contain useful information to draw a LabelledTree. The structure of a TreeDrawingInstructions instance is the same as that of its associated Tree instance, but each TreeDrawingInstructions node contains four useful parameters to draw a tree node: center, width, offset and childOffset. Parameter semantics is as follows: center: X coord of tree's center width: rightmost X coord of tree offset: X coord of tree's root childOffset: X coord of tree's leftmost child


Field Summary
private  double center
           
private  double childOffset
           
private  TreeDrawingInstructions[] children
          The instructions to draw this tree's children.
private  double offset
           
private  LabelledTree tree
          The labelled tree to draw.
private  double width
           
 
Constructor Summary
TreeDrawingInstructions(LabelledTree tree, TreeDrawingInstructions[] children, double offset, double childOffset, double center, double width)
          Creates a TreeDrawingInstructions instance from its attributes.
 
Method Summary
 double getCenter()
           
 Tree getChild(int i)
          Returns the ith child of this instructions node.
 double getChildOffset()
           
 java.lang.String getLabel()
          Returns this instructions node's tree's root node's label.
 double getOffset()
           
 LabelledTree getTree()
          Returns the labelled tree to draw.
 double getWidth()
           
 int numChildren()
          Returns the number of children of this instructions node.
 java.lang.String toString()
          Returns a string representation of this instruction tree.
private  void toStringAux(int nestLevel, java.lang.StringBuffer toAppendTo)
          Auxilliary method for toString() implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tree

private LabelledTree tree
The labelled tree to draw.


center

private double center

width

private double width

offset

private double offset

childOffset

private double childOffset

children

private TreeDrawingInstructions[] children
The instructions to draw this tree's children.

Constructor Detail

TreeDrawingInstructions

public TreeDrawingInstructions(LabelledTree tree,
                               TreeDrawingInstructions[] children,
                               double offset,
                               double childOffset,
                               double center,
                               double width)
Creates a TreeDrawingInstructions instance from its attributes.

Parameters:
tree -
children -
offset -
childOffset -
center -
width -
Method Detail

getChildOffset

public double getChildOffset()
Returns:
Returns the childoffset.

getTree

public LabelledTree getTree()
Returns the labelled tree to draw.


getCenter

public double getCenter()
Returns:
Returns the center.

getOffset

public double getOffset()
Returns:
Returns the offset.

getWidth

public double getWidth()
Returns:
Returns the width.

numChildren

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

Specified by:
numChildren in interface Tree

getChild

public Tree getChild(int i)
Returns the ith child of this instructions node.

Specified by:
getChild in interface Tree

getLabel

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

Returns:

toStringAux

private void toStringAux(int nestLevel,
                         java.lang.StringBuffer toAppendTo)
Auxilliary method for toString() implementation.


toString

public java.lang.String toString()
Returns a string representation of this instruction tree.

Overrides:
toString in class java.lang.Object