public class RotatedDecorator extends java.lang.Object implements DisplayDecorator
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.Constructor and Description |
---|
RotatedDecorator(Direction d)
Construct a new
RotatedDecorator that can be
added to a ScaledDisplay . |
Modifier and Type | Method and Description |
---|---|
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.
|
public RotatedDecorator(Direction d)
RotatedDecorator
that can be
added to a ScaledDisplay
.d
- The origrinal direction the object is facingpublic void decorate(GridObjectDisplay sd, GridObject obj, java.awt.Component comp, java.awt.Graphics2D g2)
decorate
in interface DisplayDecorator
public static void adjustForDirection(GridObject obj, java.awt.Graphics2D g2)
obj
has a direction
method.)obj
- object we want to drawg2
- drawing surface