edu.princeton.toy
Class TSimMachinePane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JLayeredPane
                  extended by edu.princeton.toy.TSimMachinePane
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class TSimMachinePane
extends JLayeredPane

TSimMachinePane is a JPanel which acts the interface between the TVirtualMachine and the user when Visual X-TOY is in Sim mode.

See Also:
Serialized Form

Nested Class Summary
protected  class TSimMachinePane.Listener
          The Listener of a TBaseConverterPane pays attention to the changes in the PTextFields, and fires off changes to the other PTextFields.
protected  class TSimMachinePane.Runner
          Runner is a simple implementation of Runnable for the Thread started when the component's size changes.
 
Nested classes/interfaces inherited from class javax.swing.JLayeredPane
JLayeredPane.AccessibleJLayeredPane
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static int ADDR_BIT_COUNT
          The number of addr switches in the TSimMachinePane.
static Border BLUE_AREA_BORDER
          The border of the blue area in the TSimMachinePane.
static Color BLUE_AREA_COLOR
          The color of the blue area in the TSimMachinePane.
static int DATA_BIT_COUNT
          The number of addr switches in the TSimMachinePane.
static int INSTR_BIT_COUNT
          The number of instr lights in the TSimMachinePane.
static int MAX_SCALE
          The maxmimum scale to which the TSimMachinePane can be scaled.
static int MIN_SCALE
          The minimum scale which the TSimMachinePane can be scaled to.
static int PC_BIT_COUNT
          The number of pc lights in the TSimMachinePane.
static Border PLACEHOLDER_BORDER
          The border of the resizing placeholder in the TSimMachinePane.
static int PREFERRED_SCALE
          The scale used in determining the preferred size of the TSimMachinePane.
static String RESCALE_COMMAND
          The command to update the contents of the inputList with the stdin stream of the virtualMachine.
static String UPDATE_COMMAND
          The command to update the contents of the inputList with the stdin stream of the virtualMachine.
 
Fields inherited from class javax.swing.JLayeredPane
DEFAULT_LAYER, DRAG_LAYER, FRAME_CONTENT_LAYER, LAYER_PROPERTY, MODAL_LAYER, PALETTE_LAYER, POPUP_LAYER
 
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
TSimMachinePane(TVirtualMachine virtualMachine, Action loadAction, Action lookAction, Action stepAction, Action runAction, Action enterAction, Action interruptAction, Action resetAction)
          Creates a new TSimMachinePane.
 
Method Summary
 void addChangeListener(ChangeListener listener)
          Adds a listener to monitor changes in the state of the switches.
 boolean doCommand(String command, Object extraInfo)
          Performs a command based on the argument.
protected  void fireStateChanged()
          Fires a state changed event to all the listeners.
 TWord getAddr()
          Returns the TWord derived from the positions of the addr switches.
 TWord getData()
          Returns the TWord derived from the positions of the data switches.
 TVirtualMachine getVirtualMachine()
          Returns the virtualMachine attached to this TSimMachinePane.
protected  void processComponentEvent(ComponentEvent e)
          Intercept ComponentEvents to do resize and move the bluePanel when this component is resized.
 void removeChangeListener(ChangeListener listener)
          Removes a listener from this machine.
 void setVirtualMachine(TVirtualMachine virtualMachine)
          Sets the virtualMachine attached to this TSimMachinePane.
 
Methods inherited from class javax.swing.JLayeredPane
addImpl, getAccessibleContext, getComponentCountInLayer, getComponentsInLayer, getComponentToLayer, getIndexOf, getLayer, getLayer, getLayeredPaneAbove, getObjectForLayer, getPosition, highestLayer, insertIndexForLayer, isOptimizedDrawingEnabled, lowestLayer, moveToBack, moveToFront, paint, paramString, putLayer, remove, removeAll, setLayer, setLayer, setPosition
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, 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, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
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, processContainerEvent, processEvent, remove, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, 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, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESCALE_COMMAND

