|
||||||||||
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>
edu.princeton.cs.algs4.growingtree.framework.BSTTreeJPanel<P>
public class BSTTreeJPanel<P extends NodeProperties>
This class provides the panel for a BSTTree
. 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.
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 |
CHRISTMAS
Christmas color scheme. |
static java.lang.String |
DEFAULT
Default color scheme. |
static java.lang.String |
HALLOWEEN
Halloween color scheme. |
static java.lang.String |
PRIMARY
Default color scheme. |
static java.lang.String |
PRINCETON
Princeton color scheme. |
Fields inherited from class edu.princeton.cs.algs4.growingtree.framework.TreeJPanel |
---|
BACKGROUND, CHARACTER, DEFAULT_DELAY, DELETE, DOUBLE, DRAWING, INSERT, INTEGER, KEY, KEY_ANIMATOR_SETTINGS, KEY_ORIGINAL_SETTINGS, LEFT_PAINT, NODE, NODE_ANIMATOR_SETTINGS, NODE_CHILD_SETTINGS, NODE_DESCENDANT_SETTINGS, NODE_LEFT_SETTINGS, NODE_ORIGINAL_SETTINGS, NODE_RIGHT_SETTINGS, NODE_ROOT_SETTINGS, NOKEY, PAINT, RIGHT_PAINT, ROTATE, SEARCH, SELECT, TRAVERSE, TYPEERR |
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 | |
---|---|
BSTTreeJPanel()
Sole Constructor. |
|
BSTTreeJPanel(P np,
IInsertOperator<P> inserter,
ISearchOperator<P> searcher,
IDeleteOperator<P> deleter,
boolean allowRotations)
|
|
BSTTreeJPanel(P np,
IInsertOperator<P> inserter,
ISearchOperator<P> searcher,
IDeleteOperator<P> deleter,
IExperimentLogger<P> logger,
boolean allowRotations)
|
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent e)
Listens to action events. |
void |
balanceCommand(Tree node)
Balance command. |
void |
constructColorOptions(ColorOptionsJPanel colorOptionsPanel)
Constructs the color options combo box and sets the box for the given colorOptionsPanel. |
void |
constructPresetColorOptions(ColorOptionsJPanel colorOptionsPanel)
Constructs the color settings combo box and sets the box for the given colorOptionsPanel. |
void |
displayChangeCommand()
Change Display Command. |
void |
drawAnimatingNode()
Draws the animating node using the currently selected animating settings. |
void |
drawDrawingNode()
Draws the drawing node using the currently selected drawing settings. |
java.lang.String[] |
getColorSchemeOptions()
Gets the color scheme aniamtion options for the current tree. |
java.lang.String |
getColorSchemeSetting(java.lang.String function,
java.lang.String setting)
Gets the Color Scheme setting for the given function and setting. |
java.lang.String[] |
getColorSchemesList(java.lang.String settings)
Gets the color scheme settings for each type of settings. |
java.lang.String[] |
getColorSettings()
Gets the color settings options for the current tree. |
java.lang.String |
getColorSettingsString()
Gets the color settings string of the current panel to the colorSettings param. |
java.lang.String[] |
getOptionColorSchemeOptions(java.lang.String option)
Gets the color scheme options for each type of animation. |
java.lang.String |
getTitle()
Gets the title for the tree. |
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 |
resetSettingStrings()
Resets the string settings currently selected. |
void |
rotateToTopCommand(Tree<P> node)
RotateToTop command. |
void |
rotateUpCommand(Tree<P> node)
RotateUp command. |
void |
rotateUpDoubleCommand(Tree node)
RotateUpDouble command. |
void |
setAnimating(boolean animating)
Sets whether the tree is animating or not. |
void |
setColorSchemeSetting(java.lang.String presetScheme)
Sets the color scheme using the given preset scheme string. |
void |
setColorSchemeSetting(java.lang.String function,
java.lang.String setting,
java.lang.String scheme)
Sets the color scheme using the given function and setting. |
void |
setColorSettingsString(java.lang.String colorSettings)
Sets the color settings string of the current panel to the colorSettings param. |
void |
setComponentShown(boolean componentShown)
Sets whether the tree is shown or not. |
void |
setSettings()
Sets the settings for the panel using the currently selected String options. |
void |
setSettings(TreeJPanel panel)
Sets the settings for the panel using the currently selected String options. |
void |
setSubtreeCountsCommand(boolean visible)
|
void |
splayCommand(Tree node)
Splay command. |
void |
traverseCommand(int traverseType)
Traverse command. |
Methods inherited from class edu.princeton.cs.algs4.growingtree.framework.TreeJPanel |
---|
addTreeMessageListener, animatingCommand, animationQualityCommand, animationSpeedCommand, clearAllCommand, clearCommand, deleteCommand, deleteCommand, getInputOptions, getKeyType, getTree, getTreeStatusMessage, inputChangeCommand, insertCommand, isAnimating, isStep, makeColorSchemeOptions, makeColorSettings, paintComponent, partitionCommand, pauseCommand, playCommand, playFastCommand, playStepCommand, removeTreeMessageListener, repaintAttempt, rewindCommand, rewindFastCommand, rewindStepCommand, saveTreeCommand, searchCommand, selectCommand, selectCommand, setDelayRate, setStep, setTree, stopCommand, treeMessageEventPerformed |
Methods inherited from class edu.princeton.cs.algs4.growingtree.framework.DrawingJPanel |
---|
componentHidden, componentMoved, componentResized, componentShown, getDrawingArea, getDrawTreeGraphics, getDrawTreeImage, isComponentShown, isDrawTree, 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 DEFAULT
public static final java.lang.String PRIMARY
public static final java.lang.String PRINCETON
public static final java.lang.String CHRISTMAS
public static final java.lang.String HALLOWEEN
Constructor Detail |
---|
public BSTTreeJPanel()
public BSTTreeJPanel(P np, IInsertOperator<P> inserter, ISearchOperator<P> searcher, IDeleteOperator<P> deleter, boolean allowRotations)
public BSTTreeJPanel(P np, IInsertOperator<P> inserter, ISearchOperator<P> searcher, IDeleteOperator<P> deleter, IExperimentLogger<P> logger, boolean allowRotations)
Method Detail |
---|
public java.lang.String getTitle()
getTitle
in class TreeJPanel<P extends NodeProperties>
public void resetSettingStrings()
public void setSettings()
The Panel used is the current panel.
public void setSettings(TreeJPanel panel)
The Panel used is the passed panel.
setSettings
in class TreeJPanel<P extends NodeProperties>
panel
- panel to which the settings are changed according to the currently
selected settings.public void setColorSettingsString(java.lang.String colorSettings)
colorSettings
- the String defining the colorSettings for the current panel.public java.lang.String getColorSettingsString()
public void drawDrawingNode()
public void drawAnimatingNode()
public java.lang.String getColorSchemeSetting(java.lang.String function, java.lang.String setting)
function
- String function like DRAWING or BACKGROUND.setting
- String setting choice for which the color setting is requested like NODE.
public void setColorSchemeSetting(java.lang.String function, java.lang.String setting, java.lang.String scheme)
function
- for which the setting is given.setting
- the setting for which the scheme is set.scheme
- the color setting used for the given function and setting.public void setColorSchemeSetting(java.lang.String presetScheme)
presetScheme
- the preset sceme defined.public java.lang.String[] getColorSchemeOptions()
public java.lang.String[] getColorSettings()
public java.lang.String[] getOptionColorSchemeOptions(java.lang.String option)
public java.lang.String[] getColorSchemesList(java.lang.String settings)
public void constructColorOptions(ColorOptionsJPanel colorOptionsPanel)
constructColorOptions
in class TreeJPanel<P extends NodeProperties>
colorOptionsPanel
- the colorToolsJPanel for which the JComboBox is set.public void constructPresetColorOptions(ColorOptionsJPanel colorOptionsPanel)
constructPresetColorOptions
in class TreeJPanel<P extends NodeProperties>
colorOptionsPanel
- the colorOptionsPanel for which the JComboBox is set.public javax.swing.JPopupMenu makeJPopupMenu(java.awt.event.ActionListener actionlistener)
makeJPopupMenu
in class TreeJPanel<P extends NodeProperties>
actionListener
- the listener add to the actions of all the items made in the menu.
public void setAnimating(boolean animating)
setAnimating
in class TreeJPanel<P extends NodeProperties>
animating
- boolean flag as to whether the tree is animating.public void setComponentShown(boolean componentShown)
setComponentShown
in class DrawingJPanel
componentShown
- boolean flag as to whether the tree is shown.public void setSubtreeCountsCommand(boolean visible)
setSubtreeCountsCommand
in class TreeJPanel<P extends NodeProperties>
public void rotateUpCommand(Tree<P> node)
rotateUpCommand
in class TreeJPanel<P extends NodeProperties>
node
- Tree to rotateUp.public void rotateToTopCommand(Tree<P> node)
rotateToTopCommand
in class TreeJPanel<P extends NodeProperties>
node
- Tree to rotateToTop.public void rotateUpDoubleCommand(Tree node)
rotateUpDoubleCommand
in class TreeJPanel<P extends NodeProperties>
node
- Tree to rotateUpDouble.public void splayCommand(Tree node)
splayCommand
in class TreeJPanel<P extends NodeProperties>
node
- Tree to splay.public void traverseCommand(int traverseType)
traverseCommand
in class TreeJPanel<P extends NodeProperties>
traverseType
- int that defines the traverseType.public void balanceCommand(Tree node)
balanceCommand
in class TreeJPanel<P extends NodeProperties>
node
- Tree to balance.public void displayChangeCommand()
public void optionEventPerformed(OptionEvent e)
optionEventPerformed
in interface OptionListener
optionEventPerformed
in class TreeJPanel<P extends NodeProperties>
e
- OptionEvent recieved from the event performed.public void actionPerformed(java.awt.event.ActionEvent e)
actionPerformed
in interface java.awt.event.ActionListener
actionPerformed
in class TreeJPanel<P extends NodeProperties>
e
- ActionEvent that contains information about the tree.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |