objectdraw
Interface DrawingCanvas

All Superinterfaces:
java.awt.event.ComponentListener, java.util.EventListener, java.awt.image.ImageObserver
All Known Implementing Classes:
AWTDrawingCanvas, AWTFrameCanvas, FrameCanvas, JDrawingCanvas

public interface DrawingCanvas
extends java.awt.image.ImageObserver, java.awt.event.ComponentListener

The DrawingCanvas interface describes the methods that are available on a drawing canvas.

Version:
1.1.2 released July 2006

Field Summary
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
 void addComponentListener(java.awt.event.ComponentListener l)
          Requests that the specified ComponentListener be notified when the DrawingCanvas is hidden, shown, resized or moved.
 void addKeyListener(java.awt.event.KeyListener l)
          Requests that the specified KeyListener be notified when keystokes occur.
 void addMouseListener(java.awt.event.MouseListener l)
          Requests that the specified MouseListener be notified when the mouse is clicked, pressed, or released.
 void addMouseMotionListener(java.awt.event.MouseMotionListener l)
          Requests that the specified MouseMotionListener be notified when the mouse is moved or dragged in the DrawingCanvas.
 void clear()
          Removes all objects from the DrawingCanvas.
 java.awt.Image createImage(int width, int height)
          Creates an off-screen drawable image to be used for double buffering.
 void disableAutoRepaint()
          Requests that the DrawingCanvas not be automatically repainted after every change.
 void enableAutoRepaint()
          Requests that the DrawingCanvas to be automatically repainted after every change without specifically calling repaint().
 objectdraw.CanvasManager getCanvasContent()
          Retrieves the CanvasManager that keeps track of all of the Drawable objects currently associated with this DrawingCanvas.
 DrawableIterator getDrawableIterator()
          Creates and returns an iterator of all the objects on the DrawingCanvas
 java.awt.Graphics getGraphics()
          Get a Graphic object associated with this DrawingCanvas.
 int getHeight()
          Determine the current height of a DrawingCanvas.
 java.awt.Dimension getSize()
          Determine the current size of a DrawingCanvas.
 int getWidth()
          Determine the current width of a DrawingCanvas.
 boolean prepareImage(java.awt.Image im, java.awt.image.ImageObserver observer)
          Prepares an image for rendering on the DrawingCanvas.
 void repaint()
          Requests that the contents of the canvas be redrawn.
 void requestFocus()
          Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window.
 boolean requestFocusInWindow()
          Requests that this Component get the input focus.
 
Methods inherited from interface java.awt.image.ImageObserver
imageUpdate
 
Methods inherited from interface java.awt.event.ComponentListener
componentHidden, componentMoved, componentResized, componentShown
 

Method Detail

getCanvasContent

public objectdraw.CanvasManager getCanvasContent()
Retrieves the CanvasManager that keeps track of all of the Drawable objects currently associated with this DrawingCanvas.

Returns:
the DrawingCanvas' manager

clear

public void clear()
Removes all objects from the DrawingCanvas.


repaint

public void repaint()
Requests that the contents of the canvas be redrawn. It is not necessary to invoke this method unless disableAutoRepaint() has been invoked. In its default state, a DrawingCanvas redraws the display automatically after any change occurs.


enableAutoRepaint

public void enableAutoRepaint()
Requests that the DrawingCanvas to be automatically repainted after every change without specifically calling repaint(). This is the default setting.


disableAutoRepaint

public void disableAutoRepaint()
Requests that the DrawingCanvas not be automatically repainted after every change. When this mode is enabled, an explicit call to repaint() must be made in order to see changes made to the objects displayed on the DrawingCanvas. By default, auto-repaint is enabled in a newly constructed DrawingCanvas.


getGraphics

public java.awt.Graphics getGraphics()
Get a Graphic object associated with this DrawingCanvas.

Returns:
a Graphics object representing the graphics currently on the DrawingCanvas.

prepareImage

public boolean prepareImage(java.awt.Image im,
                            java.awt.image.ImageObserver observer)
Prepares an image for rendering on the DrawingCanvas. The image data is downloaded asynchronously in another thread and the appropriate screen representation of the image is generated.

Parameters:
im - the Image to be prepared
observer - the ImageObserver to be notified when Image is ready
Returns:
true if the image has already been fully prepared; false otherwise

getSize

public java.awt.Dimension getSize()
Determine the current size of a DrawingCanvas.

Returns:
a Dimension referring to the size of the DrawingCanvas.

getWidth

public int getWidth()
Determine the current width of a DrawingCanvas.

Returns:
an int referring to the width of the Drawingcanvas.

getHeight

public int getHeight()
Determine the current height of a DrawingCanvas.

Returns:
an int referring to the height of the Drawingcanvas.

createImage

public java.awt.Image createImage(int width,
                                  int height)
Creates an off-screen drawable image to be used for double buffering.

Parameters:
width - - the specified width
height - - the specified height
Returns:
an off-screen drawable image, which can be used for double buffering. The return value may be null if the component is not displayable. This will always happen if GraphicsEnvironment.isHeadless() returns true.

addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Requests that the specified MouseListener be notified when the mouse is clicked, pressed, or released.

Parameters:
l - the listener object to be notified

addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener l)
Requests that the specified MouseMotionListener be notified when the mouse is moved or dragged in the DrawingCanvas.

Parameters:
l - the listener object to be notified

addComponentListener

public void addComponentListener(java.awt.event.ComponentListener l)
Requests that the specified ComponentListener be notified when the DrawingCanvas is hidden, shown, resized or moved.

Parameters:
l - the listener object to be notified

addKeyListener

public void addKeyListener(java.awt.event.KeyListener l)
Requests that the specified KeyListener be notified when keystokes occur.

Parameters:
l - the listener object to be notified

requestFocusInWindow

public boolean requestFocusInWindow()
Requests that this Component get the input focus.

Returns:
whether canvas is likely to gain focus

requestFocus

public void requestFocus()
Requests that this Component get the input focus, and that this Component's top-level ancestor become the focused Window.


getDrawableIterator

public DrawableIterator getDrawableIterator()
Creates and returns an iterator of all the objects on the DrawingCanvas

Returns:
an iterator of all of the CanvasManager's objects