edu.kzoo.grid.display
Class RotatedDecorator

java.lang.Object
  |
  +--edu.kzoo.grid.display.RotatedDecorator
All Implemented Interfaces:
DisplayDecorator

public class RotatedDecorator
extends java.lang.Object
implements DisplayDecorator

Grid Display Package:
A RotatedDecorator will allow a display to change as the object it is associated with changes direction. The GridObject must have a direction method that returns a Direction object in order for the decorator to work.

Version:
28 July 2004
Author:
Joel Booth

Constructor Summary
RotatedDecorator(Direction d)
          Construct a new RotatedDecorator that can be added to a ScaledDisplay.
 
Method Summary
static void adjustForDirection(GridObject obj, java.awt.Graphics2D g2)
          Adjusts the graphics system for drawing an object with direction.
 void decorate(GridObjectDisplay sd, GridObject obj, java.awt.Component comp, java.awt.Graphics2D g2)
          Apply the rotating aspect of the decoration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RotatedDecorator

public RotatedDecorator(Direction d)
Construct a new RotatedDecorator that can be added to a ScaledDisplay.

Parameters:
d - The origrinal direction the object is facing
Method Detail

decorate

public void decorate(GridObjectDisplay sd,
                     GridObject obj,
                     java.awt.Component comp,
                     java.awt.Graphics2D g2)
Apply the rotating aspect of the decoration. It is called from the class that has added the decorator.

Specified by:
decorate in interface DisplayDecorator

adjustForDirection

public static void adjustForDirection(GridObject obj,
                                      java.awt.Graphics2D g2)
Adjusts the graphics system for drawing an object with direction. (Precondition: obj has a direction method.)

Parameters:
obj - object we want to draw
g2 - drawing surface