hades.gui
Class MicroRomEditorCanvas

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Canvas
          extended byhades.gui.MicroRomEditorCanvas
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.io.Serializable

public class MicroRomEditorCanvas
extends java.awt.Canvas
implements java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

MicroRomEditorCanvas - a hex-style editor for direct editing of microprogram contents. The memory data is expected to consist of an array of long[] for the ROM data (allowing for up to 64 bits output) and an array String[] for state comments and labels. 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 MicroRomEditorCanvas:

Add your own objects as ActionListeners for all value changes on a MicroRomEditorCanvas by calling MicroRomEditorCanvas.addActionListener().

Note that MicroRomEditorCanvas 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 Class Summary
 
Nested classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  java.util.Hashtable actionListenerTable
           
protected  java.lang.String[] addrCache
           
protected  java.awt.Color addrColor
           
protected  java.awt.Color backgroundColor
           
protected  int baseline
           
protected  int border_height
           
protected  int border_width
           
protected  int char_height
           
protected  int char_width
           
protected  int cursor_x
           
protected  int cursor_y
           
protected  long[] data
           
protected  java.lang.String[] dataCache
           
protected  java.awt.Color dataColor
           
static boolean debug
           
protected  int dx_data
           
protected  int end_address
           
protected  int height
           
protected  int n_bits_per_word
           
protected  int n_chars
           
protected  int n_chars_per_addr
           
protected  int n_chars_per_word
           
protected  int n_columns
           
protected  int n_cursor
           
protected  int n_rows
           
protected  int n_words
           
protected  int n_words_per_row
           
protected  int n_words_per_screen
           
protected  java.awt.Image offscreenBuffer
           
protected  java.awt.Graphics offscreenGraphics
           
protected  int readHighlightAddress
           
protected  java.awt.Color readHighlightColor
           
protected  java.awt.Scrollbar scroller
           
protected  boolean shiftMode
           
protected  int start_address
           
protected  java.awt.Font textFont
           
protected  int value
           
protected  int width
           
protected  int writeHighlightAddress
           
protected  java.awt.Color writeHighlightColor
           
protected  int x0_addr
           
protected  int x0_data
           
protected  int y0_addr
           
protected  int y0_data
           
 
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
MicroRomEditorCanvas(long[] data, int n_words, int n_bits_per_word, int n_rows, int n_words_per_row)
           
 
Method Summary
 void addActionListener(java.awt.event.ActionListener AL)
           
 void blitOffscreenBuffer(java.awt.Graphics g)
           
 int clip(int currentValue, int minValue, int maxValue)
           
protected  void createOffscreenBuffer()
           
 void decrementValue()
           
 void editStartAddress(char c)
           
 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.
 int getAddrFromCursorPosition()
           
 java.awt.Color getBackground()
           
 int getCursorAddrIndex()
           
protected  long getData(int addr)
           
 java.awt.Color getDataColor()
           
protected  int getDataFieldWidth(int n_bits_per_word)
           
 java.awt.Dimension getMinimumSize()
           
 java.awt.Dimension getPreferredSize()
           
 java.awt.Color getReadHightlightColor()
           
 int getRelativeDataCursor()
          this method returns the relative cursor position for the data value value nearest to the cursor.
 java.awt.Font getTextFont()
           
 java.awt.Color getWriteHightlightColor()
           
 void incrementValue()
           
 void insertDigitAtMousePosition(char c)
          insert char c at the current cursor postion, then move the cursor to the right.
 boolean isCursorInAddrArea()
           
 boolean isCursorInDataArea()
           
 boolean isDataVisibleAtAddress(int addr)
           
static boolean isHexDigit(char c)
           
 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 makeDataVisibleAtAddress(int addr)
           
 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)
           
 void moveCursorDown()
           
 void moveCursorLeft()
           
 void moveCursorRight()
           
 void moveCursorTo(int x, int y)
           
 void moveCursorToDataAtAddr(int addr)
           
 void moveCursorUp()
           
 void moveEnd()
           
 void moveHome()
           
 void moveLineDown()
           
 void moveLineUp()
           
 void movePageDown()
           
 void movePageUp()
           
 void moveTabNext()
           
 void moveTabPrev()
           
 void moveToAddress(int addr)
           
static void msg(java.lang.String msg)
           
protected  void notifyListeners(int addr, long value)
           
 void notifyScroller()
           
 void paint(java.awt.Graphics systemGraphics)
           
 void paintAllAddresses(java.awt.Graphics g)
           
 void paintAllData(java.awt.Graphics g)
           
 void paintBackgroundAndBorder(java.awt.Graphics g)
           
 void paintCursor(java.awt.Graphics g)
           
 void paintHighlighting(java.awt.Graphics g)
           
 void paintStringAtAddr(java.awt.Graphics g, int addr, java.lang.String s)
           
