zinger.nibbles
Class Field.Plotter

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--zinger.nibbles.Field.Plotter
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Enclosing class:
Field

public class Field.Plotter
extends java.awt.Canvas

This class separates data that is stored in its parent class from the presentation of that data. The actual implementation is not crucial, except for the fact that it should be efficient. Perhaps in the future this will be substituted by an interface or an abstract class.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
protected  java.awt.Image bgImage
          Image used for double buffering.
private  int cellHeight
           
private  int cellWidth
           
private  Field.GridChange lastChange
           
 
Fields inherited from class java.awt.Canvas
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Component
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dbg, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
Field.Plotter()
           
 
Method Summary
protected  int getCellHeight()
           
protected  int getCellWidth()
           
 void paint(java.awt.Graphics g)
          Paints all of available data in the parent class, not just the increments.
protected  void paintIncremental(java.awt.Graphics g)
          Draws into g incremental updates stored in the parent class.
(package private)  void replot()
          This is the key method that gets called when we need to update the presentation because of an incremental data change.
 void setSize(java.awt.Dimension size)
          Makes sure pre-calculated information gets reassessed when component is resized.
 void update(java.awt.Graphics g)
          First time bgImage initialization and double buffering logic here.
protected  int xToCoord(int x)
          Converts grid measurements to pixel measurements along X-axis.
protected  int yToCoord(int y)
          Converts grid measurements to pixel measurements along Y-axis.
 
Methods inherited from class java.awt.Canvas
, addNotify, constructComponentName, getAccessibleContext, postsOldMouseEvents
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkGD, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createChildHierarchyEvents, createHierarchyEvents, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initIDs, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPaint, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, numListening, paintAll, paintHeavyweightComponents, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, printHeavyweightComponents, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, readObject, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setVisible, show, show, size, toString, transferFocus, validate, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

bgImage

protected java.awt.Image bgImage
Image used for double buffering.

cellWidth

private int cellWidth

cellHeight

private int cellHeight

lastChange

private Field.GridChange lastChange
Constructor Detail

Field.Plotter

public Field.Plotter()
Method Detail

replot

void replot()
This is the key method that gets called when we need to update the presentation because of an incremental data change. Here we are dependent on efficiently stored incremental change information in the parent class.

paintIncremental

protected void paintIncremental(java.awt.Graphics g)
Draws into g incremental updates stored in the parent class.

update

public void update(java.awt.Graphics g)
First time bgImage initialization and double buffering logic here. During an incremental update, paint(Graphics) does not get called.
Overrides:
update in class java.awt.Component
See Also:
paint(java.awt.Graphics)

paint

public void paint(java.awt.Graphics g)
Paints all of available data in the parent class, not just the increments.
Overrides:
paint in class java.awt.Canvas

setSize

public void setSize(java.awt.Dimension size)
Makes sure pre-calculated information gets reassessed when component is resized.
Overrides:
setSize in class java.awt.Component

getCellWidth

protected int getCellWidth()

getCellHeight

protected int getCellHeight()

xToCoord

protected int xToCoord(int x)
Converts grid measurements to pixel measurements along X-axis.

yToCoord

protected int yToCoord(int y)
Converts grid measurements to pixel measurements along Y-axis.