objectdraw
Interface DrawingCanvas

All Superinterfaces:
ComponentListener, EventListener, ImageObserver
All Known Implementing Classes:
AWTDrawingCanvas, AWTFrameCanvas, FrameCanvas, JDrawingCanvas

public interface DrawingCanvas
extends ImageObserver, ComponentListener

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

Version:
1.1.1 released February 2005

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

Method Detail

addComponentListener

void addComponentListener(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

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

Parameters:
l - the listener object to be notified

addMouseListener

void addMouseListener(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

void addMouseMotionListener(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

clear

void clear()
Removes all objects from the DrawingCanvas.


createImage

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.

disableAutoRepaint

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.


enableAutoRepaint

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


getCanvasContent

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

Returns:
the DrawingCanvas' manager

getDrawableIterator

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

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

getGraphics

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

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

getHeight

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

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

getSize

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

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

getWidth

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

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

prepareImage

boolean prepareImage(Image im,
                     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

repaint

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.


requestFocus

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


requestFocusInWindow

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

Returns:
whether canvas is likely to gain focus

setBackground

void setBackground(Color backgroundColor)
Sets the background color of the canvas.

Parameters:
backgroundColor - -- new background color

setForeground

void setForeground(Color foregroundColor)
Sets the foreground color of the canvas

Parameters:
foregroundColor - - new foreground color