Class SimpleDrawingCanvas

java.lang.Object
  extended by SimpleDrawingCanvas

public class SimpleDrawingCanvas
extends java.lang.Object

This class implements a simple drawing canvas that has a pre-determined size (640x480). The canvas provides a small number of simple operations and actions that can be performed upon it. Resizing of the canvas is not supported.

Author:
mb

Constructor Summary
SimpleDrawingCanvas()
          Instantiates a simple drawing canvas, which gets positioned according to the default behaviour of the layout manager of the system upon which the requestor is running (usually the top left corner).
 
Method Summary
 void clearCanvas()
          Causes the canvas to be re-initialized to blank.
 void drawAndAnimateImage(java.awt.image.BufferedImage bi)
          Causes the passed image to be drawn in a sequence of frames, at a rate of 10 frames-per-second, each one showing the image with a small horizontal and vertical displacement so as to make it appear that the image is moving in a circular motion.
 void drawAndAnimateRectangle(type.lib.Rectangle3 r)
          Causes the passed rectangle to be drawn in a sequence of frames, at a rate of 10 frames-per-second, each one showing the rectangle with a small horizontal and vertical displacement so as to make it appear that the rectangle is moving in a circular motion.
 void drawImg(java.awt.image.BufferedImage bi)
          Shows the passed image so that it will be placed in the center of the canvas.
 void drawImgAndClear(java.awt.image.BufferedImage bi)
          Same as drawImg(BufferedImage bi), but clears the screen after 500 msec
 void drawImgAndClear(java.awt.image.BufferedImage bi, int mSecDisplay)
          Same as drawImg(BufferedImage), but clears the screen after the specified number of msec
 void drawRectangle(type.lib.Rectangle3 r)
          Draws the passed rectangle so that it will be placed in the center of the canvas.
 void drawRectangleAndClear(type.lib.Rectangle3 r)
          Same as drawRectangle(Rectangle3), but clears the screen after 500 msec
 void drawRectangleAndClear(type.lib.Rectangle3 r, int mSecDisplay)
          Same as drawRectangle(Rectangle3), but clears the screen after the specified number of msec
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleDrawingCanvas

public SimpleDrawingCanvas()
Instantiates a simple drawing canvas, which gets positioned according to the default behaviour of the layout manager of the system upon which the requestor is running (usually the top left corner).

Method Detail

drawImg

public void drawImg(java.awt.image.BufferedImage bi)
Shows the passed image so that it will be placed in the center of the canvas. If the dimensions of the image exceeds the dimensions of the canvas, then only the visible portion of the image will be shown on the canvas.

Parameters:
bi - the BufferedImage to be shown

drawImgAndClear

public void drawImgAndClear(java.awt.image.BufferedImage bi)
Same as drawImg(BufferedImage bi), but clears the screen after 500 msec

Parameters:
bi - the BufferedImage to be shown

drawImgAndClear

public void drawImgAndClear(java.awt.image.BufferedImage bi,
                            int mSecDisplay)
Same as drawImg(BufferedImage), but clears the screen after the specified number of msec

Parameters:
bi - the BufferedImage to be shown
mSecDisplay - the amount of time in msec that the passed image should be shown. mSecDisplay >0

drawRectangle

public void drawRectangle(type.lib.Rectangle3 r)
Draws the passed rectangle so that it will be placed in the center of the canvas. If the dimensions of the rectangle exceeds the dimensions of the canvas, then only the visible portion of the rectangle will be drawn on the canvas.

Parameters:
r - the Rectangle3 to be drawn

drawRectangleAndClear

public void drawRectangleAndClear(type.lib.Rectangle3 r)
Same as drawRectangle(Rectangle3), but clears the screen after 500 msec

Parameters:
r - the Rectangle3 to be drawn

drawRectangleAndClear

public void drawRectangleAndClear(type.lib.Rectangle3 r,
                                  int mSecDisplay)
Same as drawRectangle(Rectangle3), but clears the screen after the specified number of msec

Parameters:
r - the Rectangle3 to be drawn
mSecDisplay - the amount of time in msec that the passed rectangle should be shown. mSecDisplay >0

clearCanvas

public void clearCanvas()
Causes the canvas to be re-initialized to blank.


drawAndAnimateRectangle

public void drawAndAnimateRectangle(type.lib.Rectangle3 r)
Causes the passed rectangle to be drawn in a sequence of frames, at a rate of 10 frames-per-second, each one showing the rectangle with a small horizontal and vertical displacement so as to make it appear that the rectangle is moving in a circular motion. If the dimensions of the rectangle exceed the dimensions of the canvas for any of the frames, then only the visible portion of the rectangle will be drawn on the canvas. The canvas is not cleared after the final frame.

Parameters:
r - the Rectangle3 to be drawn

drawAndAnimateImage

public void drawAndAnimateImage(java.awt.image.BufferedImage bi)
Causes the passed image to be drawn in a sequence of frames, at a rate of 10 frames-per-second, each one showing the image with a small horizontal and vertical displacement so as to make it appear that the image is moving in a circular motion. If the dimensions of the image exceed the dimensions of the canvas for any of the frames, then only the visible portion of the image will be shown on the canvas. The canvas is not cleared after the final frame.

Parameters:
bi - the BufferedImage to be shown