miSim

misim
Class ViewPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--misim.ViewPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.MenuContainer, ProcessorView, java.io.Serializable, java.awt.event.TextListener

public class ViewPanel
extends java.awt.Panel
implements java.awt.event.ActionListener, java.awt.event.TextListener, java.awt.event.ItemListener, ProcessorView

The ViewPanel displays the contents of the Processor, as a listing either generated during assembly of a file, or by disassembling a pre-compiled binary. The view also shows the essential processor state registers, PC, W and the Status register. The user may edit these through the view panel.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
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
ViewPanel(Processor processor, EditorPrefs prefs, boolean isApplet, LogListener logging, java.awt.Color background)
          Constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent anEvent)
          Respond to a GUI event.
 java.awt.PopupMenu createDebugMenu()
          Pass the request to create a Debug Popup Menu onto the breakpoint manager, which handles all menu events.
 void disassemble()
          Disassemble the software loaded into the processor.
 void display(boolean showLine)
          Display the current state of the processor, and ensure that the currently executed instruction is being displayed by the disassembly view.
 TextFile getFile()
          Return the file that this view panel is displaying
 int getSelectedAddress(int defaultAddr)
          Return the address of the currently selected line in the processor view
 void itemStateChanged(java.awt.event.ItemEvent e)
          Respond to a selection event in the main list view
 void loadListing(TextFile listFile, boolean errors)
          Load an assembled listing into the view.
 void selectAddress(int address)
          Select the line that represents the given address, and make sure that line is visible.
 void setBreakpoint(int address, boolean setBreak)
          Set the given address to have a breakpoint, or remove a set breakpoint
 void setProcessor(Processor processor)
          Set a new processor for the viewPanel and the breakpointManager.
 void setReg()
          Set a processor register from the GUI TextFields
 void textValueChanged(java.awt.event.TextEvent evt)
          Respond to a change in the flagValue text field Parse this and the flag number text field and see if the value is the same as the given flag.
 void updateButtons()
          Pass the request to update menu buttons on to the breakpoint manager
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, 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, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ViewPanel

public ViewPanel(Processor processor,
                 EditorPrefs prefs,
                 boolean isApplet,
                 LogListener logging,
                 java.awt.Color background)
Constructor. Layout the view panel, construct the BreakpointManager and initialise member variables.
Method Detail

setProcessor

public void setProcessor(Processor processor)
Set a new processor for the viewPanel and the breakpointManager. This happens when assembly causes the processor type to change.
Parameters:
processor - The new processor

createDebugMenu

public java.awt.PopupMenu createDebugMenu()
Pass the request to create a Debug Popup Menu onto the breakpoint manager, which handles all menu events.
Returns:
The newly created PopupMenu

getFile

public TextFile getFile()
Return the file that this view panel is displaying
Returns:
The current TextFile

updateButtons

public void updateButtons()
Pass the request to update menu buttons on to the breakpoint manager

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent anEvent)
Respond to a GUI event.
Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
anEvent - The event to be processed.

textValueChanged

public void textValueChanged(java.awt.event.TextEvent evt)
Respond to a change in the flagValue text field Parse this and the flag number text field and see if the value is the same as the given flag. If it is, disable the 'Set' button, otherwise enable the button so that the user can set the flag to the new value.
Specified by:
textValueChanged in interface java.awt.event.TextListener
Parameters:
evt - The event that ocurred

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Respond to a selection event in the main list view
Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
e - The ItemEvent that has ocurred

display

public void display(boolean showLine)
Display the current state of the processor, and ensure that the currently executed instruction is being displayed by the disassembly view.

selectAddress

public void selectAddress(int address)
Select the line that represents the given address, and make sure that line is visible.
Specified by:
selectAddress in interface ProcessorView
Parameters:
address - The address to select

getSelectedAddress

public int getSelectedAddress(int defaultAddr)
Return the address of the currently selected line in the processor view
Specified by:
getSelectedAddress in interface ProcessorView
Parameters:
defaultAddr - The default address to return if no valid line is selected
Returns:
The currently selected address, or the default if none

setBreakpoint

public void setBreakpoint(int address,
                          boolean setBreak)
Set the given address to have a breakpoint, or remove a set breakpoint
Specified by:
setBreakpoint in interface ProcessorView
Parameters:
address - The address to set or clear a breakpoint
setBreak - True if a breakpoint is to be set, false otherwise

setReg

public void setReg()
Set a processor register from the GUI TextFields

loadListing

public void loadListing(TextFile listFile,
                        boolean errors)
Load an assembled listing into the view.
Parameters:
asm - The Assembler used to generate the listing
listing - The listing of the assembled object code
errors - If true, the listing has errors

disassemble

public void disassemble()
Disassemble the software loaded into the processor. Mainly this is an interface between the processor, which can disassemble individual instructions and the list object that displays the entire program.

miSim