objectdraw
Class AWTDrawingCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--objectdraw.AWTDrawingCanvas
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ComponentListener, DrawingCanvas, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable
Direct Known Subclasses:
FrameCanvas

public class AWTDrawingCanvas
extends java.awt.Canvas
implements DrawingCanvas, java.awt.event.ComponentListener

The AWTDrawingCanvas is an implementation of the DrawingCanvas interface whose methods are tailored to provide compabaility with standard AWT libraries. It calls corresponding methods of the CanvasManager in order to actually modify the canvas.

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
 
Field Summary
static java.awt.Dimension DEFAULT_PREFERRED_SIZE
           
 
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
AWTDrawingCanvas()
          Creates a new DrawingCanvas.
AWTDrawingCanvas(java.awt.Dimension size)
          Creates a new DrawingCanvas.
AWTDrawingCanvas(int width, int height)
          Creates a new DrawingCanvas.
 
Method Summary
 void addToCanvas(Drawable d)
          Removes the Drawable d from the AWTDrawingCanvas
 void clear()
          Clears the canvas.
 void componentHidden(java.awt.event.ComponentEvent e)
          Invoked when component has been hidden.
 void componentMoved(java.awt.event.ComponentEvent e)
          Invoked when component has been moved.
 void componentResized(java.awt.event.ComponentEvent e)
          Invoked when component has been resized.
 void componentShown(java.awt.event.ComponentEvent e)
          Invoked when component has been shown.
 void disableAutoRepaint()
          Turns auto repaint off so the programmer must indicate when the canvas should be repainted.
 void enableAutoRepaint()
          Turns auto repaint on so the programmer does not have to manually repaint after changing the canvas
 CanvasManager getCanvasContent()
          Returns an instance of the CanvasContainer
 int getHeight()
          Returns the height of the canvas
 java.awt.Dimension getPreferredSize()
          Retrieves the object's preferred size.
 int getWidth()
          Returns the width of the canvas
 boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
          Notifies the CanvasManager of a change in state and calls the native java method imageUpdate.
 void paint(java.awt.Graphics g)
          Paints the canvas by calling the real paint method of the CanvasContainer
 void removeFromCanvas(Drawable d)
          Removes the Drawable d from the AWTDrawingCanvas
 void repaint()
          Change repaint so that it always tries to delay a bit
 void update(java.awt.Graphics g)
          Updates the screen.
 
Methods inherited from class java.awt.Canvas
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getSize, getSize, getToolkit, getTreeLock, getX, getY, gotFocus, handleEvent, hasFocus, hide, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface objectdraw.DrawingCanvas
addComponentListener, addKeyListener, addMouseListener, addMouseMotionListener, createImage, getBackground, getForeground, getGraphics, getSize, prepareImage, setBackground, setForeground
 

Field Detail

DEFAULT_PREFERRED_SIZE

public static final java.awt.Dimension DEFAULT_PREFERRED_SIZE
Constructor Detail

AWTDrawingCanvas

public AWTDrawingCanvas()
Creates a new DrawingCanvas.

AWTDrawingCanvas

public AWTDrawingCanvas(int width,
                        int height)
Creates a new DrawingCanvas.
Parameters:
width - the canvas' preferred width
height - the canvas' preferred height

AWTDrawingCanvas

public AWTDrawingCanvas(java.awt.Dimension size)
Creates a new DrawingCanvas.
Parameters:
size - the canvas' preferred dimensions
Method Detail

getPreferredSize

public java.awt.Dimension getPreferredSize()
Retrieves the object's preferred size.
Overrides:
getPreferredSize in class java.awt.Component
Returns:
the object's preferred size

repaint

public void repaint()
Change repaint so that it always tries to delay a bit
Specified by:
repaint in interface DrawingCanvas
Overrides:
repaint in class java.awt.Component

getCanvasContent

public CanvasManager getCanvasContent()
Returns an instance of the CanvasContainer
Specified by:
getCanvasContent in interface DrawingCanvas

addToCanvas

public void addToCanvas(Drawable d)
Removes the Drawable d from the AWTDrawingCanvas
Specified by:
addToCanvas in interface DrawingCanvas

removeFromCanvas

public void removeFromCanvas(Drawable d)
Removes the Drawable d from the AWTDrawingCanvas
Specified by:
removeFromCanvas in interface DrawingCanvas

clear

public void clear()
Clears the canvas.
Specified by:
clear in interface DrawingCanvas

paint

public void paint(java.awt.Graphics g)
Paints the canvas by calling the real paint method of the CanvasContainer
Overrides:
paint in class java.awt.Canvas
Parameters:
g - the canvas' graphics context.

update

public void update(java.awt.Graphics g)
Updates the screen.
Overrides:
update in class java.awt.Component
Parameters:
g - the canvas' graphics context

enableAutoRepaint

public void enableAutoRepaint()
Turns auto repaint on so the programmer does not have to manually repaint after changing the canvas
Specified by:
enableAutoRepaint in interface DrawingCanvas

disableAutoRepaint

public void disableAutoRepaint()
Turns auto repaint off so the programmer must indicate when the canvas should be repainted.
Specified by:
disableAutoRepaint in interface DrawingCanvas

getWidth

public int getWidth()
Returns the width of the canvas
Specified by:
getWidth in interface DrawingCanvas
Overrides:
getWidth in class java.awt.Component

getHeight

public int getHeight()
Returns the height of the canvas
Specified by:
getHeight in interface DrawingCanvas
Overrides:
getHeight in class java.awt.Component

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Invoked when component has been resized.
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Invoked when component has been moved.
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Invoked when component has been shown.
Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Invoked when component has been hidden.
Specified by:
componentHidden in interface java.awt.event.ComponentListener

imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
Notifies the CanvasManager of a change in state and calls the native java method imageUpdate. Returns true if the image has fully loaded or false otherwise
Specified by:
imageUpdate in interface java.awt.image.ImageObserver
Overrides:
imageUpdate in class java.awt.Component