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 SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddraw(Object referenceObject, String color, Shape shape)Draw a given shape onto the canvas.voiderase(Object referenceObject)Erase a given shape's from the screen.static CanvasgetCanvas()Factory method to get the canvas singleton object.voidsetForegroundColor(String colorString)Set the foreground color of the Canvas.voidsetVisible(boolean visible)Set the canvas visibility and brings canvas to the front of screen when made visible.voidwait(int milliseconds)Wait for a specified number of milliseconds before finishing.
 
- 
- 
- 
Method Detail- 
getCanvaspublic static Canvas getCanvas() Factory method to get the canvas singleton object.
 - 
setVisiblepublic 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)
 
 - 
drawpublic 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
 
 - 
erasepublic void erase(Object referenceObject) Erase a given shape's from the screen.- Parameters:
- referenceObject- the shape object to be erased
 
 - 
setForegroundColorpublic void setForegroundColor(String colorString) Set the foreground color of the Canvas.- Parameters:
- newColor- the new color for the foreground of the Canvas
 
 - 
waitpublic 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
 
 
- 
 
-