Class InsertBSTAnimation

java.lang.Object
  |
  +--AbstractAnimation
        |
        +--InsertBSTAnimation
All Implemented Interfaces:
Animation
Direct Known Subclasses:
InsertRedBlackAnimation

public class InsertBSTAnimation
extends AbstractAnimation

The Animation object that defines the Insertion into a BSTTree. Two constructors exist, one setting the animator and animation color Schemes. The addition of nodes that the Animation must pass include both the AffineTransform and then BSTTree or either separately.


Field Summary
protected  int comparisonCount
          Counts the amount of comparisons made.
protected  int insertionSize
          Counts the initial insertion size of the tree.
protected  int nextNodeIndex
           
protected  int previousNodeIndex
          Previous and next node indeces
 
Fields inherited from class AbstractAnimation
DEFAULT_CONVERSION, DEFAULT_STEP, listeners
 
Fields inherited from interface Animation
ANIMATION_MESSAGE, BEGIN, FINISH, PAUSE, PLAY, REDRAW, REWIND, STEP, STOP
 
Constructor Summary
InsertBSTAnimation(BSTTree node)
          The constructor which initiates the status and sets the colorSchemes to null.
InsertBSTAnimation(BSTTree node, NodeSettings AnimationSchemeLeft, NodeSettings AnimationSchemeRight, NodeSettings AnimatorScheme, KeySettings KeyAnimatorScheme, java.lang.String startingCmd, int stepTime)
          The constructor which initiates the status and prepares the colorSchemes.
 
Method Summary
 void add(java.awt.geom.AffineTransform a)
          Add a step to the InsertAnimation.
 void add(java.awt.geom.AffineTransform a, BSTTree node)
          Add a step to the InsertAnimation.
 void add(BSTTree node)
          Add a step to the InsertAnimation.
protected  void animationAction(java.lang.String cmd, java.lang.String description)
          Calls all of the listeners of the current Animation and passed information regarding the progress and status of the current Animation.
 void drawAnimation(java.awt.Graphics2D g2, java.lang.String startingStatus)
          Draws the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth).
 NodeSettings getAnimationSchemeLeft()
          Gets the NodeSettings for the left animation scheme for the insertion.
 NodeSettings getAnimationSchemeRight()
          Gets the NodeSettings for the right animation scheme for the insertion.
 NodeSettings getAnimatorScheme()
          Gets the NodeSettings for the animator scheme for the insertion.
protected  double getCurrentLocation()
          Gets the current location of the Insertion.
protected  BSTTree getInsertNode()
          Gets the node currently being drawn during the Insertion.
 KeySettings getKeyAnimatorScheme()
          Sets the KeySettings for the animator scheme key for the insertion.
protected  AffineTransformList getMovements()
          Gets the affine transform movements of the Insertion.
protected  java.util.LinkedList getNodeMovements()
          Gets the nodes of the Insertion.
protected  double getPreviousLocation()
          Gets the previous location of the Insertion.
protected  java.awt.geom.AffineTransform resetPosition(int nodeIndex)
          Returns the AffineTransform after resetting the transform based upon the node's position.
protected  void restore()
          Restores the settings of all nodes encountered during the animation.
 void setAnimationSchemeLeft(NodeSettings scheme)
          Sets the NodeSettings for the left animation scheme for the insertion.
 void setAnimationSchemeRight(NodeSettings scheme)
          Sets the NodeSettings for the right animation scheme for the insertion.
 void setAnimatorScheme(NodeSettings scheme)
          Sets the NodeSettings for the animator scheme for the insertion.
protected  void setCurrentLocation(double currentLocation)
          Sets the current location of the Insertion.
protected  void setInsertNode(BSTTree node)
          Sets the node currently being drawn during the Insertion.
 void setKeyAnimatorScheme(KeySettings scheme)
          Sets the KeySettings for the animator scheme key for the insertion.
protected  void setPreviousLocation(double previousLocation)
          Sets the previous location of the Insertion.
 
