edu.princeton.cs.algs4.growingtree.framework
Class GrowingTreeHead<P extends NodeProperties>

java.lang.Object
  extended by edu.princeton.cs.algs4.growingtree.framework.GrowingTreeNode<P>
      extended by edu.princeton.cs.algs4.growingtree.framework.GrowingTreeHead<P>
All Implemented Interfaces:
AnimatingTree<P>, AnimatingTreeHead<P>, AnimationListener, DrawingTree<P>, DrawingTreeHead<P>, Tree<P>, TreeHead<P>, java.util.EventListener

public class GrowingTreeHead<P extends NodeProperties>
extends GrowingTreeNode<P>
implements TreeHead<P>, AnimationListener, AnimatingTreeHead<P>

This class provides the head structure for a BSTTree. It implements the interface for TreeHead and implements all important methods necessary for maintaining a Binary Search Tree. The BSTTreeHead additionally extends BSTTree, using the information and methods of a BSTTree in addition to the specialized methods of a BSTTreeHead.

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

Field Summary
static int BINARY_DISPLAY
          Binary Display
static int SECTIONAL_DISPLAY
          sectional display
static java.lang.String TREE_INFORMATION
          String representing information regarding the type of tree.
 
Fields inherited from class edu.princeton.cs.algs4.growingtree.framework.GrowingTreeNode
ANIMATING_BST_TREE_TYPE, BST_TREE_TYPE, DRAWING_BST_TREE_TYPE
 
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
 
Constructor Summary
GrowingTreeHead()
          Constructs a new, null BSTTreeHead, sorted according to the keys' natural order.
GrowingTreeHead(int treeType)
          Constructs a new, empty BSTTree according to the type passed.
GrowingTreeHead(P np, IInsertOperator<P> inserter, ISearchOperator<P> searcher, IDeleteOperator<P> deleter, TreeJPanel<P> panel)
           