public static final String RESCALE_COMMAND
The command to update the contents of the inputList with the stdin stream of the virtualMachine.


UPDATE_COMMAND

public static final String UPDATE_COMMAND
The command to update the contents of the inputList with the stdin stream of the virtualMachine.


PC_BIT_COUNT

public static final int PC_BIT_COUNT
The number of pc lights in the TSimMachinePane.

See Also:
Constant Field Values

ADDR_BIT_COUNT

public static final int ADDR_BIT_COUNT
The number of addr switches in the TSimMachinePane.

See Also:
Constant Field Values

INSTR_BIT_COUNT

public static final int INSTR_BIT_COUNT
The number of instr lights in the TSimMachinePane.

See Also:
Constant Field Values

DATA_BIT_COUNT

public static final int DATA_BIT_COUNT
The number of addr switches in the TSimMachinePane.

See Also:
Constant Field Values

BLUE_AREA_COLOR

public static final Color BLUE_AREA_COLOR
The color of the blue area in the TSimMachinePane.


BLUE_AREA_BORDER

public static final Border BLUE_AREA_BORDER
The border of the blue area in the TSimMachinePane.


PLACEHOLDER_BORDER

public static final Border PLACEHOLDER_BORDER
The border of the resizing placeholder in the TSimMachinePane.


MIN_SCALE

public static final int MIN_SCALE
The minimum scale which the TSimMachinePane can be scaled to.

See Also:
Constant Field Values

MAX_SCALE

public static final int MAX_SCALE
The maxmimum scale to which the TSimMachinePane can be scaled.


PREFERRED_SCALE

public static final int PREFERRED_SCALE
The scale used in determining the preferred size of the TSimMachinePane.

See Also:
Constant Field Values
Constructor Detail

TSimMachinePane

public TSimMachinePane(TVirtualMachine virtualMachine,
                       Action loadAction,
                       Action lookAction,
                       Action stepAction,
                       Action runAction,
                       Action enterAction,
                       Action interruptAction,
                       Action resetAction)
Creates a new TSimMachinePane.

Method Detail

addChangeListener

public void addChangeListener(ChangeListener listener)
Adds a listener to monitor changes in the state of the switches.

Parameters:
listener - The listener to add to this pane. A null value will cause a NullPointerException.

removeChangeListener

public void removeChangeListener(ChangeListener listener)
Removes a listener from this machine. Nothing will happen if no match was found.

Parameters:
listener - The listener to remove from this pane. A null value will cause a NullPointerException.

setVirtualMachine

public void setVirtualMachine(TVirtualMachine virtualMachine)
Sets the virtualMachine attached to this TSimMachinePane.

Parameters:
virtualMachine - The virtualMachine to be attached to this TSimMachinePane.

getVirtualMachine

public TVirtualMachine getVirtualMachine()
Returns the virtualMachine attached to this TSimMachinePane.

Returns:
The virtualMachine attached to this TSimMachinePane.

getAddr

public TWord getAddr()
Returns the TWord derived from the positions of the addr switches.

Returns:
The TWord derived from the positions of the addr switches.

getData

public TWord getData()
Returns the TWord derived from the positions of the data switches.

Returns:
The TWord derived from the positions of the data switches.

fireStateChanged

protected void fireStateChanged()
Fires a state changed event to all the listeners.


doCommand

public boolean doCommand(String command,
                         Object extraInfo)
Performs a command based on the argument.

Parameters:
command - A string representing the command. Note that pointer equality (not string equality) is tested here, so it is important to use the string constants defined in this class. An IllegalArgumentException will be thrown if the argument is invalid.
Returns:
True iff the command was executed sucessfully.

processComponentEvent

protected void processComponentEvent(ComponentEvent e)
Intercept ComponentEvents to do resize and move the bluePanel when this component is resized.

Overrides:
processComponentEvent in class Component