|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Container | +--javax.swing.JComponent | +--javax.swing.JPanel | +--DrawingJPanel | +--TreeJPanel
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.
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 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 |
public static final java.lang.String TYPEERR
public static final java.lang.String NOKEY
public static final java.lang.String INTEGER
public static final java.lang.String CHARACTER
public static final java.lang.String DOUBLE
public static final java.lang.String DRAWING
public static final java.lang.String BACKGROUND
public static final java.lang.String INSERT
public static final java.lang.String SEARCH
public static final java.lang.String SELECT
public static final java.lang.String ROTATE
public static final java.lang.String DELETE
public static final java.lang.String TRAVERSE
public static final java.lang.String NODE
public static final java.lang.String KEY
public static final java.lang.String PAINT
public static final java.lang.String NODE_LEFT_SETTINGS
public static final java.lang.String NODE_RIGHT_SETTINGS
public static final java.lang.String NODE_ANIMATOR_SETTINGS
public static final java.lang.String KEY_ANIMATOR_SETTINGS
public static final java.lang.String KEY_ORIGINAL_SETTINGS
public static final java.lang.String NODE_ROOT_SETTINGS
public static final java.lang.String NODE_CHILD_SETTINGS
public static final java.lang.String NODE_DESCENDANT_SETTINGS
public static final java.lang.String NODE_ORIGINAL_SETTINGS
public static final java.lang.String LEFT_PAINT
public static final java.lang.String RIGHT_PAINT
public static final int DEFAULT_DELAY
Constructor Detail |
public TreeJPanel()
Method Detail |
public void setTree(AnimatingTreeHead tree)
tree
- AnimatingTreeHead head.public void setDelayRate(int t)
public void setAnimating(boolean animating)
animating
- boolean flag as to whether the tree is animating.public void setStep(boolean step)
step
- boolean flag as to whether the tree is stepping.protected void setAnimationTimer(javax.swing.Timer animationTimer)
animationTimer
- javax.swing.Timer defining the steps of animation.protected void setKeyType(java.lang.String keyType)
keyType
- String defining the type of key in the tree.protected java.lang.Object stringToType(java.lang.String text)
NumberFormatException
is caught and an error message String is returned instead
of an object.
text
- String to be converted into an object.
public java.lang.String getTitle()
public java.lang.String getTreeStatusMessage()
TreeStatusMessage
of the tree within the panel.
public AnimatingTreeHead getTree()
public boolean isAnimating()
public boolean isStep()
public java.lang.String getKeyType()
protected javax.swing.Timer getAnimationTimer()
public void getInputOptions()
protected java.util.LinkedList getObjectList(java.lang.String text)
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.
text
- String to be made into an Object list.
protected java.util.LinkedList getStringList(java.lang.String text)
text
- the String to be parsed into Strings.
protected void draw()
draw
in class DrawingJPanel
public void paintComponent(java.awt.Graphics g)
paintComponent
in class DrawingJPanel
g
- Graphics to which the component is drawn.protected void makeTypeErrorMessage(java.lang.String error)
protected void makeTypeIntegerErrorMessage(java.lang.String error)
protected void makeMissingErrorMessage(java.lang.String error)
protected void insertKeys(java.lang.String text)
getObjectList
to produce objects. Then, those objects are inserted with
a newly made DrawingKey.
text
- String to be inserted into the tree.protected void searchKeys(java.lang.String text)
getObjectList
to produce objects. Then, those objects are searched for.
text
- String to be searched into the tree.protected void selectKeys(java.lang.String text)
getObjectList
to produce objects. Then, those objects are selected.
text
- String to be selected into the tree.protected void deleteKeys(java.lang.String text)
getObjectList
to produce objects. Then, those objects are deleted.
text
- String to be deleted into the tree.protected void deleteNode(Tree node)
node
- the Tree node to be deleted from the tree.protected void partitionNode(Tree node)
node
- the node to partition.protected void selectNode(Tree node)
node
- the node to select from.protected void inputChange(java.lang.String text)
text
- the String representing the input change.protected int clearTree()
protected void clear()
public void insertCommand(java.lang.String text)
text
- String to insert.public void searchCommand(java.lang.String text)
text
- String to search.public void deleteCommand(java.lang.String text)
text
- String to delete.public void deleteCommand(Tree node)
node
- Tree to delete.public void selectCommand(java.lang.String text)
text
- String to select.public void selectCommand(Tree node)
public void clearCommand()
public void clearAllCommand()
public void partitionCommand(Tree node)
node
- Tree to partition.public void rotateUpCommand(Tree node)
node
- Tree to rotateUp.public void rotateToTopCommand(Tree node)
node
- Tree to rotateToTop.public void rotateUpDoubleCommand(Tree node)
node
- Tree to rotateUpDouble.public void splayCommand(Tree node)
node
- Tree to splay.public void balanceCommand(Tree node)
node
- Tree to balance.public void traverseCommand(int traverseType)
traverseType
- int that defines the traverseType.public void playCommand()
public void playStepCommand()
public void playFastCommand()
public void rewindCommand()
public void rewindStepCommand()
public void rewindFastCommand()
public void pauseCommand()
public void stopCommand()
public void animatingCommand(boolean animatingCommand)
public void animationQualityCommand(int quality)
quality
- int setting the quality of the animation.public void animationSpeedCommand(int speed)
speed
- int setting the speed of the animation.public void inputChangeCommand(java.lang.String input)
input
- string setting the new input type.public void saveTreeCommand(TreeJPanel panel)
public javax.swing.JPopupMenu makeJPopupMenu(java.awt.event.ActionListener actionListener)
actionListener
- the listener add to the actions of all the items made in the menu.
public void makeColorSchemeOptions()
TreeMessageEvent.COLOR_PANEL
with
this as the object.
public void makeColorSettings()
TreeMessageEvent.SET_PRESET_COLOR_OPTIONS
with
this as the object.
public void constructColorOptions(ColorOptionsJPanel allTreeToolsPanel)
allTreeToolsPanel
- Panel to construct the color settings.public void constructPresetColorOptions(ColorOptionsJPanel colorOptionsPanel)
colorOptionsPanel
- the colorOptionsPanel for which the JComboBox is set.public void addTreeMessageListener(TreeMessageListener l)
TreeMessageEvent
.
l
- the listener added recieves the TreeMessageEvents occuring.public void removeTreeMessageListener(TreeMessageListener l)
TreeMessageEvent
.
l
- the listener removed from recieving the TreeMessageEvents occuring.protected void messageAction(java.lang.String msg, java.lang.Object msgObj)
msg
- String message for the action of the message.msgObj
- the accompanying object for the message.public void setSettings(TreeJPanel panel)
panel
- the panel for the settings to be set.public void optionEventPerformed(OptionEvent e)
optionEventPerformed
in interface OptionListener
e
- OptionEvent recieved from the event performed.public void treeMessageEventPerformed(TreeMessageEvent e)
treeMessageEventPerformed
in interface TreeMessageListener
e
- TreeMessageEvent that contains information about the tree.public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
e
- ActionEvent that contains information about the tree.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |