Class SearchBSTAnimation

java.lang.Object
  |
  +--AbstractAnimation
        |
        +--SearchBSTAnimation
All Implemented Interfaces:
Animation

public class SearchBSTAnimation
extends AbstractAnimation

The Animation object that defines the Searching in a BSTTree.

The object restores all values changed in the given nodes, however, if the object is never allowed to finish, the restoring of values becomes impossible. On any exception occuring elsewhere, the object may not restore the conditions correctly.


Field Summary
static int DEFAULT_CONVERSION
          The Default step conversion used in animation (300).
 
Fields inherited from class AbstractAnimation
DEFAULT_STEP, listeners
 
Fields inherited from interface Animation
ANIMATION_MESSAGE, BEGIN, FINISH, PAUSE, PLAY, REDRAW, REWIND, STEP, STOP
 
Constructor Summary
SearchBSTAnimation(java.lang.Comparable keySearch, BSTTreeHead headNode)
          The constructor which initiates the status and sets the color schemes to null.
SearchBSTAnimation(java.lang.Comparable keySearch, BSTTreeHead headNode, 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(BSTTree node)
          Add a step to the Search Animation.
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 search.
 NodeSettings getAnimationSchemeRight()
          Gets the NodeSettings for the right animation scheme for the search.
 NodeSettings getAnimatorScheme()
          Gets the NodeSettings for the animator scheme for the search.
 KeySettings getKeyAnimatorScheme()
          Sets the KeySettings for the animator scheme key for the search.
 java.lang.Comparable getKeySearch()
          Gets the comparable object being searched for.
 boolean isSearchHit()
          Gets whether a search hit has been found.
 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.
 void setKeyAnimatorScheme(KeySettings scheme)
          Sets the KeySettings for the animator scheme key for 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

DEFAULT_CONVERSION

public static final int DEFAULT_CONVERSION
The Default step conversion used in animation (300).

See Also:
Constant Field Values
Constructor Detail

SearchBSTAnimation

public SearchBSTAnimation(java.lang.Comparable keySearch,
                          BSTTreeHead headNode,
                          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.

Parameters:
keySearch - the object key being searched for with the tree.
headNode - the head of the tree being searched.
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.
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.

SearchBSTAnimation

public SearchBSTAnimation(java.lang.Comparable keySearch,
                          BSTTreeHead headNode)
The constructor which initiates the status and sets the color schemes to null. All colors are set to default for this animation. The key which is being searched for must be passed.

Parameters:
keySearch - the object key being searched for with the tree.
headNode - the head of the tree being searched.
Method Detail

isSearchHit

public boolean isSearchHit()
Gets whether a search hit has been found.

Returns:
true if a search hit was found.

getKeySearch

public java.lang.Comparable getKeySearch()
Gets the comparable object being searched for.

Returns:
comparable object being searched for.

getAnimationSchemeLeft

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

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 search.

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 search.

Returns:
NodeSettings for the node animating.

getKeyAnimatorScheme

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

Returns:
KeySettings for the key of the node animating.

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(BSTTree node)
Add a step to the Search Animation. The step is added with only a BSTTree.When the step is performed, the search will transform the node passed (Color Scheme only). The nodes are automatically added as listeners.

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.

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.