hades.gui
Class MemoryHexEditorField
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
hades.gui.MemoryHexEditorField
- All Implemented Interfaces:
- java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, javax.swing.Scrollable, java.io.Serializable
- Direct Known Subclasses:
- DcoreDisassemblerOrHexCanvas, HexMemoryCanvas, MRCanvas
- public class MemoryHexEditorField
- extends javax.swing.JComponent
- implements javax.swing.Scrollable, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener
MemoryHexEditorField - an hex-style editor for direct editing
of memory-contents.
The current data-structures support memories of n_words (that is,
address range 0 .. n_words-1) of n_bits_per_word each, where
n_bits_per_word may be anything between 1 .. 64 bits.
However, note that integers and longs in Java are signed, so that it
may a bit inconvenient to actually use 64 bit values.
The following list describes the editing functions of MemoryHexEditorField:
Add your own objects as ActionListeners for all value changes on a
MemoryHexEditorField by calling MemoryHexEditorField.addActionListener().
Note that MemoryHexEditorField currently uses class java.lang.Long
to parse hexadecimal numbers, which are therefore assumed to be signed.
This may lead to surprising behaviour when tried on 64-bit registers,
but it should work ok with registers from 1 to 63 bits.
Please complain to Javasoft that we do need unsigned integers after all...
- See Also:
- Serialized Form
Nested classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
Nested classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
Nested classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
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.Container |
|
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 |
Method Summary |
void |
addActionListener(java.awt.event.ActionListener AL)
|
protected void |
checkInit()
|
protected int |
clip(int currentValue,
int minValue,
int maxValue)
|
protected void |
decrementValue()
|
protected void |
editStartAddress(char c)
|
protected int |
getAddrAreaEnd()
|
java.awt.Color |
getAddrColor()
|
protected int |
getAddrFieldWidth(int n_words)
calculate the number of chars required to display an hex-address for
a memory with n_words. |
protected int |
getAddrFromCursorPosition()
|
java.awt.Color |
getBackground()
|
protected int |
getColumns()
|
int |
getCursor_x()
|
int |
getCursor_y()
|
protected long |
getData(int addr)
|
protected int |
getDataAreaBegin()
|
java.awt.Color |
getDataColor()
|
protected int |
getDataFieldWidth(int n_bits_per_word)
|
java.awt.Dimension |
getMinimumSize()
|
java.awt.Dimension |
getMinimumSize(int rows)
|
java.awt.Dimension |
getPreferredScrollableViewportSize()
|
java.awt.Dimension |
getPreferredSize()
|
protected int |
getReadHightlightAddress()
|
java.awt.Color |
getReadHightlightColor()
|
protected int |
getRows()
|
int |
getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
|
boolean |
getScrollableTracksViewportHeight()
|
boolean |
getScrollableTracksViewportWidth()
|
int |
getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
|
java.awt.Font |
getTextFont()
|
protected int |
getWordsPerInstruction()
|
protected int |
getWordsPerRow()
|
protected int |
getWriteHightlightAddress()
|
java.awt.Color |
getWriteHightlightColor()
|
protected void |
incrementValue()
|
void |
init()
|
protected void |
insertDigitAtMousePosition(char c)
insert char c at the current cursor postion, then move the cursor
to the right. |
protected boolean |
isCursorInAddrArea()
|
protected boolean |
isCursorInDataArea()
|
protected static boolean |
isHexDigit(char c)
|
boolean |
isOpaque()
|
void |
keyPressed(java.awt.event.KeyEvent ke)
|
void |
keyReleased(java.awt.event.KeyEvent ke)
|
void |
keyTyped(java.awt.event.KeyEvent ke)
|
static void |
main(java.lang.String[] argv)
|
void |
mouseClicked(java.awt.event.MouseEvent me)
|
void |
mouseDragged(java.awt.event.MouseEvent me)
|
void |
mouseEntered(java.awt.event.MouseEvent me)
|
void |
mouseExited(java.awt.event.MouseEvent me)
|
void |
mouseMoved(java.awt.event.MouseEvent me)
|
void |
mousePressed(java.awt.event.MouseEvent me)
|
void |
mouseReleased(java.awt.event.MouseEvent me)
|
protected void |
moveCursorRight()
|
protected void |
moveCursorTo(int x,
int y)
|
protected void |
moveTabNext()
|
protected void |
moveTabNextOLD()
|
protected void |
moveTabPrev()
|
protected void |
moveTabPrevOLD()
|
static void |
msg(java.lang.String msg)
|
protected void |
notifyListeners(int addr,
long value)
|
void |
paint(java.awt.Graphics systemGraphics)
|
protected void |
paintAllAddresses(java.awt.Graphics g)
|
protected void |
paintAllAddressesNoClip(java.awt.Graphics g)
|
protected void |
paintBackgroundAndBorder(java.awt.Graphics g)
|
protected void |
paintBackgroundAndBorderNoClip(java.awt.Graphics g)
|
protected void |
paintCursor(java.awt.Graphics g)
|
protected void |
prepareGUI()
|
void |
removeActionListener(java.awt.event.ActionListener AL)
|
void |
setAddrColor(java.awt.Color c)
|
void |
setBackground(java.awt.Color c)
|
protected void |
setCursorFromMousePosition(java.awt.event.MouseEvent me)
|
protected void |
setData(int addr,
long value)
|
void |
setDataColor(java.awt.Color c)
|
void |
setReadHighlightAddress(int addr)
set the address of the last read access to the underlying memory. |
void |
setReadHighlightColor(java.awt.Color c)
|
void |
setTextFont(java.awt.Font f)
|
void |
setWriteHighlightAddress(int addr)
set the address of the last write access to the underlying memory. |
void |
setWriteHighlightColor(java.awt.Color c)
|
void |
update(java.awt.Graphics g)
|
Methods inherited from class javax.swing.JComponent |
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, 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, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, 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 |
debug
public static boolean debug
n_words
protected int n_words
n_bits_per_word
protected int n_bits_per_word
data
protected long[] data
actionListenerTable
protected java.util.Hashtable actionListenerTable
textFont
protected java.awt.Font textFont
backgroundColor
protected java.awt.Color backgroundColor
dataColor
protected java.awt.Color dataColor
addrColor
protected java.awt.Color addrColor
readHighlightColor
protected java.awt.Color readHighlightColor
writeHighlightColor
protected java.awt.Color writeHighlightColor
n_columns
protected int n_columns
n_rows
protected int n_rows
n_words_per_row
protected int n_words_per_row
visibleWordsPerRow
protected int visibleWordsPerRow
n_chars_per_addr
protected int n_chars_per_addr
n_chars_per_word
protected int n_chars_per_word
char_width
protected int char_width
char_height
protected int char_height
baseline
protected int baseline
x0_addr
protected int x0_addr
x0_data
protected int x0_data
y0_addr
protected int y0_addr
y0_data
protected int y0_data
dx_data
protected int dx_data
border_width
protected int border_width
border_height
protected int border_height
width
protected int width
height
protected int height
cursor_x
protected int cursor_x
cursor_y
protected int cursor_y
shiftMode
protected boolean shiftMode
readHighlightAddress
protected int readHighlightAddress
writeHighlightAddress
protected int writeHighlightAddress
memoryObject
protected Memory memoryObject
initialized
protected boolean initialized
MemoryHexEditorField
public MemoryHexEditorField(Memory memoryObject,
int n_words_per_row)
init
public void init()
setBackground
public void setBackground(java.awt.Color c)
setDataColor
public void setDataColor(java.awt.Color c)
setAddrColor
public void setAddrColor(java.awt.Color c)
setReadHighlightColor
public void setReadHighlightColor(java.awt.Color c)
setWriteHighlightColor
public void setWriteHighlightColor(java.awt.Color c)
getBackground
public java.awt.Color getBackground()
getDataColor
public java.awt.Color getDataColor()
getAddrColor
public java.awt.Color getAddrColor()
getReadHightlightColor
public java.awt.Color getReadHightlightColor()
getWriteHightlightColor
public java.awt.Color getWriteHightlightColor()
getReadHightlightAddress
protected int getReadHightlightAddress()
getWriteHightlightAddress
protected int getWriteHightlightAddress()
setReadHighlightAddress
public void setReadHighlightAddress(int addr)
- set the address of the last read access to the underlying memory.
On the next repaint, this address will be highlighted.
For performance reasons, this class does *not* request a repaint()
automatically. Instead the class calling setReadHighlightAddress()
is responsible to request a repaint on this canvas, if necessary.
setWriteHighlightAddress
public void setWriteHighlightAddress(int addr)
- set the address of the last write access to the underlying memory.
On the next repaint, this address will be highlighted.
For performance reasons, this class does *not* request a repaint()
automatically. Instead the class calling setWriteHighlightAddress()
is responsible to request a repaint on this canvas, if necessary.
getAddrFieldWidth
protected int getAddrFieldWidth(int n_words)
- calculate the number of chars required to display an hex-address for
a memory with n_words.
Note that memory addresses range from 0 .. n_words-1.
Therefore, we need 1 chars for the address field for n_words <= 16,
2 chars for n_words <= 256, etc.
getDataFieldWidth
protected int getDataFieldWidth(int n_bits_per_word)
getData
protected long getData(int addr)
setData
protected void setData(int addr,
long value)
notifyListeners
protected void notifyListeners(int addr,
long value)
addActionListener
public void addActionListener(java.awt.event.ActionListener AL)
removeActionListener
public void removeActionListener(java.awt.event.ActionListener AL)
prepareGUI
protected void prepareGUI()
getTextFont
public java.awt.Font getTextFont()
setTextFont
public void setTextFont(java.awt.Font f)
paintBackgroundAndBorder
protected void paintBackgroundAndBorder(java.awt.Graphics g)
paintAllAddresses
protected void paintAllAddresses(java.awt.Graphics g)
paintBackgroundAndBorderNoClip
protected void paintBackgroundAndBorderNoClip(java.awt.Graphics g)
paintAllAddressesNoClip
protected void paintAllAddressesNoClip(java.awt.Graphics g)
paintCursor
protected void paintCursor(java.awt.Graphics g)
isOpaque
public boolean isOpaque()
update
public void update(java.awt.Graphics g)
paint
public void paint(java.awt.Graphics systemGraphics)
getMinimumSize
public java.awt.Dimension getMinimumSize(int rows)
getPreferredSize
public java.awt.Dimension getPreferredSize()
getMinimumSize
public java.awt.Dimension getMinimumSize()
checkInit
protected void checkInit()
setCursorFromMousePosition
protected void setCursorFromMousePosition(java.awt.event.MouseEvent me)
isCursorInDataArea
protected boolean isCursorInDataArea()
isCursorInAddrArea
protected boolean isCursorInAddrArea()
getDataAreaBegin
protected int getDataAreaBegin()
getAddrAreaEnd
protected int getAddrAreaEnd()
getWordsPerRow
protected int getWordsPerRow()
getWordsPerInstruction
protected int getWordsPerInstruction()
getAddrFromCursorPosition
protected int getAddrFromCursorPosition()
clip
protected int clip(int currentValue,
int minValue,
int maxValue)
moveCursorTo
protected void moveCursorTo(int x,
int y)
moveCursorRight
protected void moveCursorRight()
moveTabNextOLD
protected void moveTabNextOLD()
moveTabPrevOLD
protected void moveTabPrevOLD()
moveTabNext
protected void moveTabNext()
moveTabPrev
protected void moveTabPrev()
incrementValue
protected void incrementValue()
decrementValue
protected void decrementValue()
editStartAddress
protected void editStartAddress(char c)
insertDigitAtMousePosition
protected void insertDigitAtMousePosition(char c)
- insert char c at the current cursor postion, then move the cursor
to the right. If the cursor is at the rightmost position, we begin
to shift the current value to the left.
If the cursor is in the address field instead of the data field,
we jump to the corresponding address (that is, display the corres-
ponding area of the memory).
isHexDigit
protected static boolean isHexDigit(char c)
mousePressed
public void mousePressed(java.awt.event.MouseEvent me)
- Specified by:
mousePressed
in interface java.awt.event.MouseListener
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent me)
- Specified by:
mouseReleased
in interface java.awt.event.MouseListener
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent me)
- Specified by:
mouseClicked
in interface java.awt.event.MouseListener
mouseExited
public void mouseExited(java.awt.event.MouseEvent me)
- Specified by:
mouseExited
in interface java.awt.event.MouseListener
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent me)
- Specified by:
mouseEntered
in interface java.awt.event.MouseListener
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent me)
- Specified by:
mouseMoved
in interface java.awt.event.MouseMotionListener
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent me)
- Specified by:
mouseDragged
in interface java.awt.event.MouseMotionListener
keyPressed
public void keyPressed(java.awt.event.KeyEvent ke)
- Specified by:
keyPressed
in interface java.awt.event.KeyListener
keyReleased
public void keyReleased(java.awt.event.KeyEvent ke)
- Specified by:
keyReleased
in interface java.awt.event.KeyListener
keyTyped
public void keyTyped(java.awt.event.KeyEvent ke)
- Specified by:
keyTyped
in interface java.awt.event.KeyListener
msg
public static void msg(java.lang.String msg)
main
public static void main(java.lang.String[] argv)
getPreferredScrollableViewportSize
public java.awt.Dimension getPreferredScrollableViewportSize()
- Specified by:
getPreferredScrollableViewportSize
in interface javax.swing.Scrollable
getScrollableBlockIncrement
public int getScrollableBlockIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
- Specified by:
getScrollableBlockIncrement
in interface javax.swing.Scrollable
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()
- Specified by:
getScrollableTracksViewportHeight
in interface javax.swing.Scrollable
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()
- Specified by:
getScrollableTracksViewportWidth
in interface javax.swing.Scrollable
getScrollableUnitIncrement
public int getScrollableUnitIncrement(java.awt.Rectangle visibleRect,
int orientation,
int direction)
- Specified by:
getScrollableUnitIncrement
in interface javax.swing.Scrollable
getColumns
protected int getColumns()
getRows
protected int getRows()
getCursor_x
public int getCursor_x()
getCursor_y
public int getCursor_y()