objectdraw
Interface DrawingCanvas

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

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

The DrawingCanvas is an interface which defines which methods must be included in an actual DrawingCanvas object. With this interface the other classes of the objectdraw package do not need to know what type of DrawingCanvas is being used, either an AWT or J DrawingCanvas.


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)
          Enables the DrawingCanvas to be able to listen to the component, and react to its movement and other actions.
 void addKeyListener(java.awt.event.KeyListener l)
          Enables the DrawingCanvas to be able to listen to the keyboard.
 void addMouseListener(java.awt.event.MouseListener l)
          Enables the DrawingCanvas to be able to listen for mouse clicks, presses, and releases.
 void addMouseMotionListener(java.awt.event.MouseMotionListener one)
          Enables the DrawingCanvas to be able to listen for mouse motion.
 void addToCanvas(Drawable d)
          Add the Drawable d to the canvas
 void clear()
          Clears the DrawingCanvas of all objects.
 java.awt.Image createImage(int width, int height)
          Creates an off-screen drawable image to be used for double buffering.
 void disableAutoRepaint()
          Disables the auto-mechanism of the DrawingCanvas so that an explicit call to repaint() must be made in order to see the changes.
 void enableAutoRepaint()
          Enables the DrawingCanvas to be automatically repainted after every change without specifically calling repaint().
 java.awt.Color getBackground()
          Returns the color of the background of the DrawingCanvas.
 CanvasManager getCanvasContent()
          Retrieves an instance of the CanvasContainer class so that the methods of it can be used without the student/package user accessing that class directly.
 java.awt.Color getForeground()
          Returns the color of the foreground of the DrawingCanvas.
 java.awt.Graphics getGraphics()
          Returns a Graphics object representing the graphics currently on the DrawingCanvas.
 int getHeight()
          Returns an int referring to the height of the Drawingcanvas.
 java.awt.Dimension getSize()
          Returns a Dimension referring to the size of the DrawingCanvas.
 int getWidth()
          Returns an int referring to the width of the Drawingcanvas.
 boolean prepareImage(java.awt.Image i, java.awt.image.ImageObserver observer)
          Prepares an image for rendering on the DrawingCanvas.
 void removeFromCanvas(Drawable d)
          Remove the Drawable d from the canvas
 void repaint()
          Calls the system repaint() method which in turn schedules a call to paint.
 void setBackground(java.awt.Color c)
          Sets the background of the DrawingCanvas to Color c.
 void setForeground(java.awt.Color c)
          Sets the foreground of the DrawingCanvas to Color c.
 
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 CanvasManager getCanvasContent()
Retrieves an instance of the CanvasContainer class so that the methods of it can be used without the student/package user accessing that class directly.

addToCanvas

public void addToCanvas(Drawable d)
Add the Drawable d to the canvas

removeFromCanvas

public void removeFromCanvas(Drawable d)
Remove the Drawable d from the canvas

clear

public void clear()
Clears the DrawingCanvas of all objects.

repaint

public void repaint()
Calls the system repaint() method which in turn schedules a call to paint.

enableAutoRepaint

public void enableAutoRepaint()
Enables the DrawingCanvas to be automatically repainted after every change without specifically calling repaint().

disableAutoRepaint

public void disableAutoRepaint()
Disables the auto-mechanism of the DrawingCanvas so that an explicit call to repaint() must be made in order to see the changes.

getGraphics

public java.awt.Graphics getGraphics()
Returns a Graphics object representing the graphics currently on the DrawingCanvas.

prepareImage

public boolean prepareImage(java.awt.Image i,
                            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:
i - the Image to be prepared
observer - the ImageObserver to be notified when Image is ready

getBackground

public java.awt.Color getBackground()
Returns the color of the background of the DrawingCanvas.

getForeground

public java.awt.Color getForeground()
Returns the color of the foreground of the DrawingCanvas.

setBackground

public void setBackground(java.awt.Color c)
Sets the background of the DrawingCanvas to Color c.

setForeground

public void setForeground(java.awt.Color c)
Sets the foreground of the DrawingCanvas to Color c.

getSize

public java.awt.Dimension getSize()
Returns a Dimension referring to the size of the DrawingCanvas.

getWidth

public int getWidth()
Returns an int referring to the width of the Drawingcanvas.

getHeight

public int getHeight()
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.

addMouseListener

public void addMouseListener(java.awt.event.MouseListener l)
Enables the DrawingCanvas to be able to listen for mouse clicks, presses, and releases.

addMouseMotionListener

public void addMouseMotionListener(java.awt.event.MouseMotionListener one)
Enables the DrawingCanvas to be able to listen for mouse motion.

addComponentListener

public void addComponentListener(java.awt.event.ComponentListener l)
Enables the DrawingCanvas to be able to listen to the component, and react to its movement and other actions.

addKeyListener

public void addKeyListener(java.awt.event.KeyListener l)
Enables the DrawingCanvas to be able to listen to the keyboard.