ch.aplu.turtle
Class TurtleRenderer

java.lang.Object
  |
  +--ch.aplu.turtle.TurtleRenderer
All Implemented Interfaces:
java.awt.image.ImageObserver

public class TurtleRenderer
extends java.lang.Object
implements java.awt.image.ImageObserver

This class is responsible for creating and choosing the correct Turtle picture.


Field Summary
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TurtleRenderer(Turtle turtle)
           
 
Method Summary
 java.awt.Image currentImage()
          Return the current image.
 boolean imageChanged(double angle)
          Tell whether the image has changed.
 boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
          As an image stays unchanged, there's no need to ever update it.
 void init(TurtleFactory factory, int resolution)
          Create the images.
 void paint(double x, double y)
          This method is responsible for painting the turtle onto the playground at (x, y).
 void paint(double x, double y, java.awt.Graphics g)
          This method is responsible for painting the Turtle at (x, y).
 void paint(java.awt.geom.Point2D.Double p)
          This method is responsible for painting the turtle onto the playground at p.
 void paint(java.awt.geom.Point2D.Double p, java.awt.Graphics g)
          This method is responsible for painting the Turtle at p.
 void setAngle(double angle)
          Set the current image to the one corresponding to the angle angle.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TurtleRenderer

public TurtleRenderer(Turtle turtle)
Method Detail

currentImage

public java.awt.Image currentImage()
Return the current image.


imageChanged

public boolean imageChanged(double angle)
Tell whether the image has changed.


imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
As an image stays unchanged, there's no need to ever update it. So this method returns always false. For further information cf. java.awt.image.ImageObserver.

Specified by:
imageUpdate in interface java.awt.image.ImageObserver
See Also:
ImageObserver.imageUpdate(java.awt.Image, int, int, int, int, int)

init

public void init(TurtleFactory factory,
                 int resolution)
Create the images. There are resolution images (i.e. two subsequent images contain an angle of 2π/ or 360/resolution degrees).


paint

public final void paint(double x,
                        double y)
This method is responsible for painting the turtle onto the playground at (x, y).


paint

public final void paint(double x,
                        double y,
                        java.awt.Graphics g)
This method is responsible for painting the Turtle at (x, y).
The Graphics argument tells where to paint.


paint

public final void paint(java.awt.geom.Point2D.Double p)
This method is responsible for painting the turtle onto the playground at p.


paint

public void paint(java.awt.geom.Point2D.Double p,
                  java.awt.Graphics g)
This method is responsible for painting the Turtle at p.
The Graphics argument tells where to paint.


setAngle

public void setAngle(double angle)
Set the current image to the one corresponding to the angle angle.