AnimationHandlerTree


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.

 

Method Index


public AnimationHandlerTree(Graphics dg, Dimension dd)

Arguments:

  1. dg is a graphics object

  2. dd is the size of the drawing panel

The constructor sets up some colors.


public void setSpeed(int i)

Arguments:

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

Arguments:

  1. level is the level of the tree

  2. xPos is the relative horizontal position in the level

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

Arguments:

  1. n is the node to draw

Draws the node


public void checkNode(int level, int xPos, int data, Color c)

Arguments:

  1. level is the level of the node
  2. xPos is the horizontal position of the node
  3. data is the value of the node
  4. c is the color to color the node

Colors the node with color c.


public void eraseNode(Node n)

Arguments:

  1. n is the node to erase

Erases node n.


public void checkNode(Node n, Color c)

Arguments:

  1. n is the node to color
  2. c is the color to make n

Color n with color c.


public void connectNodes(Node a, Node b, boolean draw)

Arguments:

  1. a is one of the nodes to connect
  2. b is one of the nodes to connect
  3. if draw is true draw a line, else erase the line

Draw or erase a line between a and b.


private void showSkeleton()

Shows the full tree with empty nodes.


Ted Jenks