jfrace.view
Class MemoryView

java.lang.Object
  |
  +--jfrace.view.MemoryView

public class MemoryView
extends java.lang.Object

Class to be used to draw the content of a memory cell inside an AWT component. The memory cell is shown bitwise by colored squares (default: green and orange for bit: 0 and 1, resp.). The value is also painted as a hexadecimal number right of the squares.

Author:
Franz-Josef Elmer

Constructor Summary
MemoryView(int theX, int theY, int aNumberOfBits)
          Create an instance for the given number of bits with default values for cell size, bit colors, number distance, and number font.
MemoryView(int theX, int theY, int aNumberOfBits, int anXSize, int aYSize, java.awt.Color aColor0, java.awt.Color aColor1, int aNumberDistance, java.awt.Font aNumberFont)
          Create an instance with overwritten all default parameters.
 
Method Summary
 void draw(java.awt.Graphics g)
          Draw the bit cells and the hex number.
 int getBitIndex(int theX, int theY)
          Return the index of the bit below the given position.
 int getCellWidth()
          Return the with of a bit cell.
 int getHeight()
          Return the height of a bit cell.
 int getWidthFor(java.awt.Component c)
          Return the with of the bit cells plus hex number.
 void setValue(int aValue)
          Set the value of the memory cell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MemoryView

public MemoryView(int theX,
                  int theY,
                  int aNumberOfBits)
Create an instance for the given number of bits with default values for cell size, bit colors, number distance, and number font.
Parameters:
theX - The x coordinate of the upper left corner.
theY - The y coordinate of the upper left corner.
aNumberOfBits - The number of bits.

MemoryView

public MemoryView(int theX,
                  int theY,
                  int aNumberOfBits,
                  int anXSize,
                  int aYSize,
                  java.awt.Color aColor0,
                  java.awt.Color aColor1,
                  int aNumberDistance,
                  java.awt.Font aNumberFont)
Create an instance with overwritten all default parameters.
Parameters:
theX - The x coordinate of the upper left corner.
theY - The y coordinate of the upper left corner.
aNumberOfBits - The number of bits.
anXSize - With of a bit cell in pixels.
aYSize - Height of a bit cell in pixels.
aColor0 - Color for bit 0.
aColor1 - Color for bit 1.
aNumberDistance - Distance in pixels between bit cells and hexadecimal number.
aNumberFont - The font for the number.
Method Detail

getWidthFor

public int getWidthFor(java.awt.Component c)
Return the with of the bit cells plus hex number.
Parameters:
c - An AWT component needed to calculate the with of the number.

getCellWidth

public int getCellWidth()
Return the with of a bit cell.

getHeight

public int getHeight()
Return the height of a bit cell.

setValue

public void setValue(int aValue)
Set the value of the memory cell. Does not update the view.

getBitIndex

public int getBitIndex(int theX,
                       int theY)
Return the index of the bit below the given position.
Parameters:
theX - The x coordinate of the position.
theY - The y coordinate of the position.
Returns:
-1 if no bit below the point (x, y).

draw

public void draw(java.awt.Graphics g)
Draw the bit cells and the hex number.
Parameters:
g - Graphics context to be drawn.