Class Canvas

java.lang.Object
  extended by Canvas

public class Canvas
extends Object

Canvas is a class to allow for simple graphical drawing on a canvas. This is a modification of the general purpose Canvas, specially made for the BlueJ "shapes" example.


Method Summary
 void draw(Object referenceObject, String color, Shape shape)
          Draw a given shape onto the canvas.
 void erase(Object referenceObject)
          Erase a given shape's from the screen.
static Canvas getCanvas()
          Factory method to get the canvas singleton object.
 void setForegroundColor(String colorString)
          Set the foreground colour of the Canvas.
 void setVisible(boolean visible)
          Set the canvas visibility and brings canvas to the front of screen when made visible.
 void wait(int milliseconds)
          Wait for a specified number of milliseconds before finishing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

draw

public void draw(Object referenceObject,
                 String color,
                 Shape shape)
Draw a given shape onto the canvas.

Parameters:
referenceObject - an object to define identity for this shape
color - the color of the shape
shape - the shape object to be drawn on the canvas

erase

public void erase(Object referenceObject)
Erase a given shape's from the screen.

Parameters:
referenceObject - the shape object to be erased

getCanvas

public static Canvas getCanvas()
Factory method to get the canvas singleton object.


setForegroundColor

public void setForegroundColor(String colorString)
Set the foreground colour of the Canvas.

Parameters:
newColour - the new colour for the foreground of the Canvas

setVisible

public void setVisible(boolean visible)
Set the canvas visibility and brings canvas to the front of screen when made visible. This method can also be used to bring an already visible canvas to the front of other windows.

Parameters:
visible - boolean value representing the desired visibility of the canvas (true or false)

wait

public void wait(int milliseconds)
Wait for a specified number of milliseconds before finishing. This provides an easy way to specify a small delay which can be used when producing animations.

Parameters:
milliseconds - the number