Methods inherited from class AbstractAnimation
addAnimationListener, addDescription, animationAction, animationAction, drawAnimation, getDescription, getListeners, getStartingCommand, getStatus, getStep, getStepConversion, getStepSize, getStepTime, messageAction, removeAnimationListener, setStartingCommand, setStatus, setStep, setStepConversion, setStepSize, setStepTime
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

previousNodeIndex

protected int previousNodeIndex
Previous and next node indeces


nextNodeIndex

protected int nextNodeIndex

comparisonCount

protected int comparisonCount
Counts the amount of comparisons made.


insertionSize

protected int insertionSize
Counts the initial insertion size of the tree.

Constructor Detail

InsertBSTAnimation

public InsertBSTAnimation(BSTTree node,
                          NodeSettings AnimationSchemeLeft,
                          NodeSettings AnimationSchemeRight,
                          NodeSettings AnimatorScheme,
                          KeySettings KeyAnimatorScheme,
                          java.lang.String startingCmd,
                          int stepTime)
The constructor which initiates the status and prepares the colorSchemes. The node which is animating must be passed. The first step added is the identity step.

Parameters:
node - the BSTTree which is animated during the animation.
AnimationSchemeLeft - the NodeSettings associated with a color scheme according to NodeSettings for the left Animation.
AnimationSchemeRight - the NodeSettings associated with a color scheme according to NodeSettings for the right Animation.
AnimatorScheme - the NodeSettings associated with a color scheme according to NodeSettings.
KeyAnimatorScheme - the KeySettings associated with a color scheme according to KeySettings.
startingCmd - the Animation command that this should start.
stepTime - the time for each step of the Animation. Sets the initial value.

InsertBSTAnimation

public InsertBSTAnimation(BSTTree node)
The constructor which initiates the status and sets the colorSchemes to null. No colors will be change using this animation. The node which is animating must be passed. The first step added is the identity step.

Parameters:
node - the BSTTree which is animated during the animation.
Method Detail

getCurrentLocation

protected double getCurrentLocation()
Gets the current location of the Insertion.

Returns:
double of the current location of the ndoe currently being inserted and animated.

getPreviousLocation

protected double getPreviousLocation()
Gets the previous location of the Insertion.

Returns:
double of the previous location of the ndoe currently being inserted and animated.

getNodeMovements

protected java.util.LinkedList getNodeMovements()
Gets the nodes of the Insertion.

Returns:
LinkedList of the nodes.

getMovements

protected AffineTransformList getMovements()
Gets the affine transform movements of the Insertion.

Returns:
AffineTransformList of the affine transform movements.

getInsertNode

protected BSTTree getInsertNode()
Gets the node currently being drawn during the Insertion.

Returns:
BSTTree of the ndoe currently being inserted and animated.

getAnimationSchemeLeft

public NodeSettings getAnimationSchemeLeft()
Gets the NodeSettings for the left animation scheme for the insertion.

Returns:
NodeSettings for the node after the animated node passes it to the left.

getAnimationSchemeRight

public NodeSettings getAnimationSchemeRight()
Gets the NodeSettings for the right animation scheme for the insertion.

Returns:
NodeSettings for the node after the animated node passes it to the right.

getAnimatorScheme

public NodeSettings getAnimatorScheme()
Gets the NodeSettings for the animator scheme for the insertion.

Returns:
NodeSettings for the node animating.

getKeyAnimatorScheme

public KeySettings getKeyAnimatorScheme()
Sets the KeySettings for the animator scheme key for the insertion.

Returns:
KeySettings for the key of the node animating.

setCurrentLocation

protected void setCurrentLocation(double currentLocation)
Sets the current location of the Insertion.

Returns:
currentLocation double of the current location of the ndoe currently being inserted and animated.

setPreviousLocation

protected void setPreviousLocation(double previousLocation)
Sets the previous location of the Insertion.

