edu.princeton.cs.algs4.growingtree.framework
Interface DrawingTree<P extends NodeProperties>

All Superinterfaces:
Tree<P>
All Known Subinterfaces:
AnimatingTree<P>
All Known Implementing Classes:
GrowingTreeHead, GrowingTreeNode, MovingBSTTree

public interface DrawingTree<P extends NodeProperties>
extends Tree<P>

The DrawingTree interface extends Tree because all Drawing Trees must also be Trees.

The interface simply inforces the defining of numerous methods which allow for the drawing of the Tree onto a given Graphics2D. The interface also defines many mutator and accesor methods for information concerning the drawing of the DrawingTree

Version:
1.2 9/15/01
Author:
Corey Sanders

Method Summary
 void drawNode()
          Draws the node of the tree to the previously defined Graphics2D.
 void drawNode(java.awt.Graphics2D g2)
          Draws the node of the tree to the given Graphics2D.
 void drawNode(java.awt.Graphics2D g2, java.awt.geom.AffineTransform a)
          Draws the node of the tree to the given Graphics2D, using the AffineTransform.
 void drawNodeAndLink()
          Draws the node and link of the tree to the previously defined Graphics2D.
 void drawNodeAndLink(java.awt.Graphics2D g2)
          Draws the node and link of the tree to the given Graphics2D.
 void drawNodeAndLink(java.awt.Graphics2D g2, double sectionHeight, java.awt.geom.AffineTransform a, double drawingLevel, double powerLevel)
          Draws the node and link of the tree to the given Graphics2D.
 java.awt.geom.AffineTransform getCurrentTransform()
          Gets the AffineTransform defined within the tree.
 double getDrawingLevel()
          Gets the drawing level for the current DrawingTree.
 java.awt.geom.Rectangle2D getScreenBounds()
          Gets the bounds of the screen to which the tree is drawing.
 double getSectionHeight()
          Gets the height of the section for the DrawingTree.
 NodeSettings getSettings()
          Gets the NodeSettings of the tree.
 void setScreenBounds(java.awt.geom.Rectangle2D bounds)
          Sets the bounds of the screen to which the tree is drawing.
 void setSettings(NodeSettings s)
          Sets the NodeSettings of the tree.
 
Methods inherited from interface edu.princeton.cs.algs4.growingtree.framework.Tree
getChildren, getKey, getLevel, getParentTree, getValue, isEmpty, size
 

Method Detail

getDrawingLevel

double getDrawingLevel()
Gets the drawing level for the current DrawingTree. This is a necessary method for allowing intermidiary drawing between two levels, because the param is a double, not an integer.

Returns:
the double level for the drawing node.

getSectionHeight

double getSectionHeight()
Gets the height of the section for the DrawingTree. The section height is generally used to determine link length and node height when drawing the tree.

Returns:
double height of the drawing section for the node.

getCurrentTransform

java.awt.geom.AffineTransform getCurrentTransform()
Gets the AffineTransform defined within the tree. The current transform is used when calling draw without the AffineTransform value.

Returns:
transform set for the current drawing of the tree.

getScreenBounds

java.awt.geom.Rectangle2D getScreenBounds()
Gets the bounds of the screen to which the tree is drawing. The bounds generally is simply the rectangle enclosing the Graphics2D passed.

Returns:
the rectangle representing the bounds of the screen.

setScreenBounds

void setScreenBounds(java.awt.geom.Rectangle2D bounds)
Sets the bounds of the screen to which the tree is drawing. Generally, these bounds are set using getClipBounds on the Graphics2D passed, however, the bounds can be set in any way.

Parameters:
bounds - the rectangle representing the bounds of the screen.

setSettings

void setSettings(NodeSettings s)
Sets the NodeSettings of the tree. These settings are used for drawing the node and the links of the given tree.

Parameters:
s - NodeSettings for use in drawing the tree.

getSettings

NodeSettings getSettings()
Gets the NodeSettings of the tree. These settings are used for drawing the node and the links of the given tree.

Returns:
NodeSettings for use in drawing the tree.

drawNode

void drawNode()
Draws the node of the tree to the previously defined Graphics2D. The drawing uses the previously defined AffineTransform.


drawNode

void drawNode(java.awt.Graphics2D g2)
Draws the node of the tree to the given Graphics2D. The drawing uses the previously defined AffineTransform.

Parameters:
g2 - graphics to which the node is drawn.

drawNode

void drawNode(java.awt.Graphics2D g2,
              java.awt.geom.AffineTransform a)
Draws the node of the tree to the given Graphics2D, using the AffineTransform. The drawing uses the AffineTransform to determine the exact way to draw the node.

Parameters:
g2 - graphics to which the node is drawn.
a - transform to draw the node.

drawNodeAndLink

void drawNodeAndLink()
Draws the node and link of the tree to the previously defined Graphics2D. The drawing also uses the previously defined AffineTransform, section height, drawing level, and power level.


drawNodeAndLink

void drawNodeAndLink(java.awt.Graphics2D g2)
Draws the node and link of the tree to the given Graphics2D. The drawing uses the previously defined AffineTransform, section height, drawing level, and power level.

Parameters:
g2 - graphics to which the node is drawn.

drawNodeAndLink

void drawNodeAndLink(java.awt.Graphics2D g2,
                     double sectionHeight,
                     java.awt.geom.AffineTransform a,
                     double drawingLevel,
                     double powerLevel)
Draws the node and link of the tree to the given Graphics2D. The drawing generally uses the AffineTransform, section height, drawing level, and power level to render the node and its links.

Parameters:
g2 - graphics to which the node and links are drawn.
sectionHieght - the height of the tree' section, to draw the correct lengths for the links.
a - transfrom to draw the node and links.
drawingLevel - the level in the tree to which the node is currently being drawn.
powerLevel - the power to which the links extend, depending on how many links are present.