This class is used to animate the algorithm by drawing to the off screen image. This class is essentially the same for all tree algorithms. It receives calls from the algorithm object and draws the animations. Some of the methods in the Method Index are contained in all of the algorithms.
public AnimationHandlerTree(Graphics dg, Dimension dd)
dg is a graphics object
dd is the size of the drawing panel
The constructor sets up some colors.
public void setSpeed(int i)
i is the delay time
Delay time is set to i.
public void treeInit()
Creates an instance of NodePosition
public void setNodePosition(int level, int xPos, Node n)
level is the level of the tree
xPos is the relative horizontal position in the level
n is the node whose position is being set
Sets n's level to level and n's xPos to xPos. Sets n's animation point with a call to nodePosition.getPosition()
public void blank()
Clears the draw panel
public void drawNode(Node n)
n is the node to draw
Draws the node
public void checkNode(int level, int xPos, int data, Color c)
Colors the node with color c.
public void eraseNode(Node n)
Erases node n.
public void checkNode(Node n, Color c)
Color n with color c.
public void connectNodes(Node a, Node b, boolean draw)
Draw or erase a line between a and b.
private void showSkeleton()
Shows the full tree with empty nodes.