Parameters:
previousLocation - double of the previous location of the ndoe currently being inserted and animated.

setInsertNode

protected void setInsertNode(BSTTree node)
Sets the node currently being drawn during the Insertion.


setAnimationSchemeLeft

public void setAnimationSchemeLeft(NodeSettings scheme)
Sets the NodeSettings for the left animation scheme for the insertion. The settings affect the change the node makes after the inserted node passes it to the left.

Parameters:
scheme - NodeSettings for the node after the animated node passes it to the left.

setAnimationSchemeRight

public void setAnimationSchemeRight(NodeSettings scheme)
Sets the NodeSettings for the right animation scheme for the insertion. The settings affect the change the node makes after the inserted node passes it to the right.

Parameters:
scheme - NodeSettings for the node after the animated node passes it to the right.

setAnimatorScheme

public void setAnimatorScheme(NodeSettings scheme)
Sets the NodeSettings for the animator scheme for the insertion. The settings affect the change the node makes as it is animating during the insertion

Parameters:
scheme - NodeSettings for the node animating.

setKeyAnimatorScheme

public void setKeyAnimatorScheme(KeySettings scheme)
Sets the KeySettings for the animator scheme key for the insertion. The settings affect the change the key of the node makes as it is animating during the insertion

Parameters:
scheme - KeySettings for the key of the node animating.

add

public void add(java.awt.geom.AffineTransform a)
Add a step to the InsertAnimation. The step is added with only an AffineTransform, which is used to draw that step in the Animation. No node will be affected, even if the transform comes from a node.

Parameters:
a - AffineTransform to be drawn in the following step.

add

public void add(java.awt.geom.AffineTransform a,
                BSTTree node)
Add a step to the InsertAnimation. The step is added with an AffineTransform and a BSTTree node. Consequently, when the step is performed, the node will transform to the given AffineTransform, and the node passed will be modified (Color Scheme only).

Parameters:
a - AffineTransform to be drawn in the following step.
node - the color scheme is changed when the step is completed.

add

public void add(BSTTree node)
Add a step to the InsertAnimation. The step is added with only a BSTTree which is used to determine the AffineTransform for the current step.W hen the step is performed, the node will transform to the passed node's AffineTransform, and the node passed will be modified (Color Scheme only).

Parameters:
node - the color scheme is changed when the step is completed.

drawAnimation

public void drawAnimation(java.awt.Graphics2D g2,
                          java.lang.String startingStatus)
Draws the animation of the next step, using the status of the animation (Animation.PLAY, Animation.PAUSE and so forth). After completing the drawing, the Animation sends an AnimationEvent to all its listeners, indicating any information that the listerners may wish to use.

Specified by:
drawAnimation in interface Animation
Overrides:
drawAnimation in class AbstractAnimation
Parameters:
g2 - the graphics to which the animation step should be drawn.
startingStatus - the status used as the starting command of animation, if needed.

restore

protected void restore()
Restores the settings of all nodes encountered during the animation. Usually called at the end of the animation (Animation.FINISH) to restore all settings changed throughout the animation. This also restores the animator node.


resetPosition

protected java.awt.geom.AffineTransform resetPosition(int nodeIndex)
Returns the AffineTransform after resetting the transform based upon the node's position. The node Index calls the node list to get the node for that index. If no node is present, then the AffineTransform previously declared for the nodeIndex is returned. Otherwise, the AffineTransform associated with the node is returned.

Parameters:
nodeIndex - index for the resetting AffineTransform.
Returns:
AffineTransform for the nodeIndex.

animationAction

protected void animationAction(java.lang.String cmd,
                               java.lang.String description)
Calls all of the listeners of the current Animation and passed information regarding the progress and status of the current Animation. Additionally, the id of the type of animation is passed. Within, the animationEventPerformed method is called.

Overrides:
animationAction in class AbstractAnimation
Parameters:
cmd - String Animation command passed instead of the current Status.
description - String description for messages.