edu.wpi.cs.cs509.clipboard
Class PaintableCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--edu.wpi.cs.cs509.clipboard.PaintableCanvas
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class PaintableCanvas
extends java.awt.Canvas

Class representing an Image button that can be hilighted and/or 3d-depressed.

State machine controlling behavior is as follows:

States:

Q0 (Initial): not Hilighted, not Depressed
Q1 (Hilighted): Hilighted, not Depressed
Q2 (Depressed): not Hilighted, Depressed

Transitions:

Q0: setHilight (true) => Q1
Q0: setDepressed (true) => Q2
Q1: setHilight (false) => Q0
Q1: setDepressed (true) => Q2
Q2: setDepressed (false) => Q0
Q2: setHilight (true) => Q1 (*special case*)

Author:
George T. Heineman (heineman@cs.wpi.edu)
See Also:
Serialized Form

Field Summary
protected  java.awt.Image image
          The image shown on the screen.
protected  boolean isDepressed
          Whether the image should be in the 'depressed' 3d state.
protected  boolean isHilighted
          Whether the image should be in the hilighted state.
protected  java.awt.image.ImageObserver observer
          The observer of the image (needed for graphic drawing routines).
 
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
PaintableCanvas()
          PaintableCanvas default constructor.
PaintableCanvas(java.awt.GraphicsConfiguration config)
          PaintableCanvas constructor comment.
 
Method Summary
 boolean isDepressed()
          Determine whether the region is currently depressed (signals that action will be taken).
 void paint(java.awt.Graphics g)
          Paint the pre-set image onto this canvas
 void setDepressed(boolean flag)
          Should the button area depressed (in 3d sense not emotive sense).
 void setHilight(boolean flag)
          Hilight area or not.
 void setImage(java.awt.Image i, java.awt.image.ImageObserver observer)
          Tell ths paintable canvas which image (and observer) to use when drawing.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
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, getBackground, 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, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, 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, setBackground, 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

image

protected java.awt.Image image
The image shown on the screen.


isHilighted

protected boolean isHilighted
Whether the image should be in the hilighted state.


isDepressed

protected boolean isDepressed
Whether the image should be in the 'depressed' 3d state.


observer

protected java.awt.image.ImageObserver observer
The observer of the image (needed for graphic drawing routines).

Constructor Detail

PaintableCanvas

public PaintableCanvas()
PaintableCanvas default constructor.


PaintableCanvas

public PaintableCanvas(java.awt.GraphicsConfiguration config)
PaintableCanvas constructor comment.

Parameters:
config - java.awt.GraphicsConfiguration
Method Detail

isDepressed

public boolean isDepressed()
Determine whether the region is currently depressed (signals that action will be taken).

Returns:
boolean

paint

public void paint(java.awt.Graphics g)
Paint the pre-set image onto this canvas

Overrides:
paint in class java.awt.Canvas

setDepressed

public void setDepressed(boolean flag)
Should the button area depressed (in 3d sense not emotive sense).

Forces a repaint of the region if depressed state has changed.


setHilight

public void setHilight(boolean flag)
Hilight area or not.

Note: If the region was depressed, a request to hilight actually turns off the depressed state while retaining the hilight state; a repaint occurs.

Forces a repaint of the region if hilighted state has changed.


setImage

public void setImage(java.awt.Image i,
                     java.awt.image.ImageObserver observer)
Tell ths paintable canvas which image (and observer) to use when drawing.

Forces a repaint.