Class Canvas
- java.lang.Object
-
- 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.- Version:
- 2016.02.29
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 color 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.
-
-
-
Method Detail
-
getCanvas
public static Canvas getCanvas()
Factory method to get the canvas singleton object.
-
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)
-
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 shapecolor
- the color of the shapeshape
- 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
-
setForegroundColor
public void setForegroundColor(String colorString)
Set the foreground color of the Canvas.- Parameters:
newColor
- the new color for the foreground of the Canvas
-
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
-
-