|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
edu.princeton.cs.algs4.growingtree.framework.DrawingJPanel
edu.princeton.cs.algs4.growingtree.framework.TreeJPanel<P>
public class TreeJPanel<P extends NodeProperties>
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/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.BaselineResizeBehavior |
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 |
---|
TOOL_TIP_TEXT_KEY, 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<P> node)
Balance command. |
void |
clearAllCommand()
Clear all command. |
void |
clearCommand()
Clear command. |
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<P> node)
Insert command. |
void |
getInputOptions()
Gets the input options for the current tree. |
java.lang.String |
getKeyType()
Gets the key type for the tree. |
java.lang.String |
getTitle()
Gets the title for the tree. |
AnimatingTreeHead<P> |
getTree()
Gets the head of the tree currently drawn in the Panel. |
java.lang.String |
getTreeStatusMessage()
Get the tree message. |
void |
inputChangeCommand(java.lang.String input)
Input Change Command. |
void |
insertCommand(java.lang.String text)
Insert command. |
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. |
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<P> node)
Partition command. |
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 |
repaintAttempt()
|
void |
rewindCommand()
Play command. |
void |
rewindFastCommand()
Play command. |
void |
rewindStepCommand()
Play command. |
void |
rotateToTopCommand(Tree<P> node)
RotateToTop command. |
void |
rotateUpCommand(Tree<P> node)
RotateUp command. |
void |
rotateUpDoubleCommand(Tree<P> node)
RotateUpDouble command. |
void |
saveTreeCommand(TreeJPanel<P> panel)
|
void |
searchCommand(java.lang.String text)
Search command. |
void |
selectCommand(java.lang.String text)
Select command. |
void |
selectCommand(Tree<P> node)
Select command. |
void |
setAnimating(boolean animating)
Sets whether the tree is animating or not. |
void |
setDelayRate(int t)
Sets the delay rate for the timer for the animation. |
void |
setSettings(TreeJPanel<P> panel)
Sets the settings for the panel param. |
void |
setStep(boolean step)
Sets whether the tree is stepping or not. |
void |
setSubtreeCountsCommand(boolean visible)
|
void |
setTree(AnimatingTreeHead<P> tree)
Sets the head of the tree currently drawn in the Panel. |
void |
splayCommand(Tree<P> node)
Splay command. |
void |
stopCommand()
Stop command. |
void |
traverseCommand(int traverseType)
Traverse command. |
void |
treeMessageEventPerformed(TreeMessageEvent e)
Listens to tree message events. |
Methods inherited from class edu.princeton.cs.algs4.growingtree.framework.DrawingJPanel |
---|
componentHidden, componentMoved, componentResized, componentShown, getDrawingArea, getDrawTreeGraphics, getDrawTreeImage, isComponentShown, isDrawTree, setComponentShown, setDrawTree |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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 |
---|
equals, 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<P> 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.public java.lang.String getTitle()
public java.lang.String getTreeStatusMessage()
TreeStatusMessage
of the tree within the panel.
public AnimatingTreeHead<P> getTree()
public boolean isAnimating()
true
- if the tree is animating.public boolean isStep()
true
- if the tree is stepping.public java.lang.String getKeyType()
public void getInputOptions()
public void paintComponent(java.awt.Graphics g)
paintComponent
in class DrawingJPanel
g
- Graphics to which the component is drawn.public void repaintAttempt()
public void setSubtreeCountsCommand(boolean visible)
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<P> node)
node
- Tree to delete.public void selectCommand(java.lang.String text)
text
- String to select.public void selectCommand(Tree<P> node)
text
- String to select.public void clearCommand()
public void clearAllCommand()
public void partitionCommand(Tree<P> node)
node
- Tree to partition.public void rotateUpCommand(Tree<P> node)
node
- Tree to rotateUp.public void rotateToTopCommand(Tree<P> node)
node
- Tree to rotateToTop.public void rotateUpDoubleCommand(Tree<P> node)
node
- Tree to rotateUpDouble.public void splayCommand(Tree<P> node)
node
- Tree to splay.public void balanceCommand(Tree<P> 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)
step
- boolean turning animation on or off.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<P> 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.public void setSettings(TreeJPanel<P> 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 |