protected  void prepareGUI()
           
 void removeActionListener(java.awt.event.ActionListener AL)
           
 void setAddrColor(java.awt.Color c)
           
 void setBackground(java.awt.Color c)
           
 void setCursorFromMousePosition(java.awt.event.MouseEvent me)
           
protected  void setData(int addr, long value)
           
 void setDataColor(java.awt.Color c)
           
 void setDigitAtMousePosition(char c)
           
 void setReadHighlightAddress(int addr)
          set the address of the last read access to the underlying memory.
 void setReadHighlightColor(java.awt.Color c)
           
 void setScroller(java.awt.Scrollbar scroller)
           
 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 java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

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

addrCache

protected java.lang.String[] addrCache

dataCache

protected java.lang.String[] dataCache

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

offscreenBuffer

protected java.awt.Image offscreenBuffer

offscreenGraphics

protected java.awt.Graphics offscreenGraphics

scroller

protected java.awt.Scrollbar scroller

n_columns

protected int n_columns

n_rows

protected int n_rows

n_words_per_row

protected int n_words_per_row

n_chars_per_word

protected int n_chars_per_word

n_chars_per_addr

protected int n_chars_per_addr

n_words_per_screen

protected int n_words_per_screen

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

start_address

protected int start_address

end_address

protected int end_address

cursor_x

protected int cursor_x

cursor_y

protected int cursor_y

n_cursor

protected int n_cursor

n_chars

protected int n_chars

value

protected int value

shiftMode

protected boolean shiftMode

readHighlightAddress

protected int readHighlightAddress

writeHighlightAddress

protected int writeHighlightAddress
Constructor Detail

MicroRomEditorCanvas

public MicroRomEditorCanvas(long[] data,
                            int n_words,
                            int n_bits_per_word,
                            int n_rows,
                            int n_words_per_row)
Method Detail

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()

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.


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)

createOffscreenBuffer

protected void createOffscreenBuffer()

blitOffscreenBuffer

public void blitOffscreenBuffer(java.awt.Graphics g)

paintBackgroundAndBorder

public void paintBackgroundAndBorder(java.awt.Graphics g)

paintAllAddresses

public void paintAllAddresses(java.awt.Graphics g)

paintAllData

public void paintAllData(java.awt.Graphics g)

paintStringAtAddr

public void paintStringAtAddr(java.awt.Graphics g,
                              int addr,
                              java.lang.String s)

paintHighlighting

public void paintHighlighting(java.awt.Graphics g)

paintCursor

public void paintCursor(java.awt.Graphics g)

update

public void update(java.awt.Graphics g)

paint

public void paint(java.awt.Graphics systemGraphics)

getMinimumSize

public java.awt.Dimension getMinimumSize()

getPreferredSize

public java.awt.Dimension getPreferredSize()

setCursorFromMousePosition

public void setCursorFromMousePosition(java.awt.event.MouseEvent me)

isCursorInDataArea

public boolean isCursorInDataArea()

isCursorInAddrArea

public boolean isCursorInAddrArea()

isDataVisibleAtAddress

public boolean isDataVisibleAtAddress(int addr)

makeDataVisibleAtAddress

public void makeDataVisibleAtAddress(int addr)

getRelativeDataCursor

public int getRelativeDataCursor()
this method returns the relative cursor position for the data value value nearest to the cursor.


getAddrFromCursorPosition

public int getAddrFromCursorPosition()

getCursorAddrIndex

public int getCursorAddrIndex()

clip

public int clip(int currentValue,
                int minValue,
                int maxValue)

moveCursorTo

public void moveCursorTo(int x,
                         int y)

moveCursorRight

public void moveCursorRight()

moveCursorLeft

public void moveCursorLeft()

moveCursorUp

public void moveCursorUp()

moveCursorDown

public void moveCursorDown()

movePageUp

public void movePageUp()

movePageDown

public void movePageDown()

moveLineUp

public void moveLineUp()

moveLineDown

public void moveLineDown()

moveHome

public void moveHome()

moveEnd

public void moveEnd()

moveToAddress

public void moveToAddress(int addr)

moveCursorToDataAtAddr

public void moveCursorToDataAtAddr(int addr)

moveTabNext

public void moveTabNext()

moveTabPrev

public void moveTabPrev()

notifyScroller

public void notifyScroller()

setScroller

public void setScroller(java.awt.Scrollbar scroller)

incrementValue

public void incrementValue()

decrementValue

public void decrementValue()

setDigitAtMousePosition

public void setDigitAtMousePosition(char c)

editStartAddress

public void editStartAddress(char c)

insertDigitAtMousePosition

public 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

public 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)