Partial Documentation for Class TraversalGUI

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Frame
                          |
                          +--javax.swing.JFrame
                                |
                                +--TraversalGUI
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.RootPaneContainer, java.io.Serializable, javax.swing.WindowConstants

public class TraversalGUI
extends javax.swing.JFrame

Environment-Based Applications:
The TraversalGUI class provides a graphical user interface to a program that creates an animation of 2-D structure traversals.

See Also:
Serialized Form

  
Constructor Summary
TraversalGUI(BoundedEnv env, java.awt.Color backgroundColor, java.awt.Color highlightColor, int displayWidth, int displayHeight)
          Construct the graphical user interface.
 
Method Summary
static EnvIterator getIterator(java.lang.String name, BoundedEnv env)
          Construct the iterator with the specified name.
 void newWindow()
          Constructs a new window in which to run another instance of the traversal algorithm animation program.
static void register(java.lang.String name, java.lang.Class iteratorClass)
           
 void resetEnv()
          Resets the environment to be empty.
 void runTraversal(java.lang.String buttonLabel)
          Animates a traversal algorithm.
 void step()
          Executes one step in a traversal.
 void stopAlg()
          Interrupts a running traversal algorithm.
 
Methods inherited from class javax.swing.JFrame
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getJMenuBar, getLayeredPane, getRootPane, isRootPaneCheckingEnabled, paramString, processKeyEvent, processWindowEvent, remove, setContentPane, setDefaultCloseOperation, setGlassPane, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, update
 
Methods inherited from class java.awt.Frame
addNotify, finalize, getCursorType, getFrames, getIconImage, getMenuBar, getState, getTitle, isResizable, remove, removeNotify, setCursor, setIconImage, setMenuBar, setResizable, setState, setTitle
 
Methods inherited from class java.awt.Window
addWindowListener, applyResourceBundle, applyResourceBundle, dispose, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, isShowing, pack, postEvent, processEvent, removeWindowListener, setCursor, show, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setFont, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseMotionEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.awt.MenuContainer
getFont, postEvent
 

Constructor Detail

TraversalGUI

public TraversalGUI(BoundedEnv env,
                    java.awt.Color backgroundColor,
                    java.awt.Color highlightColor,
                    int displayWidth,
                    int displayHeight)
Construct the graphical user interface. (Precondition: env and highlightColor are not null.)
Parameters:
env - bounded environment in which to animate traversals
backgroundColor - background color for environment
highlightColor - highlight color to illustrate traversal
displayWidth - width of visible display area in pixels
displayHeight - height of visible display area in pixels
Method Detail

register

public static void register(java.lang.String name,
                            java.lang.Class iteratorClass)

getIterator

public static EnvIterator getIterator(java.lang.String name,
                                      BoundedEnv env)
Construct the iterator with the specified name.
Parameters:
name - name (label) of a traversal algorithm
Returns:
an iterator that traverses in the specified order

runTraversal

public void runTraversal(java.lang.String buttonLabel)
Animates a traversal algorithm. It should be easy to visually verify a correct traversal algorithm. This method will throw an exception if an incorrect traversal algorithm visits more locations than exist in the environment.
Parameters:
buttonLabel - name (label) of traversal algorithm
Throws:
java.lang.RuntimeException - if the algorithm visits more locations than there are in the environment (revisiting some)

step

public void step()
Executes one step in a traversal.

stopAlg

public void stopAlg()
Interrupts a running traversal algorithm.

resetEnv

public void resetEnv()
Resets the environment to be empty.

newWindow

public void newWindow()
Constructs a new window in which to run another instance of the traversal algorithm animation program.