TreeDraw
Class TreeDrawer

java.lang.Object
  extended by TreeDraw.TreeDrawer

public class TreeDrawer
extends java.lang.Object

This public class provides a method to draw a tree in a java.awt.Graphics drawing environment. A tree drawer can be parametrized by setting three values:


Field Summary
private  double lineSeparation
          This parameter determines the separation between tree lines and node labels.
private  double minHorizSpace
          Minimum horizontal space between nodes, expressed in pixels.
private  double vertSpace
          Minimum vertical space between nodes, expressed in pixels.
 
Constructor Summary
TreeDrawer()
          Default constructor.
 
Method Summary
 void draw(LabelledTree toDraw, java.awt.Graphics toDrawIn, double xposition, double yposition)
           
private  void draw(TreeDrawingInstructions tds, java.awt.Graphics toDrawIn, double xposition, double yposition)
          Draws a tree using its TreeDrawingInstructions.
private  TreeDrawingInstructions generateDrawingInstructions(LabelledTree t, java.awt.FontMetrics fm)
          Generates drawing instructions allowing to draw a tree in an environment with a given FontMetrics.
 double getLineSeparation()
           
 double getMinHorizSpace()
           
 double getVertSpace()
           
 void setLineSeparation(double lineSeparation)
          Sets the line separation parameter.
 void setMinHorizSpace(double minHorizSpace)
          Sets the minimum horizontal space between children.
 void setVertSpace(double vertSpace)
          Sets the vertical spacing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

minHorizSpace

private double minHorizSpace
Minimum horizontal space between nodes, expressed in pixels.


vertSpace

private double vertSpace
Minimum vertical space between nodes, expressed in pixels.


lineSeparation

private double lineSeparation
This parameter determines the separation between tree lines and node labels.

Constructor Detail

TreeDrawer

public TreeDrawer()
Default constructor.

Method Detail

getLineSeparation

public double getLineSeparation()
Returns:
Returns the line separation parameter.

setLineSeparation

public void setLineSeparation(double lineSeparation)
Sets the line separation parameter.


getMinHorizSpace

public double getMinHorizSpace()
Returns:
Returns the minimum horizontal space between children.

setMinHorizSpace

public void setMinHorizSpace(double minHorizSpace)
Sets the minimum horizontal space between children.


getVertSpace

public double getVertSpace()
Returns:
Returns the vertical spacing.

setVertSpace

public void setVertSpace(double vertSpace)
Sets the vertical spacing.


draw

public void draw(LabelledTree toDraw,
                 java.awt.Graphics toDrawIn,
                 double xposition,
                 double yposition)

draw

private void draw(TreeDrawingInstructions tds,
                  java.awt.Graphics toDrawIn,
                  double xposition,
                  double yposition)
Draws a tree using its TreeDrawingInstructions.

Parameters:
tds - A TreeDrawingInstructions showing how to draw the tree.
toDrawIn - java.awt.Graphics object to draw in.
xposition - Leftmost X position to draw in.
yposition - Upmost Y position to draw in.

generateDrawingInstructions

private TreeDrawingInstructions generateDrawingInstructions(LabelledTree t,
                                                            java.awt.FontMetrics fm)
Generates drawing instructions allowing to draw a tree in an environment with a given FontMetrics.

Parameters:
t - The labelled tree to draw.
fm - FontMetrics gotten from the Graphics object.
Returns:
Instructions for drawing the tree.