Package mars.venus.execute
Class DataSegmentWindow
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JInternalFrame
mars.venus.execute.DataSegmentWindow
- All Implemented Interfaces:
ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,RootPaneContainer
,WindowConstants
,Memory.Listener
,SimulatorListener
Represents the Data Segment window, which is a type of JInternalFrame.
- Author:
- Sanderson and Bumgarner
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JInternalFrame
JInternalFrame.AccessibleJInternalFrame, JInternalFrame.JDesktopIcon
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
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
static final int
static final int
static final boolean
static final int
static final int
static final int
static final boolean
static final int
Fields inherited from class javax.swing.JInternalFrame
closable, CONTENT_PANE_PROPERTY, desktopIcon, FRAME_ICON_PROPERTY, frameIcon, GLASS_PANE_PROPERTY, iconable, IS_CLOSED_PROPERTY, IS_ICON_PROPERTY, IS_MAXIMUM_PROPERTY, IS_SELECTED_PROPERTY, isClosed, isIcon, isMaximum, isSelected, LAYERED_PANE_PROPERTY, maximizable, MENU_BAR_PROPERTY, resizable, ROOT_PANE_PROPERTY, rootPane, rootPaneCheckingEnabled, title, TITLE_PROPERTY
Fields inherited from class javax.swing.JComponent
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
accessibleContext, 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
Fields inherited from interface javax.swing.WindowConstants
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, EXIT_ON_CLOSE, HIDE_ON_CLOSE
-
Constructor Summary
ConstructorsConstructorDescriptionDataSegmentWindow
(VenusUI gui, NumberDisplayBaseChooser[] choosers) Constructor for the Data Segment window. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear highlight background color from any cell currently highlighted.void
Removes the table from its frame, typically done when a file is closed.displayCellForAddress
(int address) Given address, will compute table cell location, adjusting table if necessary to contain this cell, make sure that cell is visible, then return a Point containing row and column position of cell in the table.void
highlightCellForAddress
(int address) Scroll the viewport so the cell at the given data segment address is visible, vertically centered if possible, and highlighted (but not selected).void
memoryWritten
(int address, int length, int value, int wordAddress, int wordValue) Invoked upon any write operation which is relevant to this listener's active range.void
selectCellForAddress
(int address) Scroll the viewport so the cell at the given data segment address is visible, vertically centered if possible, and selected.void
Generates and displays fresh table, typically done upon successful assembly.void
Called when the simulator stops execution of a program due to termination or finishing.void
Called when the simulator stops execution of a program due to pausing.void
Called when the simulator begins execution of a program.void
Called when the simulator has finished executing an instruction, but only if the run speed is not unlimited.void
Convenience method to add this as a listener of all memory.void
Convenience method to remove this as a listener of memory.void
void
Redisplay the addresses.void
updateModelForMemoryRange
(int firstAddress) Update table model with contents of new memory "chunk".void
updateUI()
For whatever reason, FlatLaf seems to forget what the frame icon is set to after this method is called.void
Update data display to show all values.Methods inherited from class javax.swing.JInternalFrame
addImpl, addInternalFrameListener, createRootPane, dispose, doDefaultCloseAction, fireInternalFrameEvent, getAccessibleContext, getContentPane, getDefaultCloseOperation, getDesktopIcon, getDesktopPane, getFocusCycleRootAncestor, getFocusOwner, getFrameIcon, getGlassPane, getInternalFrameListeners, getJMenuBar, getLastCursor, getLayer, getLayeredPane, getMenuBar, getMostRecentFocusOwner, getNormalBounds, getRootPane, getTitle, getUI, getUIClassID, getWarningString, hide, isClosable, isClosed, isFocusCycleRoot, isIcon, isIconifiable, isMaximizable, isMaximum, isResizable, isRootPaneCheckingEnabled, isSelected, moveToBack, moveToFront, pack, paintComponent, paramString, remove, removeInternalFrameListener, reshape, restoreSubcomponentFocus, setClosable, setClosed, setContentPane, setCursor, setDefaultCloseOperation, setDesktopIcon, setFocusCycleRoot, setFrameIcon, setGlassPane, setIcon, setIconifiable, setJMenuBar, setLayer, setLayer, setLayeredPane, setLayout, setMaximizable, setMaximum, setMenuBar, setNormalBounds, setResizable, setRootPane, setRootPaneCheckingEnabled, setSelected, setTitle, setUI, show, toBack, toFront
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, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, 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, 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
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, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface mars.mips.hardware.Memory.Listener
memoryRead, memoryReset
-
Field Details
-
VALUES_PER_ROW
public static final int VALUES_PER_ROW- See Also:
-
ROW_COUNT
public static final int ROW_COUNT- See Also:
-
COLUMN_COUNT
public static final int COLUMN_COUNT- See Also:
-
BYTES_PER_VALUE
public static final int BYTES_PER_VALUE- See Also:
-
BYTES_PER_ROW
public static final int BYTES_PER_ROW- See Also:
-
MEMORY_CHUNK_SIZE
public static final int MEMORY_CHUNK_SIZE- See Also:
-
PREV_NEXT_CHUNK_SIZE
public static final int PREV_NEXT_CHUNK_SIZE- See Also:
-
ADDRESS_COLUMN
public static final int ADDRESS_COLUMN- See Also:
-
USER_MODE
public static final boolean USER_MODE- See Also:
-
KERNEL_MODE
public static final boolean KERNEL_MODE- See Also:
-
-
Constructor Details
-
DataSegmentWindow
Constructor for the Data Segment window.- Parameters:
choosers
- an array of objects used by user to select number display base (10 or 16)
-
-
Method Details
-
updateBaseAddressComboBox
public void updateBaseAddressComboBox() -
selectCellForAddress
public void selectCellForAddress(int address) Scroll the viewport so the cell at the given data segment address is visible, vertically centered if possible, and selected. Developed July 2007 for new feature that shows source code step where label is defined when that label is clicked on in the Label Window. Note there is a separate method to highlight the cell by setting its background color to a highlighting color. Thus one cell can be highlighted while a different cell is selected at the same time.- Parameters:
address
- data segment address of word to be selected.
-
highlightCellForAddress
public void highlightCellForAddress(int address) Scroll the viewport so the cell at the given data segment address is visible, vertically centered if possible, and highlighted (but not selected).- Parameters:
address
- Data segment address of word to be selected.
-
displayCellForAddress
Given address, will compute table cell location, adjusting table if necessary to contain this cell, make sure that cell is visible, then return a Point containing row and column position of cell in the table. This private helper method is called by selectCellForAddress() and highlightCellForAddress(). This is the kind of design I tell my students to avoid! The method both translates address to table cell coordinates and adjusts the display to assure the cell is visible. The two operations are related because the address may fall in within address space not currently in the (display) table, including a different MIPS data segment (e.g. in kernel instead of user data segment). -
setupTable
public void setupTable()Generates and displays fresh table, typically done upon successful assembly. -
clearWindow
public void clearWindow()Removes the table from its frame, typically done when a file is closed. -
clearHighlighting
public void clearHighlighting()Clear highlight background color from any cell currently highlighted. -
updateModelForMemoryRange
public void updateModelForMemoryRange(int firstAddress) Update table model with contents of new memory "chunk". MARS supports megabytes of data segment space so we only plug a "chunk" at a time into the table.- Parameters:
firstAddress
- The first address in the memory range to be placed in the model.
-
updateDataAddresses
public void updateDataAddresses()Redisplay the addresses. This should only be done when address display base is modified (e.g. between base 16, hex, and base 10, dec). -
updateValues
public void updateValues()Update data display to show all values. -
simulatorStarted
Description copied from interface:SimulatorListener
Called when the simulator begins execution of a program.- Specified by:
simulatorStarted
in interfaceSimulatorListener
- Parameters:
event
- The event which occurred.
-
simulatorPaused
Description copied from interface:SimulatorListener
Called when the simulator stops execution of a program due to pausing.- Specified by:
simulatorPaused
in interfaceSimulatorListener
- Parameters:
event
- The event which occurred.
-
simulatorFinished
Description copied from interface:SimulatorListener
Called when the simulator stops execution of a program due to termination or finishing.- Specified by:
simulatorFinished
in interfaceSimulatorListener
- Parameters:
event
- The event which occurred.
-
simulatorStepped
public void simulatorStepped()Description copied from interface:SimulatorListener
Called when the simulator has finished executing an instruction, but only if the run speed is not unlimited.Note: For very fast run speeds, GUI listeners may not receive all step events. This is an intentional feature to prevent overloading of the GUI event queue.
- Specified by:
simulatorStepped
in interfaceSimulatorListener
-
updateUI
public void updateUI()For whatever reason, FlatLaf seems to forget what the frame icon is set to after this method is called. So, this method has been overwritten to set the frame icon back tonull
as desired.- Overrides:
updateUI
in classJInternalFrame
-
memoryWritten
public void memoryWritten(int address, int length, int value, int wordAddress, int wordValue) Description copied from interface:Memory.Listener
Invoked upon any write operation which is relevant to this listener's active range. Does nothing by default.- Specified by:
memoryWritten
in interfaceMemory.Listener
- Parameters:
address
- The address which was written to.length
- The number of bytes written. Will always be 1 (single byte),Memory.BYTES_PER_HALFWORD
, orMemory.BYTES_PER_WORD
.value
- The value which was written.wordAddress
- The address of the word affected by the operation.wordValue
- The resulting value of the word.
-
startObservingMemory
public void startObservingMemory()Convenience method to add this as a listener of all memory. -
stopObservingMemory
public void stopObservingMemory()Convenience method to remove this as a listener of memory.
-