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

All Superinterfaces:
Tree<P>, TreeHead<P>
All Known Subinterfaces:
AnimatingTreeHead<P>
All Known Implementing Classes:
GrowingTreeHead

public interface DrawingTreeHead<P extends NodeProperties>
extends TreeHead<P>

The interface defines numerous methods which allow for the drawing of the entire DrawingTree onto a given Graphics2D using the head methods. The interface also defines many mutator and accesor methods for information concerning the drawing of the entire DrawingTree

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

Field Summary
 
Fields inherited from interface edu.princeton.cs.algs4.growingtree.framework.TreeHead
BALANCE_NODE, CHANGE_DISPLAY, FREEZE, INORDER_TRAVERSAL, INSERT_NODE, LEVELORDER_TRAVERSAL, PARTITION_NODE, POSTORDER_TRAVERSAL, PREORDER_TRAVERSAL, REMOVE_NODE, ROTATE_TO_TOP_NODE, ROTATE_UP, ROTATE_UP_DOUBLE, SEARCH, SELECT, SPLAY_NODE, SWAP, TRAVERSE
 
Method Summary
 void DrawTree(java.awt.Graphics2D g2)
          Draws the entire tree from the null head down.
 DrawingTree<P> findNode(double x, double y)
          Finds the node represented by the x-y coordinates given.
 KeySettings getDrawingKeySettings()
          Gets the KeySettings for the entire tree.
 NodeSettings getDrawingNodeSettings()
          Gets the NodeSettings for the entire tree.
 double getNodeHeight()
          Gets the height of the standard node within the tree.
 double getNodeWidth()
          Gets the width of the standard node within the tree.
 java.awt.geom.Rectangle2D getScreenBounds()
          Gets the bounds of the screen to which the tree is drawing.
 void MakeTree(java.awt.Graphics2D g2)
          Makes the entire tree from the null head down.
 void setScreenBounds(java.awt.geom.Rectangle2D screen)
          Sets the bounds of the screen to which the tree is drawing.
 void setTreeSettings(NodeSettings s, KeySettings k)
          Sets the NodeSettings for the entire tree from the head down.
 
Methods inherited from interface edu.princeton.cs.algs4.growingtree.framework.TreeHead
addTreeMessageListener, balance, balanceTree, clear, fixLevel, getChild, getTreeLevel, insert, isTreeEmpty, partition, remove, remove, removeTreeMessageListener, resetTreeLevel, search, select, setChild, size, waitingAction
 
Methods inherited from interface edu.princeton.cs.algs4.growingtree.framework.Tree
getChildren, getKey, getLevel, getParentTree, getValue, isEmpty
 

Method Detail

setTreeSettings

void setTreeSettings(NodeSettings s,
                     KeySettings k)
Sets the NodeSettings for the entire tree from the head down. These settings are used for drawing the node and the links of each given tree.

Parameters:
s - NodeSettings for use in drawing the entire tree.
k - KeySettings for use in drawing the keys of the entire tree.

getDrawingNodeSettings

NodeSettings getDrawingNodeSettings()
Gets the NodeSettings for the entire tree.

Returns:
NodeSettings for defined for the entire tree.

getDrawingKeySettings

KeySettings getDrawingKeySettings()
Gets the KeySettings for the entire tree.

Returns:
KeySettings for defined for the entire tree.

getNodeWidth

double getNodeWidth()
Gets the width of the standard node within the tree. Every node is not necessarily the same width, but the standard is set within the Head.

Returns:
width of the standard node.

getNodeHeight

double getNodeHeight()
Gets the height of the standard node within the tree. Every node is not necessarily the same height, but the standard is set within the Head.

Returns:
height of the standard node.

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 screen)
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.

MakeTree

void MakeTree(java.awt.Graphics2D g2)
Makes the entire tree from the null head down. The tree is made using the Graphics2D, and generally fills the entire Graphics2D parameter. This method allows the tree's drawing information to be defined without having to render the entire tree.

Parameters:
g2 - Graphics2D which the tree is made to fit unto.

DrawTree

void DrawTree(java.awt.Graphics2D g2)
Draws the entire tree from the null head down. The tree is drawn onto the Graphics2D, and uses the information defined in the previous call to MakeTree.

Parameters:
g2 - Graphics2D which the tree is drawn onto.

findNode

DrawingTree<P> findNode(double x,
                        double y)
Finds the node represented by the x-y coordinates given. The (x,y) location represents a location within the Graphics2D to which the node appears. The recursive method progresses through the entire tree looking for the proper node.

Parameters:
x - x-coordinate to find the node.
y - y-coordinate to find the node.
Returns:
DrawingTree representing the x-y coordinates passed or null if no node is found.