edu.ou.mlfw.gui
Class Shadow2D

java.lang.Object
  extended by edu.ou.mlfw.gui.Shadow2D
Direct Known Subclasses:
CircleShadow, LineShadow, TextBoxShadow

public abstract class Shadow2D
extends java.lang.Object

Shadow2D provides a way for clients or whatever else to draw on a Shadow2DCanvas. The main consideration for a Shadow2D is that the Shadow2DCanvas be able to find its current "real" position as well as set its current "draw" position. A Shadow2D also needs to specify the width and height of a bounding box. This bounding box should but does not have to be respected by the draw method; however, respecting this boundry box can allow a specific implementation of Shadow2DCanvas to provide some convenient handling for special-case drawing conditions (for instance, wrapping a drawing around the borders of a toroidal environment).


Field Summary
static java.lang.Iterable<Shadow2D> EMPTY_ITER
           
 
Constructor Summary
Shadow2D(int width, int height)
          Initialize the shadow with a bounding box, calculate the halfwidth and halfheight
 
Method Summary
abstract  void cleanUp()
          A convenience method that gets called after all the drawings are complete and the draw position is reset to the real position.
abstract  void draw(java.awt.Graphics2D g)
          The actual drawing routine.
abstract  boolean drawMe()
          Tell the Shadow2DCanvas to draw or not draw this shadow.
 Vector2D getDrawPosition()
           
 int getHalfHeight()
           
 int getHalfWidth()
           
 int getHeight()
           
abstract  Vector2D getRealPosition()
          JSpacewarComponent uses this method in conjunction with the bounding box information to determine if the graphic needs to be redrawn to account for wrapping.
 int getWidth()
           
 void resetDrawPosition()
          Reset the drawing position to the real position.
 void setDrawPosition(Vector2D pos)
          Centers the bounding box around a particular point for drawing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ITER

public static java.lang.Iterable<Shadow2D> EMPTY_ITER
Constructor Detail

Shadow2D

public Shadow2D(int width,
                int height)
Initialize the shadow with a bounding box, calculate the halfwidth and halfheight

Parameters:
width - The width of the bounding box.
height - The height of the bounding box.
Method Detail

getWidth

public final int getWidth()
Returns:
The width of the shadow's bounding box.

getHalfWidth

public final int getHalfWidth()
Returns:
The halfwidth of the shadow's bounding box.

getHeight

public final int getHeight()
Returns:
The height of the shadow's bounding box.

getHalfHeight

public final int getHalfHeight()
Returns:
The halfheight of the shadow's bounding box

setDrawPosition

public final void setDrawPosition(Vector2D pos)
Centers the bounding box around a particular point for drawing. This should only need to be used by Shadow2DCanvav, but is available if you want it for something else. The draw position gets set back to the real position after the draw routine has finished.

Parameters:
pos - The new drawing position.

getDrawPosition

public final Vector2D getDrawPosition()
Returns:
The current drawing position.

resetDrawPosition

public final void resetDrawPosition()
Reset the drawing position to the real position.


getRealPosition

public abstract Vector2D getRealPosition()
JSpacewarComponent uses this method in conjunction with the bounding box information to determine if the graphic needs to be redrawn to account for wrapping. Real position is the position that resetDrawPosition sets the draw position to.

Returns:
The current "real" center position of the bounding box.

drawMe

public abstract boolean drawMe()
Tell the Shadow2DCanvas to draw or not draw this shadow. This does not remove the shadow, it just keeps it from being drawn.

Returns:
Whether the shadow should be drawn or not.

draw

public abstract void draw(java.awt.Graphics2D g)
The actual drawing routine.


cleanUp

public abstract void cleanUp()
A convenience method that gets called after all the drawings are complete and the draw position is reset to the real position.