GrowingTreeHead(P np, IInsertOperator<P> inserter, ISearchOperator<P> searcher, IDeleteOperator<P> deleter, TreeJPanel<P> panel, IExperimentLogger<P> logger)
           
 
Method Summary
 void addTreeAnimator(Animation a)
          Adds the Animation to the list of Animations for the Head.
 void addTreeMessageListener(TreeMessageListener l)
          Adds an TreeMessageListener from the TREE, according to the TreeMessageListener interface and the TreeMessageEvent.
 void AnimateTree(java.awt.Graphics2D g2)
          Animates the entire BSTTree.
 void animationEventPerformed(AnimationEvent e)
          Implements AnimationListener which requires the following method.
 double averageInsertion(int n)
          Returns the average Insertion time, according to n, the amount of elements in the tree.
 double averageSearchHit(int n)
          Returns the average Search hit time, according to n, the amount of elements in the tree.
 double averageSearchMiss(int n)
          Returns the average Search miss time, according to n, the amount of elements in the tree.
 void balance(Tree<P> node)
          Balances the tree, from the node downward, recursively rotating the median to the top.
 void balanceAnimatingType(GrowingTreeNode<P> node)
          Balances the tree from the given node, recursively rotating the median to the top.
 void balanceTree()
          Balances the entire tree, recursively rotating the median to the top.
 void balanceTreeType(GrowingTreeNode<P> node)
          Balances the tree from the given node, recursively rotating the median to the top.
 void changeDisplay()
          Changes the display of the current tree.
 void changeDisplayAnimatingType()
          Change Display of the BSTTree.
 void changeDisplayTreeType()
          Change Display of the BSTTree.
 void clear()
          Clears the BSTTree completely, removing all references to all nodes and all values return to the default.
 void clearAnimators()
          Clears the Animations from the list of Animations for the Head.
 void constructAnimatingBSTTreeHead()
          Constructor for the ANIMATING_BST_TREE_TYPE.
 void constructBSTTreeHead()
          Constructor for the BST_TREE_TYPE.
 void constructDrawingBSTTreeHead()
          Constructor for the DRAWING_BST_TREE_TYPE.
 void delete(Tree<P> node, boolean successorSwap)
          Removes the given node from the tree.
 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.
 void fixLevel()
          Fixes the lowest level of the Tree, using recursive calls into the BSTTree.
 int fixSize()
          Fixes the size of each subtree, using recursive calls into the BSTTree.
 void freeze(double lengthMult)
           
 void freezeAnimatingType(double lengthMult)
           
 Tree<P> getChild()
          Gets the child of the TreeHead.
 PaintSettings getDeleteLeftLinePaintSettings()
          Gets the Paint for the left line of Paint.
 PaintSettings getDeleteRightLinePaintSettings()
          Gets the Paint for the right line of Paint.
 int getDisplay()
          Gets the display choice for the tree.
 KeySettings getDrawingKeySettings()
          Gets the KeySettings for the entire tree.
 NodeSettings getDrawingNodeSettings()
          Gets the NodeSettings for the entire tree.
 java.util.LinkedList<GrowingTreeNode<P>> getInorderTree()
          Makes a inorder representation of the tree in an array of BSTTrees.
 KeySettings getInsertAnimatorKeySettings()
          Gets the KeySettings for the animator key settings for insertion.
 NodeSettings getInsertAnimatorNodeSettings()
          Gets the NodeSettings for the animator node settings for insertion.
 NodeSettings getInsertNodeLeftSettings()
          Gets the NodeSettings for the left node settings for insertion.
 NodeSettings getInsertNodeRightSettings()
          Gets the NodeSettings for the right node settings for insertion.
 java.util.LinkedList<GrowingTreeNode<P>> getLevelorderTree()
          Makes a levelorder representation of the tree in an array of BSTTrees.
 IExperimentLogger<P> getLogger()
          BST_TREE_TYPE Accessor methods *
 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.util.LinkedList<GrowingTreeNode<P>> getPostorderTree()
          Makes a postorder representation of the tree in an array of BSTTrees.
 java.util.LinkedList<GrowingTreeNode<P>> getPreorderTree()
          Makes a preorder representation of the tree in an array of BSTTrees.
 int getPreviousDisplay()
          Gets the previous display choice for the tree.
 KeySettings getRotateAnimatorKeySettings()
          Gets the KeySettings for the animator key settings for rotation.
 NodeSettings getRotateChildNodeSettings()
          Gets the NodeSettings for the child node settings for rotation.
 NodeSettings getRotateDescendantNodeSettings()
          Gets the NodeSettings for the descendant node settings for rotation.
 KeySettings getRotateOriginalKeySettings()
          Gets the KeySettings for the original key settings for rotation.
 NodeSettings getRotateOriginalNodeSettings()
          Gets the NodeSettings for the original node settings for rotation.
 NodeSettings getRotateRootNodeSettings()
          Gets the NodeSettings for the root node settings for rotation.
 java.awt.geom.Rectangle2D getScreenBounds()
          Gets the bounds of the screen to which the tree is drawing.
 KeySettings getSearchAnimatorKeySettings()
          Gets the KeySettings for the animator key settings for searching.
 NodeSettings getSearchAnimatorNodeSettings()
          Gets the NodeSettings for the animator node settings for searching.
 NodeSettings getSearchNodeLeftSettings()
          Gets the NodeSettings for the left node settings for searching.
 NodeSettings getSearchNodeRightSettings()
          Gets the NodeSettings for the right node settings for searching.
 KeySettings getSelectAnimatorKeySettings()
          Gets the KeySettings for the animator key settings for selection.
 NodeSettings getSelectAnimatorNodeSettings()
          Gets the NodeSettings for the animator node settings for selection.
 NodeSettings getSelectNodeLeftSettings()
          Gets the NodeSettings for the left node settings for selection.
 NodeSettings getSelectNodeRightSettings()
          Gets the NodeSettings for the right node settings for selection.
 boolean getSubtreeCountsVisible()
           
 KeySettings getTraverseAnimatorKeySettings()
          Gets the KeySettings for the animator key settings for traversal.
 NodeSettings getTraverseAnimatorNodeSettings()
          Gets the NodeSettings for the animator node settings for traversal.
 int getTreeAnimationStepSize()
          Gets the step size of the Animations of the tree.
 Animation getTreeAnimator()
          Gets the first Animation in the list of Animations for the Head and null if no Animations are present.
 int getTreeLevel()
          Gets the lowest level of the Tree.
 java.lang.String getTreeStatus()
          Gets the Tree's status, using the String status of Animation.
 java.lang.String getTreeStatusMessage()
          Makes a new tree message.
 boolean insert(KeyType keyInsert, java.lang.Object valueInsert)
          Inserts the comaparable object keyInsert to the tree using its natural ordering .
 void insert(Tree<P> node)
          Inserts the node to the tree using its natural ordering .
 boolean isJumpStep()
          Gets the JumpStep of the current tree.
 boolean isStepPause()
          Gets the StepPause of the current tree.
 boolean isTreeAnimating()
          Returns true if the current AnimatingBSTTreeHead is animating (whether the animating list is empty.
 boolean isTreeEmpty()
          Returns true if the TreeHead is empty, indicating no Child node, and a level of 0.
 boolean isTreeRemove()
          Gets whether the AnimatingBSTTreeHead is removing an Animation.
 Animation makeBalanceAnimation(GrowingTreeNode<P> node)
          Makes a balance Animation using the given node.
 Animation makeChangeDisplayAnimation()
          Makes a changeDisplay Animation.
 Animation makeDeletionAnimation(GrowingTreeNode<P> node)
          Makes a deletion Animation using the given node.
 Animation makeFreezeAnimation(double lengthMult)
           
 Animation makeInsertAnimation(GrowingTreeNode<P> insertNode)
          Makes an insert Animation using the given node.
 Animation makePartitionAnimation(GrowingTreeNode<P> node, int keySelect)
          Makes a partition Animation using the given node and given keySelect.
 Animation makeRotationAnimation(GrowingTreeNode<P> node)
          Makes a rotation Animation using the given node.
 Animation makeRotationDoubleAnimation(GrowingTreeNode<P> node)
          Makes a rotationDouble Animation using the given node.
 Animation makeSearchAnimation(KeyType keySearch)
          Makes a search Animation using the given keySearch.
 Animation makeSelectionAnimation(GrowingTreeNode<P> node, int keySelect)
          Makes a select Animation using the given keySelect.
 Animation makeSwapNodesAnimation(GrowingTreeNode<P> node, int keySelect)
           
 Animation makeTraverseAnimation(java.util.LinkedList<GrowingTreeNode<P>> nodeList)
          Makes a traverse Animation using the given LinkedList.
 void MakeTree(java.awt.Graphics2D g2)
          Makes the entire tree from the null head down.
 int maxKeyWidth()
           
 Tree<P> partition(Tree<P> node, int keySelect)
          Partitions from the given node the keySelect value.
 void pause()
          Sets the status of the AnimatingBSTTree to pause.
 void play()
          Sets the status of the AnimatingBSTTree to play.
 void popTreeProperties()
           
 boolean remove(KeyType keyRemove)
          Removes the comaparable object keyRemove from the BSTTree using its natural ordering .
 void remove(Tree<P> node)
          Removes the given node from the tree.
 void removeTreeAnimation()
          Quickly removes all Animations within the Tree.
 void removeTreeMessageListener(TreeMessageListener l)
          Removes an TreeMessageListener from the TREE, according to the TreeMessageListener interface and the TreeMessageEvent.
 void removeTreeType(GrowingTreeNode<P> node)
          Removes the given node from the tree.
 void resetTreeLevel()
          Resets the lowest level of the Tree.
 void rewind()
          Sets the status of the AnimatingBSTTree to rewind.
 void rotateToTop(GrowingTreeNode<P> node)
          Rotates the BSTTTree to the top.
 void rotateUp(GrowingTreeNode<P> node)
          Rotates the BSTTree up.
 void rotateUp(GrowingTreeNode<P> node, int levelCount)
          Rotates the BSTTree up.
 void rotateUpDouble(GrowingTreeNode<P> node)
          Double Rotatation of the BSTTTree.
 void rotateUpDouble(GrowingTreeNode<P> node, int levelCount)
          Doubly Rotates the BSTTree up to the top.
 void rotateUpDoubleTreeType(GrowingTreeNode<P> node)
          Double Rotates the BSTTree up.
 void rotateUpTreeType(GrowingTreeNode<P> node)
          Rotates the BSTTree up.
 void saveTreeProperties()
          ANIMATING_BST_TREE_TYPE Mutator methods *
 Tree<P> search(KeyType keySearch)
          Searches for the comaparable object in the Tree using its natural ordering .
 Tree<P> searchTreeType(KeyType keySearch)
          Searches for the Tree in the entire tree.
 Tree<P> select(Tree<P> node, int keySelect)
          Selects the kth smallest item in the Tree using its natural ordering from the given node.
 Tree<P> selectTreeType(GrowingTreeNode<P> node, int keySelect)
          Selects for the Tree in the entire tree.
 void setChild(Tree<P> child)
          Sets the child of the TreeHead.
 void setDeleteLeftLinePaintSettings(PaintSettings p)
          Sets the PaintSettings for the left line of Paint.
 void setDeleteRightLinePaintSettings(PaintSettings p)
          Sets the PaintSettings for the right line of Paint.
 void setDisplay(int display)
          Sets the display choice for the tree.
 void setDrawingKeySettings(KeySettings k)
          Sets the KeySettings for the key of the head, used in creation of new nodes.
 void setDrawingNodeSettings(NodeSettings s)
          Sets the NodeSettings for the node of the head, used in creation of new nodes.
 void setInsertAnimatorKeySettings(KeySettings k)
          Sets the KeySettings for the animator key settings for insertion.
 void setInsertAnimatorNodeSettings(NodeSettings n)
          Sets the NodeSettings for the animator node settings for insertion.
 void setInsertNodeLeftSettings(NodeSettings n)
          Sets the NodeSettings for the left node settings for insertion.
 void setInsertNodeRightSettings(NodeSettings n)
          Sets the NodeSettings for the right node settings for insertion.
 void setJumpStep(boolean b)
          Sets the JumpStep of the current tree to the boolean value.
 void setPreviousDisplay(int previousDisplay)
          Sets the previous display choice for the tree.
 void setRotateAnimatorKeySettings(KeySettings k)
          Sets the KeySettings for the animator key settings for rotation.
 void setRotateChildNodeSettings(NodeSettings n)
          Sets the NodeSettings for the child node settings for rotation.
 void setRotateDescendantNodeSettings(NodeSettings n)
          Sets the NodeSettings for the descendant node settings for rotation.
 void setRotateOriginalKeySettings(KeySettings k)
          Sets the KeySettings for the original key settings for rotation.
 void setRotateOriginalNodeSettings(NodeSettings n)
          Sets the NodeSettings for the original node settings for rotation.
 void setRotateRootNodeSettings(NodeSettings n)
          Sets the NodeSettings for the root node settings for rotation.
 void setScreenBounds(java.awt.geom.Rectangle2D screen)
          Sets the bounds of the screen to which the tree is drawing.
 void setSearchAnimatorKeySettings(KeySettings k)
          Sets the KeySettings for the animator key settings for searching.
 void setSearchAnimatorNodeSettings(NodeSettings n)
          Sets the NodeSettings for the animator node settings for searching.
 void setSearchNodeLeftSettings(NodeSettings n)
          Sets the NodeSettings for the left node settings for searching.
 void setSearchNodeRightSettings(NodeSettings n)
          Sets the NodeSettings for the right node settings for searching.
 void setSelectAnimatorKeySettings(KeySettings k)
          Sets the KeySettings for the animator key settings for selection.
 void setSelectAnimatorNodeSettings(NodeSettings n)
          Sets the NodeSettings for the animator node settings for selection.
 void setSelectNodeLeftSettings(NodeSettings n)
          Sets the NodeSettings for the left node settings for selection.
 void setSelectNodeRightSettings(NodeSettings n)
          Sets the NodeSettings for the right node settings for selection.
 void setStepPause(boolean b)
          Sets the StepPause of the current tree to the boolean value.
 void setSubtreeCountsVisible(boolean visible)
          BST_TREE_TYPE Mutator methods *
 void setTraverseAnimatorKeySettings(KeySettings k)
          Sets the KeySettings for the animator key settings for traversal.
 void setTraverseAnimatorNodeSettings(NodeSettings n)
          Sets the NodeSettings for the animator node settings for traversal.
 void setTreeAnimationsStepSize(int t)
          Sets the step size of the Animations of the tree.
 void setTreeSettings(NodeSettings s, KeySettings k)
          Sets the NodeSettings for the entire tree from the head down.
 void setTreeStatus(java.lang.String s)
          Sets the Status of the entire tree, using the status of Animation class.
 void setTreeType(int treeType)
          Sets the tree type for the BSTTree.
 int size()
          Returns the number of objects in the entire tree.
 void splay(GrowingTreeNode<P> node)
          Splays the BSTTTree to the top (Double rotates).
 void stop()
          Sets the status of the AnimatingBSTTree to stop.
 void swapNodes(Tree<P> node, int keySelect)
          Swaps node with the the kth smallest item in its subtree using its natural ordering from the given node.
 void swapTreeType(GrowingTreeNode<P> node, int keySelect)
          Selects for the Tree in the entire tree.
 java.util.LinkedList<GrowingTreeNode<P>> traverse(int traverseType)
          Traverses the tree in the given traversal type.
 java.util.LinkedList<GrowingTreeNode<P>> traverseAnimatingType(int traverseType)
          Traverses the tree in the given traversal type.
 java.util.LinkedList<GrowingTreeNode<P>> traverseTreeType(int traverseType)
          Traverses the tree in the given traversal type.
 void waitingAction(java.lang.String action, ActionElementType<P> element)
          Acts according to the String action passed.
 double worstCaseInsertion(int n)
          Returns the worst case Insertion time, according to n, the amount of elements in the tree.
 double worstCaseSearchHit(int n)
          Returns the worst case Search hit time, according to n, the amount of elements in the tree.
 double worstCaseSearchMiss(int n)
          Returns the worst case Search miss time, according to n, the amount of elements in the tree.
 
Methods inherited from class edu.princeton.cs.algs4.growingtree.framework.GrowingTreeNode
addAnimator, compareTo, constructAnimatingBSTTree, constructBSTTree, constructDrawingBSTTree, delete, drawNode, drawNode, drawNode, drawNodeAndLeftLink, drawNodeAndLink, drawNodeAndLink, drawNodeAndLink, drawNodeAndLink, drawNodeAndLink, drawNodeAndLink, drawNodeAndLink, drawNodeAndRightLink, eraseNodeAndLink, eraseNodeAndLink, getAnimator, getChildren, getCurrentGraphics, getCurrentPower2, getCurrentTransform, getDrawingLevel, getHead, getInorderCount, getKey, getLeftLinkColor, getLeftNodeInternal, getLevel, getMaxKeyWidth, getNodeProperties, getParentTree, getRightLinkColor, getRightNodeInternal, getRoot, getSectionHeight, getSettings, getShadowNode, getTreeType, getTreeTypeString, getValue, insertNode, inTree, isAnimateDrawing, isEmpty, isLeaf, isNodeAnimating, isSettingsSaved, restoreLeftSettings, restoreRightSettings, restoreSettings, restoreTransform, rotateLeftPointers, rotateRightPointers, rotateUp, saveLeftSettings, saveRightSettings, saveSettings, setAnimateDrawing, setCurrentGraphics, setNodeSettings, setSettings
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.princeton.cs.algs4.growingtree.framework.Tree
getChildren, getKey, getLevel, getParentTree, getValue, isEmpty
 

Field Detail

TREE_INFORMATION

public static final java.lang.String TREE_INFORMATION
String representing information regarding the type of tree.

See Also:
Constant Field Values

BINARY_DISPLAY

public static final int BINARY_DISPLAY
Binary Display

See Also:
Constant Field Values

SECTIONAL_DISPLAY

public static final int SECTIONAL_DISPLAY
sectional display

See Also:
Constant Field Values
Constructor Detail

GrowingTreeHead

public GrowingTreeHead()
Constructs a new, null BSTTreeHead, sorted according to the keys' natural order.

Default type is BST_TREE_TYPE.


GrowingTreeHead

public GrowingTreeHead(int treeType)
Constructs a new, empty BSTTree according to the type passed. The options for the types are BST_TREE_TYPE, DRAWING_BST_TREE_TYPE, and ANIMATING_BST_TREE_TYPE. The types are defined as follows:

Parameters:
treeType - type of tree that should be implemented.

GrowingTreeHead

public GrowingTreeHead(P np,
                       IInsertOperator<P> inserter,
                       ISearchOperator<P> searcher,
                       IDeleteOperator<P> deleter,
                       TreeJPanel<P> panel)

GrowingTreeHead

public GrowingTreeHead(P np,
                       IInsertOperator<P> inserter,
                       ISearchOperator<P> searcher,
                       IDeleteOperator<P> deleter,
                       TreeJPanel<P> panel,
                       IExperimentLogger<P> logger)
Method Detail

setTreeType

public void setTreeType(int treeType)
Sets the tree type for the BSTTree. It additionally checks constructors for the head.

Overrides:
setTreeType in class GrowingTreeNode<P extends NodeProperties>
Parameters:
treeType - setting for the tree.

addTreeMessageListener

public void addTreeMessageListener(TreeMessageListener l)
Adds an TreeMessageListener from the TREE, according to the TreeMessageListener interface and the TreeMessageEvent.

Specified by:
addTreeMessageListener in interface TreeHead<P extends NodeProperties>
Parameters:
l - the listener added recieves the TreeMessageEvents occuring.

removeTreeMessageListener

public void removeTreeMessageListener(TreeMessageListener l)
Removes an TreeMessageListener from the TREE, according to the TreeMessageListener interface and the TreeMessageEvent.

Specified by:
removeTreeMessageListener in interface TreeHead<P extends NodeProperties>
Parameters:
l - the listener removed from recieving the TreeMessageEvents occuring.

getTreeStatusMessage

public java.lang.String getTreeStatusMessage()
Makes a new tree message. The method calls messageAction with the information necessary for the tree status. The information presented include :

Specified by:
getTreeStatusMessage in interface AnimatingTreeHead<P extends NodeProperties>

averageSearchHit

public double averageSearchHit(int n)
Returns the average Search hit time, according to n, the amount of elements in the tree.

Parameters:
n - the size of the tree for which the average search hit is needed.
Returns:
double the is the average search hit.

averageSearchMiss

public double averageSearchMiss(int n)
Returns the average Search miss time, according to n, the amount of elements in the tree.

Parameters:
n - the size of the tree for which the average search hit is needed.
Returns:
double the is the average search hit.

worstCaseSearchHit

public double worstCaseSearchHit(int n)
Returns the worst case Search hit time, according to n, the amount of elements in the tree.

Parameters:
n - the size of the tree for which the worst case search hit is needed.
Returns:
double the is the worst case search hit.

worstCaseSearchMiss

public double worstCaseSearchMiss(int n)
Returns the worst case Search miss time, according to n, the amount of elements in the tree.

Parameters:
n - the size of the tree for which the worst case search hit is needed.
Returns:
double the is the worst case search hit.

averageInsertion

public double averageInsertion(int n)
Returns the average Insertion time, according to n, the amount of elements in the tree.

Parameters:
n - the size of the tree for which the average search hit is needed.
Returns:
double the is the average search hit.

worstCaseInsertion

public double worstCaseInsertion(int n)
Returns the worst case Insertion time, according to n, the amount of elements in the tree.

Parameters:
n - the size of the tree for which the worst case search hit is needed.
Returns:
double the is the worst case search hit.

waitingAction

public void waitingAction(java.lang.String action,
                          ActionElementType<P> element)
Acts according to the String action passed. The method generally accompanies a WaitingActionList which keeps the list of actions, and calls the method when instructed to call the next action.

Specified by:
waitingAction in interface TreeHead<P extends NodeProperties>
Parameters:
action - String action representing the next action for the BSTTreeHead.
element - element to which the action could be occuring, depending on the type of action.

constructBSTTreeHead

public void constructBSTTreeHead()
Constructor for the BST_TREE_TYPE. This constructs and sets all values to defaults for the BST_TREE_TYPE.


getLogger

public IExperimentLogger<P> getLogger()
BST_TREE_TYPE Accessor methods *


isTreeEmpty

public boolean isTreeEmpty()
Returns true if the TreeHead is empty, indicating no Child node, and a level of 0.

Specified by:
isTreeEmpty in interface TreeHead<P extends NodeProperties>
Returns:
true if the TreeHead is empty.

getChild

public Tree<P> getChild()
Gets the child of the TreeHead. The child is the beginning of the Tree nodes.

Specified by:
getChild in interface TreeHead<P extends NodeProperties>
Parameters:
child - Tree, beginning the Tree nodes.

getTreeLevel

public int getTreeLevel()
Gets the lowest level of the Tree. A level of 0 indicates an empty tree.

Specified by:
getTreeLevel in interface TreeHead<P extends NodeProperties>
Returns:
integer level set for the Tree.

size

public int size()
Returns the number of objects in the entire tree.

Specified by:
size in interface Tree<P extends NodeProperties>
Specified by:
size in interface TreeHead<P extends NodeProperties>
Overrides:
size in class GrowingTreeNode<P extends NodeProperties>
Returns:
the number of objects in the entire tree.

getSubtreeCountsVisible

public boolean getSubtreeCountsVisible()

setSubtreeCountsVisible

public void setSubtreeCountsVisible(boolean visible)
BST_TREE_TYPE Mutator methods *


setChild

public void setChild(Tree<P> child)
Sets the child of the TreeHead. The child is the beginning of the Tree nodes.

Specified by:
setChild in interface TreeHead<P extends NodeProperties>
Parameters:
child - Tree, beginning the Tree nodes.

resetTreeLevel

public void resetTreeLevel()
Resets the lowest level of the Tree. The level is set to 0, so that is can be recalculated, using fixLevel.

Specified by:
resetTreeLevel in interface TreeHead<P extends NodeProperties>

fixLevel

public void fixLevel()
Fixes the lowest level of the Tree, using recursive calls into the BSTTree. Generally, resetTreeLevel is called before the method.

Specified by:
fixLevel in interface TreeHead<P extends NodeProperties>

fixSize

public int fixSize()
Fixes the size of each subtree, using recursive calls into the BSTTree.

Returns:
integer of the size fixed, which is passed up through the BSTTree, recursively.

clear

public void clear()
Clears the BSTTree completely, removing all references to all nodes and all values return to the default.

Specified by:
clear in interface TreeHead<P extends NodeProperties>

insert

public boolean insert(KeyType keyInsert,
                      java.lang.Object valueInsert)
               throws java.lang.NullPointerException,
                      java.lang.ClassCastException
Inserts the comaparable object keyInsert to the tree using its natural ordering . The value, valueInsert is added with the key to the node.

Specified by:
insert in interface TreeHead<P extends NodeProperties>
Parameters:
keyInsert - comparable object which is added to the tree.
valueInsert - Object that accompanies keyInsert in the node.
Returns:
boolean true if this collection changed as a result of the call.
Throws:
java.lang.ClassCastException - key cannot be compared with the keys currently in the map.
java.lang.NullPointerException - key is null.

insert

public void insert(Tree<P> node)
            throws java.lang.ClassCastException
Inserts the node to the tree using its natural ordering .

Parameters:
node - BSTTree which is added to the tree.
Throws:
java.lang.ClassCastException - key cannot be compared with the keys currently in the map.

delete

public void delete(Tree<P> node,
                   boolean successorSwap)
Removes the given node from the tree. The accompanying value is also removed from the tree and the node is deleted.

Parameters:
node - the Tree node to be removed from the tree.
successorSwap - true if hibbard successor delete, false if predecessor

remove

public void remove(Tree<P> node)
Description copied from interface: TreeHead
Removes the given node from the tree. The accompanying value is also removed from the tree and the node is deleted.

Specified by:
remove in interface TreeHead<P extends NodeProperties>
Parameters:
node - the Tree node to be removed from the tree.

remove

public boolean remove(KeyType keyRemove)
               throws java.lang.ClassCastException,
                      java.lang.NullPointerException
Removes the comaparable object keyRemove from the BSTTree using its natural ordering . If the method is successful in removing the element, true is returned.

Specified by:
remove in interface TreeHead<P extends NodeProperties>
Parameters:
keyRemove - comparable object which is removed from the tree.
Returns:
boolean true if this collection changed as a result of the call.
Throws:
java.lang.ClassCastException - key cannot be compared with the keys currently in the map.
java.lang.NullPointerException - key is null.

balanceTree

public void balanceTree()
Balances the entire tree, recursively rotating the median to the top.

Specified by:
balanceTree in interface TreeHead<P extends NodeProperties>

balance

public void balance(Tree<P> node)
Balances the tree, from the node downward, recursively rotating the median to the top.

Specified by:
balance in interface TreeHead<P extends NodeProperties>
Parameters:
node - the node from which the balance occurs

partition

public Tree<P> partition(Tree<P> node,
                         int keySelect)
Partitions from the given node the keySelect value. Replacing the reference in the Tree to the given node, to the keySelectth item.

Specified by:
partition in interface TreeHead<P extends NodeProperties>
Parameters:
Tree - which the partition occurs at.
keySelect - integer key selecting the count item.
Returns:
Tree that is the reference to the newly partitioned tree.

search

public Tree<P> search(KeyType keySearch)
                                      throws java.lang.ClassCastException,
                                             java.lang.NullPointerException
Searches for the comaparable object in the Tree using its natural ordering . If the method is successful in finding the element, the item is returned. Otherwise, the closest item is returned.

Specified by:
search in interface TreeHead<P extends NodeProperties>
Parameters:
keySearch - comparable object which is search for within the tree.
Returns:
Tree element which matches the keySearch or the nearest node or null if the search is impossible to perform.
Throws:
java.lang.ClassCastException - key cannot be compared with the keys currently in the map.
java.lang.NullPointerException - key is null.

select

public Tree<P> select(Tree<P> node,
                      int keySelect)
Selects the kth smallest item in the Tree using its natural ordering from the given node. If the method is successful in finding the element, the item is returned. Otherwise, null is returned if the integer is greater than the size.

Specified by:
select in interface TreeHead<P extends NodeProperties>
Parameters:
Tree - which the partition occurs at.
keySelect - integer key selecting the count item.
Returns:
Tree element which matches the kth element or null if k > size.

swapNodes

public void swapNodes(Tree<P> node,
                      int keySelect)
Swaps node with the the kth smallest item in its subtree using its natural ordering from the given node. If the method is successful in finding the element, the item is returned. Otherwise, null is returned if the integer is greater than the size.

Parameters:
Tree - which the partition occurs at.
keySelect - integer key selecting the count item.

freeze

public void freeze(double lengthMult)

freezeAnimatingType

public void freezeAnimatingType(double lengthMult)

maxKeyWidth

public int maxKeyWidth()

rotateUp

public void rotateUp(GrowingTreeNode<P> node)
Rotates the BSTTree up. It simply changes around references, including the parent reference and the ancestor reference. The rotation upwards replaces the parent with the node and brings the parent down a level.

Parameters:
node - BSTTree that rotated upwards.

rotateUp

public void rotateUp(GrowingTreeNode<P> node,
                     int levelCount)
Rotates the BSTTree up. It simply changes around references, including the parent reference and the ancestor reference. The rotation upwards replaces the parent with the node and brings the parent down a level.

Parameters:
node - BSTTree that rotated upwards.
levelCount - the amount of levels up the node should rotate

rotateUpDouble

public void rotateUpDouble(GrowingTreeNode<P> node)
Double Rotatation of the BSTTTree.

Parameters:
node - BSTTree that is double rotated (bottom rotation first).

rotateUpDouble

public void rotateUpDouble(GrowingTreeNode<P> node,
                           int levelCount)
Doubly Rotates the BSTTree up to the top. This is also referred to as a Splay and is the basis for a splay tree if the double rotation occurs to the top.

Parameters:
node - BSTTree that rotated upwards.
levelCount - the amount of levels up the node should rotate

rotateToTop

public void rotateToTop(GrowingTreeNode<P> node)
Rotates the BSTTTree to the top.

Parameters:
node - BSTTree that is rotated to the top.

splay

public void splay(GrowingTreeNode<P> node)
Splays the BSTTTree to the top (Double rotates).

Parameters:
node - BSTTree that is rotated to the top.

changeDisplay

public void changeDisplay()
Changes the display of the current tree.


traverse

public java.util.LinkedList<GrowingTreeNode<P>> traverse(int traverseType)
Traverses the tree in the given traversal type.

Parameters:
traverseType - int defining the given traversal type.

removeTreeType

public void removeTreeType(GrowingTreeNode<P> node)
Removes the given node from the tree. The accompanying value is also removed from the tree and the node is deleted.

Parameters:
node - the Tree node to be removed from the tree.

balanceTreeType

public void balanceTreeType(GrowingTreeNode<P> node)
Balances the tree from the given node, recursively rotating the median to the top.

Parameters:
node - BSTTree that is balanced from.

searchTreeType

public Tree<P> searchTreeType(KeyType keySearch)
                                              throws java.lang.ClassCastException
Searches for the Tree in the entire tree.

Parameters:
keySearch - the comparable key which is searched for within the tree.
Returns:
Tree the Tree found or null if keySearch was not present within the tree.
Throws:
java.lang.ClassCastException - key cannot be compared with the keys currently in the map.

selectTreeType

public Tree<P> selectTreeType(GrowingTreeNode<P> node,
                              int keySelect)
                                              throws java.lang.ClassCastException
Selects for the Tree in the entire tree.

Parameters:
node - the node from which the selection takes place.
keySelect - integer key selecting the count item.
Returns:
Tree the Tree found or null.
Throws:
java.lang.ClassCastException - key cannot be compared with the keys currently in the map.

swapTreeType

public void swapTreeType(GrowingTreeNode<P> node,
                         int keySelect)
                  throws java.lang.ClassCastException
Selects for the Tree in the entire tree.

Parameters:
node - the node from which the selection takes place.
keySelect - integer key selecting the count item.
Throws:
java.lang.ClassCastException - key cannot be compared with the keys currently in the map.

rotateUpTreeType

public void rotateUpTreeType(GrowingTreeNode<P> node)
Rotates the BSTTree up. It simply changes around references, including the parent reference and the ancestor reference. The rotation upwards replaces the parent with the node and brings the parent down a level.

Parameters:
node - BSTTree that rotated upwards.

rotateUpDoubleTreeType

public void rotateUpDoubleTreeType(GrowingTreeNode<P> node)
Double Rotates the BSTTree up.

Parameters:
node - BSTTree that rotated upwards.

traverseTreeType

public java.util.LinkedList<GrowingTreeNode<P>> traverseTreeType(int traverseType)
Traverses the tree in the given traversal type.

Parameters:
traverseType - int defining the given traversal type.

changeDisplayTreeType

public void changeDisplayTreeType()
Change Display of the BSTTree.


getPreorderTree

public java.util.LinkedList<GrowingTreeNode<P>> getPreorderTree()
Makes a preorder representation of the tree in an array of BSTTrees. Changes in the references in the array have no effect upon the tree.

Returns:
LinkedList of BSTTree objects that are the preorder representation of the tree.

getInorderTree

public java.util.LinkedList<GrowingTreeNode<P>> getInorderTree()
Makes a inorder representation of the tree in an array of BSTTrees. Changes in the references in the array have no effect upon the tree.

Returns:
LinkedList of BSTTree objects that are the preorder representation of the tree.

getPostorderTree

public java.util.LinkedList<GrowingTreeNode<P>> getPostorderTree()
Makes a postorder representation of the tree in an array of BSTTrees. Changes in the references in the array have no effect upon the tree.

Returns:
LinkedList of BSTTree objects that are the preorder representation of the tree.

getLevelorderTree

public java.util.LinkedList<GrowingTreeNode<P>> getLevelorderTree()
Makes a levelorder representation of the tree in an array of BSTTrees. Changes in the references in the array have no effect upon the tree.

Returns:
Array of BSTTree objects that are the preorder representation of the tree.

constructDrawingBSTTreeHead

public void constructDrawingBSTTreeHead()
Constructor for the DRAWING_BST_TREE_TYPE. This constructs and sets all values to defaults for the DRAWING_BST_TREE_TYPE.


getDisplay

public int getDisplay()
Gets the display choice for the tree.

Returns:
the integer that defines the display choice of the tree.

getPreviousDisplay

public int getPreviousDisplay()
Gets the previous display choice for the tree.

Returns:
the integer that defines the display choice of the tree.

getDrawingNodeSettings

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

Specified by:
getDrawingNodeSettings in interface DrawingTreeHead<P extends NodeProperties>
Returns:
NodeSettings for defined for the entire tree.

getDrawingKeySettings

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

Specified by:
getDrawingKeySettings in interface DrawingTreeHead<P extends NodeProperties>
Returns:
KeySettings for defined for the entire tree.

getNodeWidth

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

Specified by:
getNodeWidth in interface DrawingTreeHead<P extends NodeProperties>
Returns:
width of the standard node.

getNodeHeight

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

Specified by:
getNodeHeight in interface DrawingTreeHead<P extends NodeProperties>
Returns:
height of the standard node.

getScreenBounds

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

Specified by:
getScreenBounds in interface DrawingTree<P extends NodeProperties>
Specified by:
getScreenBounds in interface DrawingTreeHead<P extends NodeProperties>
Overrides:
getScreenBounds in class GrowingTreeNode<P extends NodeProperties>
Returns:
the rectangle representing the bounds of the screen.

getInsertNodeLeftSettings

public NodeSettings getInsertNodeLeftSettings()
Gets the NodeSettings for the left node settings for insertion.

Returns:
NodeSettings for the left node.

getInsertNodeRightSettings

public NodeSettings getInsertNodeRightSettings()
Gets the NodeSettings for the right node settings for insertion.

Returns:
NodeSettings for the right node.

getInsertAnimatorNodeSettings

public NodeSettings getInsertAnimatorNodeSettings()
Gets the NodeSettings for the animator node settings for insertion.

Returns:
NodeSettings for the animator node.

getInsertAnimatorKeySettings

public KeySettings getInsertAnimatorKeySettings()
Gets the KeySettings for the animator key settings for insertion.

Returns:
KeySettings for the animator key.

getSearchNodeLeftSettings

public NodeSettings getSearchNodeLeftSettings()
Gets the NodeSettings for the left node settings for searching.

Returns:
NodeSettings for the left node.

getSearchNodeRightSettings

public NodeSettings getSearchNodeRightSettings()
Gets the NodeSettings for the right node settings for searching.

Returns:
NodeSettings for the right node.

getSearchAnimatorNodeSettings

public NodeSettings getSearchAnimatorNodeSettings()
Gets the NodeSettings for the animator node settings for searching.

Returns:
NodeSettings for the animator node.

getSearchAnimatorKeySettings

public KeySettings getSearchAnimatorKeySettings()
Gets the KeySettings for the animator key settings for searching.

Returns:
KeySettings for the animator key.

getSelectNodeLeftSettings

public NodeSettings getSelectNodeLeftSettings()
Gets the NodeSettings for the left node settings for selection.

Returns:
NodeSettings for the left node.

getSelectNodeRightSettings

public NodeSettings getSelectNodeRightSettings()
Gets the NodeSettings for the right node settings for selection.

Returns:
NodeSettings for the right node.

getSelectAnimatorNodeSettings

public NodeSettings getSelectAnimatorNodeSettings()
Gets the NodeSettings for the animator node settings for selection.

Returns:
NodeSettings for the animator node.

getSelectAnimatorKeySettings

public KeySettings getSelectAnimatorKeySettings()
Gets the KeySettings for the animator key settings for selection.

Returns:
KeySettings for the animator key.

getRotateRootNodeSettings

public NodeSettings getRotateRootNodeSettings()
Gets the NodeSettings for the root node settings for rotation.

Returns:
NodeSettings for the root node.

getRotateChildNodeSettings

public NodeSettings getRotateChildNodeSettings()
Gets the NodeSettings for the child node settings for rotation.

Returns:
NodeSettings for the child node.

getRotateDescendantNodeSettings

public NodeSettings getRotateDescendantNodeSettings()
Gets the NodeSettings for the descendant node settings for rotation.

Returns:
NodeSettings for the descendant node.

getRotateOriginalNodeSettings

public NodeSettings getRotateOriginalNodeSettings()
Gets the NodeSettings for the original node settings for rotation.

Returns:
NodeSettings for the original node.

getRotateAnimatorKeySettings

public KeySettings getRotateAnimatorKeySettings()
Gets the KeySettings for the animator key settings for rotation.

Returns:
KeySettings for the animator key.

getRotateOriginalKeySettings

public KeySettings getRotateOriginalKeySettings()
Gets the KeySettings for the original key settings for rotation.

Returns:
KeySettings for the original key.

getDeleteLeftLinePaintSettings

public PaintSettings getDeleteLeftLinePaintSettings()
Gets the Paint for the left line of Paint.

Returns:
Paint for the left line.

getDeleteRightLinePaintSettings

public PaintSettings getDeleteRightLinePaintSettings()
Gets the Paint for the right line of Paint. `

Returns:
Paint for the right line.

getTraverseAnimatorNodeSettings

public NodeSettings getTraverseAnimatorNodeSettings()
Gets the NodeSettings for the animator node settings for traversal.

Returns:
NodeSettings for the animator node.

getTraverseAnimatorKeySettings

public KeySettings getTraverseAnimatorKeySettings()
Gets the KeySettings for the animator key settings for traversal.

Returns:
KeySettings for the animator key.

setDisplay

public void setDisplay(int display)
Sets the display choice for the tree.

Parameters:
display - sets the integer that defines the display choice of the tree.

setPreviousDisplay

public void setPreviousDisplay(int previousDisplay)
Sets the previous display choice for the tree.

Parameters:
display - sets the integer that defines the display choice of the tree.

setTreeSettings

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

Specified by:
setTreeSettings in interface DrawingTreeHead<P extends NodeProperties>
Parameters:
s - NodeSettings for use in drawing the entire tree.
k - KeySettings for use in drawing the keys of the entire tree.

setDrawingNodeSettings

public void setDrawingNodeSettings(NodeSettings s)
Sets the NodeSettings for the node of the head, used in creation of new nodes.

Parameters:
s - NodeSettings for use in drawing the nodes.

setDrawingKeySettings

public void setDrawingKeySettings(KeySettings k)
Sets the KeySettings for the key of the head, used in creation of new nodes.

Parameters:
k - KeySettings for use in drawing the keys.

setScreenBounds

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

Specified by:
setScreenBounds in interface DrawingTree<P extends NodeProperties>
Specified by:
setScreenBounds in interface DrawingTreeHead<P extends NodeProperties>
Overrides:
setScreenBounds in class GrowingTreeNode<P extends NodeProperties>
Parameters:
bounds - the rectangle representing the bounds of the screen.

setInsertNodeLeftSettings

public void setInsertNodeLeftSettings(NodeSettings n)
Sets the NodeSettings for the left node settings for insertion.


setInsertNodeRightSettings

public void setInsertNodeRightSettings(NodeSettings n)
Sets the NodeSettings for the right node settings for insertion.


setInsertAnimatorNodeSettings

public void setInsertAnimatorNodeSettings(NodeSettings n)
Sets the NodeSettings for the animator node settings for insertion.


setInsertAnimatorKeySettings

public void setInsertAnimatorKeySettings(KeySettings k)
Sets the KeySettings for the animator key settings for insertion.


setSearchNodeLeftSettings

public void setSearchNodeLeftSettings(NodeSettings n)
Sets the NodeSettings for the left node settings for searching.


setSearchNodeRightSettings

public void setSearchNodeRightSettings(NodeSettings n)
Sets the NodeSettings for the right node settings for searching.


setSearchAnimatorNodeSettings

public void setSearchAnimatorNodeSettings(NodeSettings n)
Sets the NodeSettings for the animator node settings for searching.


setSearchAnimatorKeySettings

public void setSearchAnimatorKeySettings(KeySettings k)
Sets the KeySettings for the animator key settings for searching.


setSelectNodeLeftSettings

public void setSelectNodeLeftSettings(NodeSettings n)
Sets the NodeSettings for the left node settings for selection.


setSelectNodeRightSettings

public void setSelectNodeRightSettings(NodeSettings n)
Sets the NodeSettings for the right node settings for selection.


setSelectAnimatorNodeSettings

public void setSelectAnimatorNodeSettings(NodeSettings n)
Sets the NodeSettings for the animator node settings for selection.


setSelectAnimatorKeySettings

public void setSelectAnimatorKeySettings(KeySettings k)
Sets the KeySettings for the animator key settings for selection.


setRotateRootNodeSettings

public void setRotateRootNodeSettings(NodeSettings n)
Sets the NodeSettings for the root node settings for rotation.


setRotateChildNodeSettings

public void setRotateChildNodeSettings(NodeSettings n)
Sets the NodeSettings for the child node settings for rotation.


setRotateDescendantNodeSettings

public void setRotateDescendantNodeSettings(NodeSettings n)
Sets the NodeSettings for the descendant node settings for rotation.


setRotateOriginalNodeSettings

public void setRotateOriginalNodeSettings(NodeSettings n)
Sets the NodeSettings for the original node settings for rotation.


setRotateAnimatorKeySettings

public void setRotateAnimatorKeySettings(KeySettings k)
Sets the KeySettings for the animator key settings for rotation.


setRotateOriginalKeySettings

public void setRotateOriginalKeySettings(KeySettings k)
Sets the KeySettings for the original key settings for rotation.


setDeleteLeftLinePaintSettings

public void setDeleteLeftLinePaintSettings(PaintSettings p)
Sets the PaintSettings for the left line of Paint.


setDeleteRightLinePaintSettings

public void setDeleteRightLinePaintSettings(PaintSettings p)
Sets the PaintSettings for the right line of Paint.


setTraverseAnimatorNodeSettings

public void setTraverseAnimatorNodeSettings(NodeSettings n)
Sets the NodeSettings for the animator node settings for traversal.


setTraverseAnimatorKeySettings

public void setTraverseAnimatorKeySettings(KeySettings k)
Sets the KeySettings for the animator key settings for traversal.


MakeTree

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

Specified by:
MakeTree in interface DrawingTreeHead<P extends NodeProperties>
Parameters:
g2 - Graphics2D which the tree is made to fit unto.

DrawTree

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

Specified by:
DrawTree in interface DrawingTreeHead<P extends NodeProperties>
Parameters:
g2 - Graphics2D which the tree is drawn onto.

findNode

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

Specified by:
findNode in interface DrawingTreeHead<P extends NodeProperties>
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.

constructAnimatingBSTTreeHead

public void constructAnimatingBSTTreeHead()
Constructor for the ANIMATING_BST_TREE_TYPE. This constructs and sets all values to defaults for the ANIMATING_BST_TREE_TYPE.


isTreeRemove

public boolean isTreeRemove()
Gets whether the AnimatingBSTTreeHead is removing an Animation.

Returns:
boolean value as to whether the tree is removing an Animation.

getTreeAnimator

public Animation getTreeAnimator()
Gets the first Animation in the list of Animations for the Head and null if no Animations are present.

Specified by:
getTreeAnimator in interface AnimatingTreeHead<P extends NodeProperties>
Returns:
first Animation in the Animation list.

isTreeAnimating

public boolean isTreeAnimating()
Returns true if the current AnimatingBSTTreeHead is animating (whether the animating list is empty.

Specified by:
isTreeAnimating in interface AnimatingTreeHead<P extends NodeProperties>
Returns:
true if the current tree is animating and not empty.

isJumpStep

public boolean isJumpStep()
Gets the JumpStep of the current tree.

Specified by:
isJumpStep in interface AnimatingTreeHead<P extends NodeProperties>
Returns:
true if the tree is jumpSteping.

isStepPause

public boolean isStepPause()
Gets the StepPause of the current tree.

Specified by:
isStepPause in interface AnimatingTreeHead<P extends NodeProperties>
Returns:
true if the tree is pausing at the completion of each step.

getTreeAnimationStepSize

public int getTreeAnimationStepSize()
Gets the step size of the Animations of the tree.

Specified by:
getTreeAnimationStepSize in interface AnimatingTreeHead<P extends NodeProperties>
Returns:
integer step size of the tree.

getTreeStatus

public java.lang.String getTreeStatus()
Gets the Tree's status, using the String status of Animation.

Specified by:
getTreeStatus in interface AnimatingTreeHead<P extends NodeProperties>
Returns:
String status of the Tree, representing the Animation status.

saveTreeProperties

public void saveTreeProperties()
ANIMATING_BST_TREE_TYPE Mutator methods *


popTreeProperties

public void popTreeProperties()

clearAnimators

public void clearAnimators()
Clears the Animations from the list of Animations for the Head.


addTreeAnimator

public void addTreeAnimator(Animation a)
Adds the Animation to the list of Animations for the Head. The method does not add the tree as a listener to the Animation. That must be accomplished by the client.

Specified by:
addTreeAnimator in interface AnimatingTreeHead<P extends NodeProperties>
Parameters:
a - Animation added to the Animation list.

removeTreeAnimation

public void removeTreeAnimation()
Quickly removes all Animations within the Tree. The method sets the Status of all the Animations to Animation.FINISH so that all listeners of the Animations will receive the AnimationEvent.

Specified by:
removeTreeAnimation in interface AnimatingTreeHead<P extends NodeProperties>

setJumpStep

public void setJumpStep(boolean b)
Sets the JumpStep of the current tree to the boolean value. The jumpStep determines whether the Animation skips through an entire step at each AnimateTree call.

Specified by:
setJumpStep in interface AnimatingTreeHead<P extends NodeProperties>
Parameters:
b - sets the jumpStep to the value b.

setStepPause

public void setStepPause(boolean b)
Sets the StepPause of the current tree to the boolean value. The stepPause determines whether the Animation pauses after each step of the Animation completes.

Specified by:
setStepPause in interface AnimatingTreeHead<P extends NodeProperties>
Parameters:
b - sets the stepPause to the value b.

setTreeAnimationsStepSize

public void setTreeAnimationsStepSize(int t)
Sets the step size of the Animations of the tree. The integer value is passed to every Animation's setStepTime method.

Specified by:
setTreeAnimationsStepSize in interface AnimatingTreeHead<P extends NodeProperties>
Parameters:
t - integer step size setting.

setTreeStatus

public void setTreeStatus(java.lang.String s)
Sets the Status of the entire tree, using the status of Animation class.

Specified by:
setTreeStatus in interface AnimatingTreeHead<P extends NodeProperties>
Parameters:
s - String status to set the Tree's Status.

balanceAnimatingType

public void balanceAnimatingType(GrowingTreeNode<P> node)
Balances the tree from the given node, recursively rotating the median to the top. The method is overiden to allow for animation of the balancing, simply calling balanceTREE if no waiting action appears.

Parameters:
node - BSTTree that is balanced from.

traverseAnimatingType

public java.util.LinkedList<GrowingTreeNode<P>> traverseAnimatingType(int traverseType)
Traverses the tree in the given traversal type.

Parameters:
traverseType - int defining the given traversal type.

changeDisplayAnimatingType

public void changeDisplayAnimatingType()
Change Display of the BSTTree.


makeInsertAnimation

public Animation makeInsertAnimation(GrowingTreeNode<P> insertNode)
Makes an insert Animation using the given node. The Animation adds no listeners, making the client have to add the listeners.

Parameters:
insertNode - BSTTree node that the insert Animation is built for.
Returns:
Animation that represents the insertAnimation.

makeSearchAnimation

public Animation makeSearchAnimation(KeyType keySearch)
Makes a search Animation using the given keySearch. The Animation adds no listeners, making the client have to add the listeners.

Parameters:
keySearch - the comparable object which is search for within the tree.

makeSelectionAnimation

public Animation makeSelectionAnimation(GrowingTreeNode<P> node,
                                        int keySelect)
Makes a select Animation using the given keySelect. The Animation adds no listeners, making the client have to add the listeners.

Parameters:
keySelect - the int which is selected for within the tree.

makeSwapNodesAnimation

public Animation makeSwapNodesAnimation(GrowingTreeNode<P> node,
                                        int keySelect)

makeFreezeAnimation

public Animation makeFreezeAnimation(double lengthMult)

makeRotationAnimation

public Animation makeRotationAnimation(GrowingTreeNode<P> node)
Makes a rotation Animation using the given node. The Animation adds no listeners, making the client have to add the listeners.

Parameters:
node - BSTTree node that the rotation Animation is built from.
Returns:
Animation that represents the rotationAnimation.

makeDeletionAnimation

public Animation makeDeletionAnimation(GrowingTreeNode<P> node)
Makes a deletion Animation using the given node. The Animation adds no listeners, making the client have to add the listeners.

Parameters:
node - BSTTree node that the deletion Animation is built from.
Returns:
Animation that represents the deleteAnimation.

makePartitionAnimation

public Animation makePartitionAnimation(GrowingTreeNode<P> node,
                                        int keySelect)
Makes a partition Animation using the given node and given keySelect. The Animation adds no listeners, making the client have to add the listeners.

Parameters:
node - BSTTree node that the deletion Animation is built from.
keySelect - finds the keySelectth node and rotates it to the top.
Returns:
Animation that represents the deleteAnimation.

makeBalanceAnimation

public Animation makeBalanceAnimation(GrowingTreeNode<P> node)
Makes a balance Animation using the given node. The Animation adds no listeners, making the client have to add the listeners.

Parameters:
node - BSTTree node that the balance Animation is built from.
Returns:
Animation that represents the balanceAnimation.

makeRotationDoubleAnimation

public Animation makeRotationDoubleAnimation(GrowingTreeNode<P> node)
Makes a rotationDouble Animation using the given node. The Animation adds no listeners, making the client have to add the listeners.

Parameters:
node - BSTTree node that the doubleRotation Animation is built from.
Returns:
Animation that represents the balanceAnimation.

makeTraverseAnimation

public Animation makeTraverseAnimation(java.util.LinkedList<GrowingTreeNode<P>> nodeList)
Makes a traverse Animation using the given LinkedList. The Animation adds no listeners, making the client have to add the listeners.

Parameters:
nodeList - the LinkedList containing the nodes that are the path of the traversal.

makeChangeDisplayAnimation

public Animation makeChangeDisplayAnimation()
Makes a changeDisplay Animation. The Animation adds no listeners, making the client have to add the listeners.


AnimateTree

public void AnimateTree(java.awt.Graphics2D g2)
Animates the entire BSTTree. The animation is drawn to the Graphics2D passed. This method is called repeatedly and for each Animation within the list, the drawAnimation method is called. Within this method, checks for removing a Animation are made, as are checks for Waiting Actions.

Specified by:
AnimateTree in interface AnimatingTreeHead<P extends NodeProperties>
Parameters:
g2 - Graphics2D to which the Animations are drawn.

play

public void play()
Sets the status of the AnimatingBSTTree to play.

Specified by:
play in interface AnimatingTreeHead<P extends NodeProperties>

stop

public void stop()
Sets the status of the AnimatingBSTTree to stop.

Specified by:
stop in interface AnimatingTreeHead<P extends NodeProperties>

rewind

public void rewind()
Sets the status of the AnimatingBSTTree to rewind.

Specified by:
rewind in interface AnimatingTreeHead<P extends NodeProperties>

pause

public void pause()
Sets the status of the AnimatingBSTTree to pause.

Specified by:
pause in interface AnimatingTreeHead<P extends NodeProperties>

animationEventPerformed

public void animationEventPerformed(AnimationEvent e)
Implements AnimationListener which requires the following method. The only status of animation it listens for is Animation.FINISH, to remove the animation from the animators list and Animation.STEP, to possible pause the animation if stepPause is true.

Specified by:
animationEventPerformed in interface AnimationListener
Overrides:
animationEventPerformed in class GrowingTreeNode<P extends NodeProperties>
Parameters:
e - AnimationEvent that represents the information of the Animation.