javalib.worldcanvas
Class MyCanvas

java.lang.Object
  extended by javalib.worldcanvas.MyCanvas

public abstract class MyCanvas
extends Object

Abstract Canvas - allows the drawing of shapes, lines, and text in the window of the given size, window closing and re-opening.

Since:
July 12 2007, August 2, 2007, October 19, 2009
Author:
Viera K. Proulx

Field Summary
protected  int height
          the height of the panel
protected  int width
          the width of the panel
 
Constructor Summary
MyCanvas(int width, int height)
          Construct a MyCanvas with the given width and height.
 
Method Summary
abstract  void clear()
          Clear the canvas before painting the next scene
abstract  boolean drawImage(ImageMaker image, Posn nw)
          Draw the image provided by the ImageMaker on the Canvas at the given NW corner
abstract  boolean drawImage(String fileName, Posn nw)
          Draw the image in the specified file at the location of the given NW corner
abstract  boolean drawImage(WorldImage image)
          Draw the image on the Canvas at its pinhole location.
abstract  Graphics2D getBufferGraphics()
          Returns a Graphics2D object that permits painting to the internal buffered image for this canvas.
 String toIndentedString(String indent)
          Produce an indented String representation of this Canvas
 String toString()
          Produce a String representation of this Canvas
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

height

protected int height
the height of the panel


width

protected int width
the width of the panel

Constructor Detail

MyCanvas

public MyCanvas(int width,
                int height)

Construct a MyCanvas with the given width and height.

Parameters:
width - the width of the panel
height - the height of the panel
Method Detail

clear

public abstract void clear()
Clear the canvas before painting the next scene


drawImage

public abstract boolean drawImage(ImageMaker image,
                                  Posn nw)
Draw the image provided by the ImageMaker on the Canvas at the given NW corner

Parameters:
image - the image maker for the image file
nw - the NW corner for the image placement

drawImage

public abstract boolean drawImage(String fileName,
                                  Posn nw)
Draw the image in the specified file at the location of the given NW corner

Parameters:
fileName - the name of the image file
nw - the NW corner for the image placement

drawImage

public abstract boolean drawImage(WorldImage image)
Draw the image on the Canvas at its pinhole location.

Parameters:
image - the image to be drawn
Returns:
true

getBufferGraphics

public abstract Graphics2D getBufferGraphics()

Returns a Graphics2D object that permits painting to the internal buffered image for this canvas.


toIndentedString

public String toIndentedString(String indent)
Produce an indented String representation of this Canvas

Parameters:
indent - the desired indentation: ignored, because we only produce one line of text.

toString

public String toString()
Produce a String representation of this Canvas

Overrides:
toString in class Object