objectdraw
Class CanvasManager

java.lang.Object
  |
  +--objectdraw.CanvasManager

public class CanvasManager
extends java.lang.Object

CanvasManager contains the methods which act on the actual canvas. In order to enable swing compatabliltiy the DrawingCanvas is now just a shell which is tailored to swing or awt and then calls the methods of this class when necessary. The actual painting and drawing and maintaince of the Vector of objects takes place in this class.


Field Summary
static java.awt.Dimension DEFAULT_PREFERRED_SIZE
          The canvas' default preferred dimensions.
 
Constructor Summary
CanvasManager(java.awt.Dimension size, DrawingCanvas c)
          Creates a CanvasManager
 
Method Summary
 void add(DrawableInterface object)
          Adds a new object on top of existing objects.
 void addToCanvas(Drawable d)
          If the Drawable d is not already on the canvas or if the canvas is null it sets d's canvas to this one and adds d to it.
 void clear()
          Clears the Vector of all objects and tells the Container that the state has changed.
 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.
 DrawableIterator getObjectIterator()
          Creates and returns an iterator of all the objects in the CanvasManager
 void paint(java.awt.Graphics g)
          Paints the canvas.
 void redraw()
          Redraws all objects on the canvas that are not currently hidden.
 void remove(DrawableInterface object)
          Removes an object.
 void removeFromCanvas(Drawable d)
          Removes the Drawable d from the Drawable d.
 void repaint()
          Tells the DrawingCanvas to repaint().
 void sendObjectBackward(DrawableInterface object)
          Sends an object backward.
 void sendObjectForward(DrawableInterface object)
          Sends an object forward.
 void sendObjectToBack(DrawableInterface object)
          Sends an object to the back.
 void sendObjectToFront(DrawableInterface object)
          Sends an object to the front.
 void setStateChanged()
          When invoked sets the stateChanged boolean to true and calls repaint() if enabled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PREFERRED_SIZE

public static final java.awt.Dimension DEFAULT_PREFERRED_SIZE
The canvas' default preferred dimensions.
Constructor Detail

CanvasManager

public CanvasManager(java.awt.Dimension size,
                     DrawingCanvas c)
Creates a CanvasManager
Method Detail

addToCanvas

public void addToCanvas(Drawable d)
If the Drawable d is not already on the canvas or if the canvas is null it sets d's canvas to this one and adds d to it.

removeFromCanvas

public void removeFromCanvas(Drawable d)
Removes the Drawable d from the Drawable d.

add

public void add(DrawableInterface object)
Adds a new object on top of existing objects.
Parameters:
object - the new object

remove

public void remove(DrawableInterface object)
Removes an object.
Parameters:
object - the object to be removed

clear

public void clear()
Clears the Vector of all objects and tells the Container that the state has changed.

setStateChanged

public void setStateChanged()
When invoked sets the stateChanged boolean to true and calls repaint() if enabled.

paint

public void paint(java.awt.Graphics g)
Paints the canvas.
Parameters:
g - the canvas' graphics context.

redraw

public void redraw()
Redraws all objects on the canvas that are not currently hidden.

repaint

public void repaint()
Tells the DrawingCanvas to repaint().

enableAutoRepaint

public void enableAutoRepaint()
Turns auto repaint on so the programmer does not have to manually repaint after changing the canvas.

disableAutoRepaint

public void disableAutoRepaint()
Turns auto repaint off so the programmer must indicate when the canvas should be repainted.

sendObjectToFront

public void sendObjectToFront(DrawableInterface object)
Sends an object to the front.
Parameters:
object - the object

sendObjectToBack

public void sendObjectToBack(DrawableInterface object)
Sends an object to the back.
Parameters:
object - the object

sendObjectForward

public void sendObjectForward(DrawableInterface object)
Sends an object forward. This means that it is being moved to the back of the vector
Parameters:
object - the object

sendObjectBackward

public void sendObjectBackward(DrawableInterface object)
Sends an object backward. This means that it is being moved to the front of the vector
Parameters:
object - the object

getObjectIterator

public DrawableIterator getObjectIterator()
Creates and returns an iterator of all the objects in the CanvasManager
Returns:
an iterator of all of the CanvasManager's objects