|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--BSTTree
The class provides the base structure of a BSTTree
, a node of the Binary Search Tree.
It uses the elements natural ordering. It uses everything defined within the AbstractTree
The BSTTree cannot be the head of the tree, it is only the nodes. It defines recursive methods which aren't defined in the head node and it does not define the methods for the head node.
A Binary Search Tree is a binary tree that has a key associated with each of its internal nodes, with the additional property that the key in any node is larger than (or eqaul to) that keys in all nodes in that node's left subtree and smaller than (or equal to) the keys in all nodes in the node's right subtree. (Sedgewick, 502, Algorithms in C)
Note that this implementation is not synchronized. If multiple threads access this tree concurrently, and at least one of the threads modifies the tree structurally, it must be synchronized externally.
Field Summary | |
static int |
ANIMATING_BST_TREE_TYPE
Tree type defining AnimatingBSTTree. |
static int |
BST_TREE_TYPE
Tree type defining only a BSTTree. |
static int |
DRAWING_BST_TREE_TYPE
Tree type defining a DrawingBSTTree. |
Constructor Summary | |
BSTTree()
Constructs a new, empty BSTTree, sorted according to the keys' natural order. |
|
BSTTree(int treeType)
Constructs a new, empty BSTTree according to the type passed. |
Method Summary | |
void |
addAnimator(Animation a)
Adds an animation to the current node. |
void |
animationEventPerformed(AnimationEvent e)
Implements AnimationListener which requires the following method. |
void |
constructAnimatingBSTTree()
Constructor for the ANIMATING_BST_TREE_TYPE. |
void |
constructBSTTree()
Constructor for the BST_TREE_TYPE. |
void |
constructDrawingBSTTree()
Constructor for the DRAWING_BST_TREE_TYPE. |
protected void |
copyBSTTree(BSTTree copy)
Copies the fields of this BSTTree into the BSTTree copy. |
protected void |
drawLeftLink(java.awt.Graphics2D g2,
double sectionHeight,
java.awt.geom.AffineTransform a,
double drawingLevel,
double powerLevel,
boolean bottomLinks)
Draws just the left link according to the NodeSettings currently set. |
void |
drawNode()
Draws the node of the tree using the previously defined graphics. |
void |
drawNode(java.awt.Graphics2D g2)
Draws the node of the tree to the given Graphics2D. |
void |
drawNode(java.awt.Graphics2D g2,
java.awt.geom.AffineTransform a)
Draws the node of the tree to the given Graphics2D, using the AffineTransform . |
void |
drawNodeAndLeftLink()
Draws the node and left link of the tree using the previously defined graphics. |
void |
drawNodeAndLink()
Draws the node and link of the tree using the previously defined graphics.. |
void |
drawNodeAndLink(java.awt.Graphics2D g2)
Draws the node and link of the tree to the given Graphics2D. |
void |
drawNodeAndLink(java.awt.Graphics2D g2,
java.awt.geom.AffineTransform a)
Draws the node and link of the tree to the given Graphics2D. |
void |
drawNodeAndLink(java.awt.Graphics2D g2,
java.awt.geom.AffineTransform a,
boolean bottomLinks)
Draws the node and link of the tree to the given Graphics2D. |
void |
drawNodeAndLink(java.awt.Graphics2D g2,
boolean bottomLinks)
Draws the node and link of the tree to the given Graphics2D. |
void |
drawNodeAndLink(java.awt.Graphics2D g2,
double sectionHeight,
java.awt.geom.AffineTransform a,
double drawingLevel,
double powerLevel)
Draws the node and link of the tree to the given Graphics2D. |
void |
drawNodeAndLink(java.awt.Graphics2D g2,
double sectionHeight,
java.awt.geom.AffineTransform a,
double drawingLevel,
double powerLevel,
boolean bottomLinks)
Draws the node and link of the tree to the given Graphics2D. |
void |
drawNodeAndRightLink()
Draws the node and right link of the tree using the previously defined graphics. |
protected void |
drawRightLink(java.awt.Graphics2D g2,
double sectionHeight,
java.awt.geom.AffineTransform a,
double drawingLevel,
double powerLevel,
boolean bottomLinks)
Draws just the right link according to the NodeSettings currently set. |
protected void |
drawTree(java.awt.Graphics2D g2)
Draws the tree recursively, on to the Graphics2D. |
void |
eraseNodeAndLink()
Erases the previous drawing of the nodeAndLinkm, simply drawing. |
protected DrawingTree |
findNode(double x,
double y)
Finds the node represented by the x-y coordinates given. |
protected void |
fixLevel(int currentLevel)
Fixes the level of the node. |
protected int |
fixSize()
Fixes the size of the node. |
protected void |
fixTreeType(int treeType)
Fixes the tree type for the entire BSTTree. |
Animation |
getAnimator()
Gets the first Animation of the node. |
Tree[] |
getChildren()
Returns the children of the current Tree . |
java.awt.Graphics2D |
getCurrentGraphics()
Gets the graphics previously defined within the tree. |
double |
getCurrentPower2()
Gets the current power of 2 to which the tree was last drawn. |
protected java.awt.Shape |
getCurrentShape()
Gets the shape of the node previously drawn or transformed. |
java.awt.geom.AffineTransform |
getCurrentTransform()
Gets the AffineTransform defined within the tree. |
double |
getDrawingLevel()
Gets the drawing level for the current DrawingTree . |
BSTTreeHead |
getHead()
Gets the head for the node. |
int |
getInorderCount()
Returns the inorder count of the current node. |
java.lang.Comparable |
getKey()
Returns the key of the current BSTTree . |
protected java.awt.Shape |
getKeyOriginRectangle()
Gets the shape of the key within the node shape at the origin and size 1, for usage in transforming and drawing. |
BSTTree |
getLeftTree()
Returns the left BSTTree of the current tree. |
int |
getLevel()
Gets the the level of the current BSTTree . |
protected java.awt.Shape |
getNodeOriginShape()
Gets the shape of the node at the origin and size 1, for usage in transforming and drawing. |
Tree |
getParentTree()
Returns the parent of the current tree. |
protected java.awt.geom.AffineTransform |
getPreviousTransform()
Gets the AffineTransform previously defined within the tree. |
BSTTree |
getRightTree()
Returns the right BSTTree of the current tree. |
java.awt.geom.Rectangle2D |
getScreenBounds()
Gets the bounds of the screen to which the tree is drawing. |
double |
getSectionHeight()
Gets the height of the section for the DrawingTree . |
NodeSettings |
getSettings()
Gets the NodeSettings of the tree. |
int |
getTreeType()
Gets the tree type for the BSTTree. |
java.lang.String |
getTreeTypeString()
Gets the tree type String for the BSTTree. |
java.lang.Object |
getValue()
Returns the value of the current BSTTree . |
protected void |
insert(BSTTree newTree,
int currentLevel)
Inserts the given object into the tree, using recursive calls and is called from the Head node. |
boolean |
inTree()
Determines if the current node is within a BSTTree. |
boolean |
isAnimateDrawing()
Gets the boolean flag whether the node should draw if called from an animation. |
protected boolean |
isAnimatingBSTTree()
Returns true if the BSTTree is of type AnimatingBSTTree. |
protected boolean |
isDrawingBSTTree()
Returns true if the BSTTree is of type DrawingBSTTree or higher type. |
boolean |
isEmpty()
Returns true if the current BSTTree is empty. |
boolean |
isNodeAnimating()
Returns true if the node is animating. |
boolean |
isSettingsSaved()
Returns true if the settings are currently saved for the DrawingTree. |
protected static BSTTree |
join(BSTTree treeJoinOne,
BSTTree treeJoinTwo)
Joins two subtrees together as one tree. |
protected void |
makeInorderTree(java.util.LinkedList treeList)
Makes an array in inorder using recursive calls and the count. |
protected void |
makeInsertAnimation(BSTTree insertNode,
InsertBSTAnimation newAnimator)
Insert the BSTTree down from the current node. |
protected void |
makePostorderTree(java.util.LinkedList treeList)
Makes an array in postorder using recursive calls and the count. |
protected void |
makePreorderTree(java.util.LinkedList treeList)
Makes an array in preorder using recursive calls and the count. |
protected void |
makeSearchAnimation(java.lang.Comparable keySearch,
SearchBSTAnimation newAnimator)
Constructs the searchBSTAnimation down from the current node. |
protected void |
makeSelectionAnimation(int elementCount,
SelectionBSTAnimation newAnimator)
Constructs the partitionBSTAnimation down from the current node. |
protected void |
makeTree(java.awt.geom.AffineTransform a,
int currentLevel)
Makes the tree recursively using the two parameters. |
protected BSTTree |
partition(int keySelect,
int levelCount)
Partitions the Tree at the given keySelect and rotates the keySelectth node
to this node's position. |
protected void |
remove()
Removes the BSTTree from the tree. |
void |
restoreLeftSettings()
Restores the settings for the tree, decrementing the count of left Saves and total saves by one. |
void |
restoreRightSettings()
Restores the settings for the tree, decrementing the count of right Saves and total saves by one. |
void |
restoreSettings()
Restores the settings for the tree, decrementing the count of saves by one. |
void |
restoreTransform()
Restores the AffineTransform defined previously within the tree. |
protected BSTTree |
rotateLeft()
Rotate the tree to the left. |
protected BSTTree |
rotateRight()
Rotate the tree to the right. |
void |
saveLeftSettings()
Saves the settings for the tree, incrementing the count of left Saves and total saves by one and setting the previous settings accordingly. |
void |
saveRightSettings()
Saves the settings for the tree, incrementing the count of right Saves and total saves by one and setting the previous settings accordingly. |
void |
saveSettings()
Saves the settings for the tree, incrementing the count of saves by one and setting the previous settings accordingly. |
protected Tree |
search(java.lang.Comparable keyFind)
Finds a node within a tree using the comparable keyFind. |
protected Tree |
select(int keySelect)
Selects for the Tree in the entire tree. |
void |
setAnimateDrawing(boolean animateDrawing)
Sets the boolean flag whether the node should draw if called from an animation. |
void |
setCurrentGraphics(java.awt.Graphics2D g2)
Sets the graphics defined within the tree. |
protected void |
setCurrentPower2(double p2)
Sets the current power of 2. |
protected void |
setCurrentTransform(java.awt.geom.AffineTransform a)
Sets the AffineTransform defined within the tree. |
protected void |
setDrawingLevel(double level)
Sets the drawing level for the current DrawingTree . |
protected void |
setHead(BSTTreeHead head)
Sets the head for the node. |
protected void |
setInorderCount(int inorder_count)
Sets the inorder count of the current node. |
protected void |
setLeaf()
Sets the values of a new Node left and right tress, to refer to null trees. |
protected void |
setLeftTree(BSTTree left)
Sets the left tree for the node. |
protected void |
setLevel(int level)
Sets the the level of the current BSTTree . |
protected void |
setNode(java.lang.Comparable keyInsert,
java.lang.Object valueInsert)
Sets the key and value of the BSTTree . |
void |
setNodeSettings(NodeSettings s)
Sets the settings of the node for the BSTTree . |
protected void |
setParentTree(BSTTree parent)
Sets the parent tree for the node. |
protected void |
setRightTree(BSTTree right)
Sets the right tree for the node. |
void |
setScreenBounds(java.awt.geom.Rectangle2D bounds)
Sets the bounds of the screen to which the tree is drawing. |
void |
setSettings(NodeSettings s)
Sets the NodeSettings of the DrawingTree . |
protected void |
setSize(int size)
Sets the the size of the current BSTTree . |
protected void |
setTreeSettings(NodeSettings s,
KeySettings k)
Sets the settings of the entire tree. |
void |
setTreeType(int treeType)
Sets the tree type for the BSTTree. |
int |
size()
Returns the number of nodes in the current Tree and below. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int BST_TREE_TYPE
public static final int DRAWING_BST_TREE_TYPE
public static final int ANIMATING_BST_TREE_TYPE
Constructor Detail |
public BSTTree()
Default type is BST_TREE_TYPE.
public BSTTree(int treeType)
treeType
- type of tree that should be implemented.Method Detail |
public void setTreeType(int treeType)
treeType
- setting for the tree.public int getTreeType()
protected void fixTreeType(int treeType)
treeType
- setting for the tree.public java.lang.String getTreeTypeString()
protected boolean isDrawingBSTTree()
protected boolean isAnimatingBSTTree()
protected void copyBSTTree(BSTTree copy)
BSTTree
into the BSTTree
copy.
It simply copies it field by field, for usage when changes are made to the head node.If the tree type is Drawing or Animating, the method copies the fields accordingly.
copy
- the BSTTree
that takes the fields of the BSTTree
.public void constructBSTTree()
public BSTTreeHead getHead()
public int size()
size
in interface Tree
public boolean isEmpty()
BSTTree
is empty.
isEmpty
in interface Tree
BSTTree
is empty.public java.lang.Object getValue()
BSTTree
.
getValue
in interface Tree
BSTTree
.public java.lang.Comparable getKey()
BSTTree
.
getKey
in interface Tree
BSTTree
.public int getLevel()
BSTTree
.
The level is the integer count of how far down the tree is to the current node.
getLevel
in interface Tree
BSTTree
.public int getInorderCount()
public BSTTree getLeftTree()
BSTTree
of the current tree. Used to traverse down
the binary tree.
BSTTree
that is the left subtree of the current BSTTree
,
null of no such tree exists.public BSTTree getRightTree()
BSTTree
of the current tree. Used to traverse down
the binary tree.
BSTTree
that is the right subtree of the current BSTTree
,
null of no such tree exists.public Tree[] getChildren()
Tree
.
getChildren
in interface Tree
Tree
array that is the children and null if the tree is an exterior node.public Tree getParentTree()
getParentTree
in interface Tree
public boolean inTree()
protected void setHead(BSTTreeHead head)
getLevel
).
head
- TreeHead for the current node.protected void setLeftTree(BSTTree left)
left
- BSTTree that sets the left link for the current node.protected void setRightTree(BSTTree right)
right
- BSTTree that sets the right link for the current node.protected void setParentTree(BSTTree parent)
parent
- BSTTree that sets the parent link for the current node.protected void setLevel(int level)
BSTTree
.
The level sets the integer count of how far down the tree is.
level
- the level set for the node.protected void setSize(int size)
BSTTree
.
The size represents the nodes below and including the current node.
size
- integer setting the size of the node, which is the count of the nodes below
and including the current node.protected void setInorderCount(int inorder_count)
protected void setNode(java.lang.Comparable keyInsert, java.lang.Object valueInsert)
BSTTree
. This is prtoected for usage by
extended classes but not for public access.
keyInsert
- comparable object to be inserted as the key of the BSTTree
.valueInsert
- object to be inserted as the value of the BSTTree
.protected void fixLevel(int currentLevel)
currentLevel
- currentLevel of the BSTTree
protected int fixSize()
protected void setLeaf()
protected void insert(BSTTree newTree, int currentLevel) throws java.lang.ClassCastException
newTree
- the tree to be inserted, with key and value already set.currentLevel
- keeps track of the recursive call, and sets the new level if it changes.
java.lang.ClassCastException
- key cannot be compared with the keys
currently in the tree.protected void remove()
BSTTree
by
partitioning the right subTree and replacing itself with the smallest of the right tree.
protected Tree search(java.lang.Comparable keyFind) throws java.lang.ClassCastException
keyFind
- the key which the method is attempting to find.
java.lang.ClassCastException
protected Tree select(int keySelect)
Tree
in the entire tree.
keySelect
- integer key selecting the count item.
Tree
found or null.protected BSTTree partition(int keySelect, int levelCount)
Tree
at the given keySelect and rotates the keySelectth node
to this node's position. A recursive call generally called from the head
keySelect
- integer key selecting the count item.levelCount
- integer counting the levels down the partition is going.
protected BSTTree rotateRight()
protected BSTTree rotateLeft()
protected static BSTTree join(BSTTree treeJoinOne, BSTTree treeJoinTwo)
treeJoinOne
- one subtree to be joined.treeJoinTwo
- second subtree to be joined.
protected void makePreorderTree(java.util.LinkedList treeList)
protected void makeInorderTree(java.util.LinkedList treeList)
protected void makePostorderTree(java.util.LinkedList treeList)
public void constructDrawingBSTTree()
public double getDrawingLevel()
DrawingTree
. This is a necessary method for allowing
intermidiary drawing between two levels, because the param is a double, not an integer.
getDrawingLevel
in interface DrawingTree
public double getSectionHeight()
DrawingTree
. The section height is generally
used to determine link length and node height when drawing the tree.
getSectionHeight
in interface DrawingTree
public java.awt.geom.Rectangle2D getScreenBounds()
getScreenBounds
in interface DrawingTree
public double getCurrentPower2()
public NodeSettings getSettings()
NodeSettings
of the tree.
These settings are used for drawing the node and the links of the given tree.
getSettings
in interface DrawingTree
NodeSettings
for use in drawing the tree.public boolean isSettingsSaved()
NodeSettings
are saved.protected java.awt.Shape getNodeOriginShape()
Shape
of the node at the origin and size 1.protected java.awt.Shape getKeyOriginRectangle()
Shape
of the key.protected java.awt.Shape getCurrentShape()
Shape
of the node previously drawn.public java.awt.geom.AffineTransform getCurrentTransform()
AffineTransform
defined within the tree. The current transform
is used when calling draw
without the AffineTransform
value.
getCurrentTransform
in interface DrawingTree
protected java.awt.geom.AffineTransform getPreviousTransform()
AffineTransform
previously defined within the tree. The previous transform
is used when calling restoreTransform
and is automatically
updates with each call of setCurrentTransform
.
public java.awt.Graphics2D getCurrentGraphics()
makeTree
or by the client using setCurrentGraphics
.
protected void setDrawingLevel(double level)
DrawingTree
. This is a necessary method for allowing
intermidiary drawing between two levels, because the param is a double, not an integer.
level
- the double level for the drawing node.public void setScreenBounds(java.awt.geom.Rectangle2D bounds)
getClipBounds
on the Graphics2D passed, however, the bounds
can be set in any way.
setScreenBounds
in interface DrawingTree
bounds
- the rectangle representing the bounds of the screen.public void setCurrentGraphics(java.awt.Graphics2D g2)
g2
- Graphics2D which are the defined graphics for the tree.protected void setCurrentPower2(double p2)
protected void setTreeSettings(NodeSettings s, KeySettings k)
s
- NodeSettings being set for the entire tree.public void setNodeSettings(NodeSettings s)
BSTTree
. No settings are saved
and the previous settings are not modified.
s
- NodeSettings
set for the entire tree.public void setSettings(NodeSettings s)
NodeSettings
of the DrawingTree
.
These settings are used for drawing the node and the links of the given tree.
If the settings are saved, the previous settings are modified to the NodeSettings
,
leaving the current settings unmodified. To modify the current settings, use setNodeSettings
.
If the settings are not saved, the previous settings are made null and the currentSettings are set.
setSettings
in interface DrawingTree
s
- NodeSettings
for use in drawing the tree.protected void setCurrentTransform(java.awt.geom.AffineTransform a)
AffineTransform
defined within the tree. The set transform
is used when calling draw
without the AffineTransform
value.
a
- transform set for the current drawing of the tree.public void restoreTransform()
AffineTransform
defined previously within the tree.
The previous transform is always the last transform defined and is automatically
updated each time setCurrentTransform
is called.
public void saveSettings()
public void saveLeftSettings()
public void saveRightSettings()
public void restoreLeftSettings()
public void restoreRightSettings()
public void restoreSettings()
protected void makeTree(java.awt.geom.AffineTransform a, int currentLevel)
setCurrentTransform
setLevel
setDrawingLevel
setCurrentPower2
setScreenBounds
(using head bounds)
The method calls the method for the left and right children, using properly modified
AffineTransform
and level.
a
- AffineTransform
for the current tree.currentLevel
- the current level for the tree.protected void drawTree(java.awt.Graphics2D g2)
g2
- the Graphics2D to which the tree is drawn.public void drawNode()
AffineTransform
.
drawNode
in interface DrawingTree
public void drawNode(java.awt.Graphics2D g2)
AffineTransform
.
drawNode
in interface DrawingTree
g2
- graphics to which the node is drawn.public void drawNode(java.awt.Graphics2D g2, java.awt.geom.AffineTransform a)
AffineTransform
.
The drawing uses the AffineTransform
to determine the exact way to draw the
node.
drawNode
in interface DrawingTree
g2
- graphics to which the node is drawn.a
- transform to draw the node.public void drawNodeAndLeftLink()
AffineTransform
,
section height, drawing level, and power level.
public void drawNodeAndRightLink()
AffineTransform
,
section height, drawing level, and power level.
public void eraseNodeAndLink()
public void drawNodeAndLink()
AffineTransform
,
section height, drawing level, and power level.
drawNodeAndLink
in interface DrawingTree
public void drawNodeAndLink(java.awt.Graphics2D g2)
AffineTransform
,
section height, drawing level, and power level.
drawNodeAndLink
in interface DrawingTree
g2
- graphics to which the node is drawn.public void drawNodeAndLink(java.awt.Graphics2D g2, boolean bottomLinks)
AffineTransform
,
section height, drawing level, and power level.
g2
- graphics to which the node is drawn.bottomLinks
- the boolean to declare whether the bottom links should be drawn.public void drawNodeAndLink(java.awt.Graphics2D g2, java.awt.geom.AffineTransform a)
g2
- graphics to which the node and links are drawn.a
- transfrom to draw the node and links.public void drawNodeAndLink(java.awt.Graphics2D g2, java.awt.geom.AffineTransform a, boolean bottomLinks)
g2
- graphics to which the node and links are drawn.a
- transfrom to draw the node and links.bottomLinks
- the boolean to declare whether the bottom links should be drawn.public void drawNodeAndLink(java.awt.Graphics2D g2, double sectionHeight, java.awt.geom.AffineTransform a, double drawingLevel, double powerLevel)
AffineTransform
, section height,
drawing level, and power level to render the node and its links.
drawNodeAndLink
in interface DrawingTree
g2
- graphics to which the node and links are drawn.sectionHeight
- the height of the tree' section, to draw the correct lengths for the links.a
- transfrom to draw the node and links.drawingLevel
- the level in the tree to which the node is currently being drawn.powerLevel
- the power to which the links extend, depending on how many links are present.public void drawNodeAndLink(java.awt.Graphics2D g2, double sectionHeight, java.awt.geom.AffineTransform a, double drawingLevel, double powerLevel, boolean bottomLinks)
AffineTransform
, section height,
drawing level, and power level to render the node and its links.
g2
- graphics to which the node and links are drawn.sectionHeight
- the height of the tree' section, to draw the correct lengths for the links.a
- transfrom to draw the node and links.drawingLevel
- the level in the tree to which the node is currently being drawn.powerLevel
- the power to which the links extend, depending on how many links are present.bottomLinks
- the boolean to declare whether the bottom links should be drawn.protected void drawRightLink(java.awt.Graphics2D g2, double sectionHeight, java.awt.geom.AffineTransform a, double drawingLevel, double powerLevel, boolean bottomLinks)
g2
- graphics to which the node and links are drawn.sectionHeight
- the height of the tree' section, to draw the correct lengths for the links.a
- transfrom to draw the node and links.drawingLevel
- the level in the tree to which the node is currently being drawn.powerLevel
- the power to which the links extend, depending on how many links are present.bottomLinks
- the boolean to declare whether the bottom links should be drawn.protected void drawLeftLink(java.awt.Graphics2D g2, double sectionHeight, java.awt.geom.AffineTransform a, double drawingLevel, double powerLevel, boolean bottomLinks)
g2
- graphics to which the node and links are drawn.sectionHeight
- the height of the tree' section, to draw the correct lengths for the links.a
- transfrom to draw the node and links.drawingLevel
- the level in the tree to which the node is currently being drawn.powerLevel
- the power to which the links extend, depending on how many links are present.bottomLinks
- the boolean to declare whether the bottom links should be drawn.protected DrawingTree findNode(double x, double y)
x
- x-coordinate to find the node.y
- y-coordinate to find the node.
public void constructAnimatingBSTTree()
public boolean isNodeAnimating()
isNodeAnimating
in interface AnimatingTree
public Animation getAnimator()
Animation
of the node.
getAnimator
in interface AnimatingTree
public void setAnimateDrawing(boolean animateDrawing)
animateDrawing
- boolean flag to draw if animating.public void addAnimator(Animation a)
addAnimator
in interface AnimatingTree
a
- the Animation
being added to the node.public boolean isAnimateDrawing()
protected void makeInsertAnimation(BSTTree insertNode, InsertBSTAnimation newAnimator) throws java.lang.ClassCastException
BSTTree
down from the current node. This is a recursive call,
defined in BSTTree
. It is overiden in this class to build the animation
of the insertion. The reason this animation is overiden and not simply added in the AnimatingBSTTreeHead,
is to allow multiple insertions to occur at once. Therefore, insertion never goes through
WaitingActionList
.
newAnimator
- the InsertBSTAnimation to which the nodes are being added.
java.lang.ClassCastException
- key cannot be compared with the keys
currently in the tree.protected void makeSearchAnimation(java.lang.Comparable keySearch, SearchBSTAnimation newAnimator) throws java.lang.ClassCastException
searchBSTAnimation
down from the current node.
This is a recursive call through the tree. No Listeners are affected by this call.
keySearch
- the key being searched for.newAnimator
- the SerachBSTAnimation to which the nodes are being added.
java.lang.ClassCastException
- key cannot be compared with the keys
currently in the tree.protected void makeSelectionAnimation(int elementCount, SelectionBSTAnimation newAnimator) throws java.lang.ClassCastException
partitionBSTAnimation
down from the current node.
This is a recursive call through the tree. No Listeners are affected by this call.
elementCount
- the integer (kth small element) searching for that partitionnewAnimator
- the PartitionBSTAnimation to which the nodes are being added.
java.lang.ClassCastException
- key cannot be compared with the keys
currently in the tree.public void animationEventPerformed(AnimationEvent e)
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.
animationEventPerformed
in interface AnimationListener
e
- AnimationEvent that represents the information of the Animation.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |