Class TreeJPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--DrawingJPanel
                                |
                                +--TreeJPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.awt.event.ComponentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, OptionListener, java.io.Serializable, TreeMessageListener
Direct Known Subclasses:
BSTTreeJPanel

public class TreeJPanel
extends DrawingJPanel
implements OptionListener, java.awt.event.ActionListener, TreeMessageListener

This class provides the panel for a Tree. It keeps the graphics for drawing the tree and the image for redrawing. It also keeps a timer for the animation and all changes to the tree proceed through the panel. This is a class that is extended for each specific tree.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String BACKGROUND
          String representing DRAWING color scheme.
static java.lang.String CHARACTER
          String representing character types.
static int DEFAULT_DELAY
          The default delay for animation (90).
static java.lang.String DELETE
          String representing DELETE color scheme.
static java.lang.String DOUBLE
          String representing double types.
static java.lang.String DRAWING
          String representing DRAWING color scheme.
static java.lang.String INSERT
          String representing INSERT color scheme.
static java.lang.String INTEGER
          String representing integer types.
static java.lang.String KEY
          String representing Key color scheme.
static java.lang.String KEY_ANIMATOR_SETTINGS
          String representing key animator color scheme.
static java.lang.String KEY_ORIGINAL_SETTINGS
          String representing key original color scheme.
static java.lang.String LEFT_PAINT
          String representing the left paint.
static java.lang.String NODE
          String representing Node color scheme.
static java.lang.String NODE_ANIMATOR_SETTINGS
          String representing node animator color scheme.
static java.lang.String NODE_CHILD_SETTINGS
          String representing node child color scheme.
static java.lang.String NODE_DESCENDANT_SETTINGS
          String representing node descendant color scheme.
static java.lang.String NODE_LEFT_SETTINGS
          String representing node left color scheme.
static java.lang.String NODE_ORIGINAL_SETTINGS
          String representing node original color scheme.
static java.lang.String NODE_RIGHT_SETTINGS
          String representing node right color scheme.
static java.lang.String NODE_ROOT_SETTINGS
          String representing node root color scheme.
static java.lang.String NOKEY
          command passed for no key errors.
static java.lang.String PAINT
          String representing Paint color scheme.
static java.lang.String RIGHT_PAINT
          String representing the right paint.
static java.lang.String ROTATE
          String representing ROTATE color scheme.
static java.lang.String SEARCH
          String representing SEARCH color scheme.
static java.lang.String SELECT
          String representing SELECT color scheme.
static java.lang.String TRAVERSE
          String representing TRAVERSE color scheme.
static java.lang.String TYPEERR
          command passed for type errors.
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TreeJPanel()
          Sole constructor which sets all of the default values for the Panel.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          Listens to action events.
 void addTreeMessageListener(TreeMessageListener l)
          Adds an TreeMessageListener from the TREE, according to the TreeMessageListener interface and the TreeMessageEvent.
 void animatingCommand(boolean animatingCommand)
          Animation command.
 void animationQualityCommand(int quality)
          Animation quality command.
 void animationSpeedCommand(int speed)
          Animation speed command.
 void balanceCommand(Tree node)
          Balance command.
protected  void clear()
          Clears the tree.
 void clearAllCommand()
          Clear all command.
 void clearCommand()
          Clear command.
protected  int clearTree()
          Clears the tree.
 void constructColorOptions(ColorOptionsJPanel allTreeToolsPanel)
          Constructs the color settings for this tree, using the given parameter.
 void constructPresetColorOptions(ColorOptionsJPanel colorOptionsPanel)
          Constructs the color settings combo box and sets the box for the given colorOptionsPanel.
 void deleteCommand(java.lang.String text)
          Delete command.
 void deleteCommand(Tree node)
          Insert command.
protected  void deleteKeys(java.lang.String text)
          Deletes the given text from the tree.
protected  void deleteNode(Tree node)
          Deletes the given node from the tree.
protected  void draw()
          Method actually called to complete the drawing of the panel.
protected  javax.swing.Timer getAnimationTimer()
          Gets the animation timer for the animation of the panel.
 void getInputOptions()
          Gets the input options for the current tree.
 java.lang.String getKeyType()
          Gets the key type for the tree.
protected  java.util.LinkedList getObjectList(java.lang.String text)
          Gets a List of objects made from the String text.
protected  java.util.LinkedList getStringList(java.lang.String text)
          Processes a given text String into a LinkedList of Strings.
 java.lang.String getTitle()
          Gets the title for the tree.
 AnimatingTreeHead getTree()
          Gets the head of the tree currently drawn in the Panel.
 java.lang.String getTreeStatusMessage()
          Get the tree message.
protected  void inputChange(java.lang.String text)
          Changes the input according to the text string.
 void inputChangeCommand(java.lang.String input)
          Input Change Command.
 void insertCommand(java.lang.String text)
          Insert command.
protected  void insertKeys(java.lang.String text)
          Inserts the given text as keys into the tree.
 boolean isAnimating()
          Gets whether the tree is animating or not.
 boolean isStep()
          Gets whether the tree is stepping or not.
 void makeColorSchemeOptions()
          Passes a message to make the color scheme options for the current Panel.
 void makeColorSettings()
          Passes a message to make the color settings options for the current Panel.
 javax.swing.JPopupMenu makeJPopupMenu(java.awt.event.ActionListener actionListener)
          Constructs a popupmenu, using the actionlistener passed.
protected  void makeMissingErrorMessage(java.lang.String error)
          Constructs a error missing message based upon the current type and the String passed in.
protected  void makeTypeErrorMessage(java.lang.String error)
          Constructs a error type message based upon the current type and the String passed in.
protected  void makeTypeIntegerErrorMessage(java.lang.String error)
          Constructs a error type message based upon the current type and the String passed in.
protected  void messageAction(java.lang.String msg, java.lang.Object msgObj)
          Calls all of the treeListeners of the Tree and passes the tree message information information regarding the status of the Tree.
 void optionEventPerformed(OptionEvent e)
          Recieved an event from an OptionJPanel with one of the given commands.
 void paintComponent(java.awt.Graphics g)
          Overides paintComponenet and is called whenever the Panel needs to be painted.
 void partitionCommand(Tree node)
          Partition command.
protected  void partitionNode(Tree node)
          Partitions the given node.
 void pauseCommand()
          Pause command.
 void playCommand()
          Play command.
 void playFastCommand()
          Play command.
 void playStepCommand()
          Play command.
 void removeTreeMessageListener(TreeMessageListener l)
          Removes an TreeMessageListener from the TREE, according to the TreeMessageListener interface and the TreeMessageEvent.
 void rewindCommand()
          Play command.
 void rewindFastCommand()
          Play command.
 void rewindStepCommand()
          Play command.
 void rotateToTopCommand(Tree node)
          RotateToTop command.
 void rotateUpCommand(Tree node)
          RotateUp command.
 void rotateUpDoubleCommand(Tree node)
          RotateUpDouble command.
 void saveTreeCommand(TreeJPanel panel)
           
 void searchCommand(java.lang.String text)
          Search command.
protected  void searchKeys(java.lang.String text)
          Searches the given text for keys in the tree.
 void selectCommand(java.lang.String text)
          Select command.
 void selectCommand(Tree node)
          Select command.
protected  void selectKeys(java.lang.String text)
          Selects the given text for keys in the tree.
protected  void selectNode(Tree node)
          Selects the given node.
 void setAnimating(boolean animating)
          Sets whether the tree is animating or not.
protected  void setAnimationTimer(javax.swing.Timer animationTimer)
          Sets the animation timer for the animation of the panel.
 void setDelayRate(int t)
          Sets the delay rate for the timer for the animation.
protected  void setKeyType(java.lang.String keyType)
          Sets the key type for the tree.
 void setSettings(TreeJPanel panel)
          Sets the settings for the panel param.
 void setStep(boolean step)
          Sets whether the tree is stepping or not.
 void setTree(AnimatingTreeHead tree)
          Sets the head of the tree currently drawn in the Panel.
 void splayCommand(Tree node)
          Splay command.
 void stopCommand()
          Stop command.
protected  java.lang.Object stringToType(java.lang.String text)
          Given a String, converts the string into the specific type set currently for the tree.
 void traverseCommand(int traverseType)
          Traverse command.
 void treeMessageEventPerformed(TreeMessageEvent e)
          Listens to tree message events.
 
Methods inherited from class DrawingJPanel
componentHidden, componentMoved, componentResized, componentShown, drawTree, getDrawingArea, getDrawTreeGraphics, getDrawTreeImage, isComponentShown, isDrawTree, makeDrawTreeGraphics, makeDrawTreeImage, setComponentShown, setDrawingArea, setDrawTree, setDrawTreeGraphics, setDrawTreeImage
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPEERR

public static final java.lang.String TYPEERR
command passed for type errors.

See Also:
Constant Field Values

NOKEY

public static final java.lang.String NOKEY
command passed for no key errors.

See Also:
Constant Field Values

INTEGER

public static final java.lang.String INTEGER
String representing integer types.

See Also:
Constant Field Values

CHARACTER

public static final java.lang.String CHARACTER
String representing character types.

See Also:
Constant Field Values

DOUBLE

public static final java.lang.String DOUBLE
String representing double types.

See Also:
Constant Field Values

DRAWING

public static final java.lang.String DRAWING
String representing DRAWING color scheme.

See Also:
Constant Field Values

BACKGROUND

public static final java.lang.String BACKGROUND
String representing DRAWING color scheme.

See Also:
Constant Field Values

INSERT

public static final java.lang.String INSERT
String representing INSERT color scheme.

See Also:
Constant Field Values

SEARCH

public static final java.lang.String SEARCH
String representing SEARCH color scheme.

See Also:
Constant Field Values

SELECT

public static final java.lang.String SELECT
String representing SELECT color scheme.

See Also:
Constant Field Values

ROTATE

public static final java.lang.String ROTATE
String representing ROTATE color scheme.

See Also:
Constant Field Values

DELETE

public static final java.lang.String DELETE
String representing DELETE color scheme.

See Also:
Constant Field Values

TRAVERSE

public static final java.lang.String TRAVERSE
String representing TRAVERSE color scheme.

See Also:
Constant Field Values

NODE

public static final java.lang.String NODE
String representing Node color scheme.

See Also:
Constant Field Values

KEY

public static final java.lang.String KEY
String representing Key color scheme.

See Also:
Constant Field Values

PAINT

public static final java.lang.String PAINT
String representing Paint color scheme.

See Also:
Constant Field Values

NODE_LEFT_SETTINGS

public static final java.lang.String NODE_LEFT_SETTINGS
String representing node left color scheme.

See Also:
Constant Field Values

NODE_RIGHT_SETTINGS

public static final java.lang.String NODE_RIGHT_SETTINGS
String representing node right color scheme.

See Also:
Constant Field Values

NODE_ANIMATOR_SETTINGS

public static final java.lang.String NODE_ANIMATOR_SETTINGS
String representing node animator color scheme.

See Also:
Constant Field Values

KEY_ANIMATOR_SETTINGS

public static final java.lang.String KEY_ANIMATOR_SETTINGS
String representing key animator color scheme.

See Also:
Constant Field Values

KEY_ORIGINAL_SETTINGS

public static final java.lang.String KEY_ORIGINAL_SETTINGS
String representing key original color scheme.

See Also:
Constant Field Values

NODE_ROOT_SETTINGS

public static final java.lang.String NODE_ROOT_SETTINGS
String representing node root color scheme.

See Also:
Constant Field Values

NODE_CHILD_SETTINGS

public static final java.lang.String NODE_CHILD_SETTINGS
String representing node child color scheme.

See Also:
Constant Field Values

NODE_DESCENDANT_SETTINGS

public static final java.lang.String NODE_DESCENDANT_SETTINGS
String representing node descendant color scheme.

See Also:
Constant Field Values

NODE_ORIGINAL_SETTINGS

public static final java.lang.String NODE_ORIGINAL_SETTINGS
String representing node original color scheme.

See Also:
Constant Field Values

LEFT_PAINT

public static final java.lang.String LEFT_PAINT
String representing the left paint.

See Also:
Constant Field Values

RIGHT_PAINT

public static final java.lang.String RIGHT_PAINT
String representing the right paint.

See Also:
Constant Field Values

DEFAULT_DELAY

public static final int DEFAULT_DELAY
The default delay for animation (90).

See Also:
Constant Field Values
Constructor Detail

TreeJPanel

public TreeJPanel()
Sole constructor which sets all of the default values for the Panel. Calls the super constructor of JPanel. Also, it adds itself to listen to component events.

Method Detail

setTree

public void setTree(AnimatingTreeHead tree)
Sets the head of the tree currently drawn in the Panel.

Parameters:
tree - AnimatingTreeHead head.

setDelayRate

public void setDelayRate(int t)
Sets the delay rate for the timer for the animation. param t int delay rate.


setAnimating

public void setAnimating(boolean animating)
Sets whether the tree is animating or not.

Parameters:
animating - boolean flag as to whether the tree is animating.

setStep

public void setStep(boolean step)
Sets whether the tree is stepping or not.

Parameters:
step - boolean flag as to whether the tree is stepping.

setAnimationTimer

protected void setAnimationTimer(javax.swing.Timer animationTimer)
Sets the animation timer for the animation of the panel.

Parameters:
animationTimer - javax.swing.Timer defining the steps of animation.

setKeyType

protected void setKeyType(java.lang.String keyType)
Sets the key type for the tree.

Parameters:
keyType - String defining the type of key in the tree.

stringToType

protected java.lang.Object stringToType(java.lang.String text)
Given a String, converts the string into the specific type set currently for the tree. A NumberFormatException is caught and an error message String is returned instead of an object.

Parameters:
text - String to be converted into an object.
Returns:
the object after converting to the type of the tree, or a String error message.

getTitle

public java.lang.String getTitle()
Gets the title for the tree.

Returns:
String defining the title of the tree.

getTreeStatusMessage

public java.lang.String getTreeStatusMessage()
Get the tree message. The method calls TreeStatusMessage of the tree within the panel.


getTree

public AnimatingTreeHead getTree()
Gets the head of the tree currently drawn in the Panel.

Returns:
TreeHead the tree head.

isAnimating

public boolean isAnimating()
Gets whether the tree is animating or not.


isStep

public boolean isStep()
Gets whether the tree is stepping or not.


getKeyType

public java.lang.String getKeyType()
Gets the key type for the tree.

Returns:
String defining the type of key in the tree.

getAnimationTimer

protected javax.swing.Timer getAnimationTimer()
Gets the animation timer for the animation of the panel.

Returns:
javax.swing.Timer defining the steps of animation.

getInputOptions

public void getInputOptions()
Gets the input options for the current tree.

Returns:
String array of the options for the current tree.

getObjectList

protected java.util.LinkedList getObjectList(java.lang.String text)
Gets a List of objects made from the String text. The method first gets a List of Strings using getStringList. Then the method uses stringToType repeatedly, constructing a LinkedList of objects. Any incorrect strings, the error message is automatically made and sent in the form of a Dialog.

Parameters:
text - String to be made into an Object list.
Returns:
LinkedList List of objects.

getStringList

protected java.util.LinkedList getStringList(java.lang.String text)
Processes a given text String into a LinkedList of Strings. This allows for multiple inserts deletes and so forth.

Parameters:
text - the String to be parsed into Strings.
Returns:
LinkedList of Strings, parsed from the text passed.

draw

protected void draw()
Method actually called to complete the drawing of the panel. The node is drawn to fill the entire graphics given within the panel.

Overrides:
draw in class DrawingJPanel

paintComponent

public void paintComponent(java.awt.Graphics g)
Overides paintComponenet and is called whenever the Panel needs to be painted. The painting includes painting the image and then painting the animation (if any).

Overrides:
paintComponent in class DrawingJPanel
Parameters:
g - Graphics to which the component is drawn.

makeTypeErrorMessage

protected void makeTypeErrorMessage(java.lang.String error)
Constructs a error type message based upon the current type and the String passed in.


makeTypeIntegerErrorMessage

protected void makeTypeIntegerErrorMessage(java.lang.String error)
Constructs a error type message based upon the current type and the String passed in.


makeMissingErrorMessage

protected void makeMissingErrorMessage(java.lang.String error)
Constructs a error missing message based upon the current type and the String passed in.


insertKeys

protected void insertKeys(java.lang.String text)
Inserts the given text as keys into the tree. The method uses the protected method getObjectList to produce objects. Then, those objects are inserted with a newly made DrawingKey.

Parameters:
text - String to be inserted into the tree.

searchKeys

protected void searchKeys(java.lang.String text)
Searches the given text for keys in the tree. The method uses the protected method getObjectList to produce objects. Then, those objects are searched for.

Parameters:
text - String to be searched into the tree.

selectKeys

protected void selectKeys(java.lang.String text)
Selects the given text for keys in the tree. The method uses the protected method getObjectList to produce objects. Then, those objects are selected.

Parameters:
text - String to be selected into the tree.

deleteKeys

protected void deleteKeys(java.lang.String text)
Deletes the given text from the tree. The method uses the protected method getObjectList to produce objects. Then, those objects are deleted.

Parameters:
text - String to be deleted into the tree.

deleteNode

protected void deleteNode(Tree node)
Deletes the given node from the tree.

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

partitionNode

protected void partitionNode(Tree node)
Partitions the given node. A JOptionPane appears requesting the entering of the kth element with which to partition.

Parameters:
node - the node to partition.

selectNode

protected void selectNode(Tree node)
Selects the given node. A JOptionPane appears requesting the entering of the kth element with which to select.

Parameters:
node - the node to select from.

inputChange

protected void inputChange(java.lang.String text)
Changes the input according to the text string. The tree is cleared if it is not empty. Also a key type change message is sent to all listeners.

Parameters:
text - the String representing the input change.

clearTree

protected int clearTree()
Clears the tree. Initiates a JOptionPane to confirm clearing.


clear

protected void clear()
Clears the tree. Does not initiate a JOptionPane to confirm clearing. Just clears.


insertCommand

public void insertCommand(java.lang.String text)
Insert command. Simply calls insertKeys with the text. Overide if necessary.

Parameters:
text - String to insert.

searchCommand

public void searchCommand(java.lang.String text)
Search command. Simply calls searchKeys with the text. Overide if necessary.

Parameters:
text - String to search.

deleteCommand

public void deleteCommand(java.lang.String text)
Delete command. Simply calls deleteKeys with the text. Overide if necessary.

Parameters:
text - String to delete.

deleteCommand

public void deleteCommand(Tree node)
Insert command. Simply calls insertKeys with the text. Overide if necessary.

Parameters:
node - Tree to delete.

selectCommand

public void selectCommand(java.lang.String text)
Select command. Simply calls selectKeys with the text. Overide if necessary.

Parameters:
text - String to select.

selectCommand

public void selectCommand(Tree node)
Select command. Simply calls selectKeys with the text. Overide if necessary.


clearCommand

public void clearCommand()
Clear command. Simply calls clearTree. Overide if necessary.


clearAllCommand

public void clearAllCommand()
Clear all command. Simply calls clear. Overide if necessary.


partitionCommand

public void partitionCommand(Tree node)
Partition command. Simply calls partitionNode. Overide if necessary.

Parameters:
node - Tree to partition.

rotateUpCommand

public void rotateUpCommand(Tree node)
RotateUp command. Does Nothing (not all trees have rotations). Overide if necessary.

Parameters:
node - Tree to rotateUp.

rotateToTopCommand

public void rotateToTopCommand(Tree node)
RotateToTop command. Does Nothing (not all trees have rotations). Overide if necessary.

Parameters:
node - Tree to rotateToTop.

rotateUpDoubleCommand

public void rotateUpDoubleCommand(Tree node)
RotateUpDouble command. Does Nothing (not all trees have rotations). Overide if necessary.

Parameters:
node - Tree to rotateUpDouble.

splayCommand

public void splayCommand(Tree node)
Splay command. Does Nothing (not all trees have rotations). Overide if necessary.

Parameters:
node - Tree to splay.

balanceCommand

public void balanceCommand(Tree node)
Balance command. Does Nothing. Overide if necessary.

Parameters:
node - Tree to balance.

traverseCommand

public void traverseCommand(int traverseType)
Traverse command. Does Nothing. Overide if necessary.

Parameters:
traverseType - int that defines the traverseType.

playCommand

public void playCommand()
Play command.


playStepCommand

public void playStepCommand()
Play command.


playFastCommand

public void playFastCommand()
Play command.


rewindCommand

public void rewindCommand()
Play command.


rewindStepCommand

public void rewindStepCommand()
Play command.


rewindFastCommand

public void rewindFastCommand()
Play command.


pauseCommand

public void pauseCommand()
Pause command.


stopCommand

public void stopCommand()
Stop command.


animatingCommand

public void animatingCommand(boolean animatingCommand)
Animation command.


animationQualityCommand

public void animationQualityCommand(int quality)
Animation quality command.

Parameters:
quality - int setting the quality of the animation.

animationSpeedCommand

public void animationSpeedCommand(int speed)
Animation speed command.

Parameters:
speed - int setting the speed of the animation.

inputChangeCommand

public void inputChangeCommand(java.lang.String input)
Input Change Command.

Parameters:
input - string setting the new input type.

saveTreeCommand

public void saveTreeCommand(TreeJPanel panel)

makeJPopupMenu

public javax.swing.JPopupMenu makeJPopupMenu(java.awt.event.ActionListener actionListener)
Constructs a popupmenu, using the actionlistener passed. The popupMenu contains all of the options available through the current tree. For this class, no items are added, making it necessary to overide the method.

Parameters:
actionListener - the listener add to the actions of all the items made in the menu.
Returns:
JPopupMenu which is the menu constructed within the panel.

makeColorSchemeOptions

public void makeColorSchemeOptions()
Passes a message to make the color scheme options for the current Panel. Generally called if this panel becomes selected. A tree message is sent with TreeMessageEvent.COLOR_PANEL with this as the object.


makeColorSettings

public void makeColorSettings()
Passes a message to make the color settings options for the current Panel. Generally called if this panel becomes selected. A tree message is sent with TreeMessageEvent.SET_PRESET_COLOR_OPTIONS with this as the object.


constructColorOptions

public void constructColorOptions(ColorOptionsJPanel allTreeToolsPanel)
Constructs the color settings for this tree, using the given parameter.

Parameters:
allTreeToolsPanel - Panel to construct the color settings.

constructPresetColorOptions

public void constructPresetColorOptions(ColorOptionsJPanel colorOptionsPanel)
Constructs the color settings combo box and sets the box for the given colorOptionsPanel.

Parameters:
colorOptionsPanel - the colorOptionsPanel for which the JComboBox is set.

addTreeMessageListener

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

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.

Parameters:
l - the listener removed from recieving the TreeMessageEvents occuring.

messageAction

protected void messageAction(java.lang.String msg,
                             java.lang.Object msgObj)
Calls all of the treeListeners of the Tree and passes the tree message information information regarding the status of the Tree.

Parameters:
msg - String message for the action of the message.
msgObj - the accompanying object for the message.

setSettings

public void setSettings(TreeJPanel panel)
Sets the settings for the panel param.

Parameters:
panel - the panel for the settings to be set.

optionEventPerformed

public void optionEventPerformed(OptionEvent e)
Recieved an event from an OptionJPanel with one of the given commands. The Panel responds accordingly. The Methods it calls (for example: insertCommand, rotateCommand...) should be overiden in extending classes to functionable.

Specified by:
optionEventPerformed in interface OptionListener
Parameters:
e - OptionEvent recieved from the event performed.

treeMessageEventPerformed

public void treeMessageEventPerformed(TreeMessageEvent e)
Listens to tree message events.

Specified by:
treeMessageEventPerformed in interface TreeMessageListener
Parameters:
e - TreeMessageEvent that contains information about the tree.

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Listens to action events.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - ActionEvent that contains information about the tree.