lab7lib
Class SquareShape

java.lang.Object
  extended by graphics.AbstractGraphic
      extended by graphics.AbstractColorableGraphic
          extended by graphics.Rectangle
              extended by lab7lib.SquareShape
All Implemented Interfaces:
CenterLocatable, IColorable, IColorableGraphic, IGraphic, ILocatable, IRotatable, ISizeable, java.util.Observer, IUpdatable

public class SquareShape
extends Rectangle
implements IUpdatable

A square that moves when told to. Created: Wed Sep 15, 2004

Author:
Adrienne Decker

Constructor Summary
SquareShape(Window w)
          Creates a new SquareGraphic instance.
 
Method Summary
 java.lang.Integer getDx()
          Get the x component of the movement vector (the change in x).
 java.lang.Integer getDy()
          Get the y component of the movement vector (the change in y).
 Degree getOrientation()
          Gets the orientation (degree of rotation) of the shape
 Vector getVector()
          Get the vector that controls the movement for this shape.
 void setOrientation(Degree degree)
          Sets the orientation (degree of rotation) of the shape
 void setVector(Vector v)
          Change the vector that controls the movement for this shape.
 void update()
          Update the position and orientation of the fish based on the velocity.
 void update(java.util.Observable o, java.lang.Object arg)
           
 
Methods inherited from class graphics.Rectangle
actualPaint, getShape
 
Methods inherited from class graphics.AbstractColorableGraphic
getColor, paint, setColor
 
Methods inherited from class graphics.AbstractGraphic
addMouseListener, addMouseMotionListener, contains, getBounds, getCenterLocation, getContainer, getDimension, getLocation, getMouseListeners, getMouseMotionListeners, getMovement, getRotation, intersects, move, rotate, setCenterLocation, setContainer, setDimension, setLocation, setMovement, setRotation
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface graphics.IGraphic
addMouseListener, addMouseMotionListener, contains, getBounds, getContainer, getMouseListeners, getMouseMotionListeners, getMovement, intersects, setContainer, setMovement
 
Methods inherited from interface graphics.ISizeable
getDimension, setDimension
 
Methods inherited from interface graphics.CenterLocatable
getCenterLocation, setCenterLocation
 
Methods inherited from interface graphics.ILocatable
getLocation, move, setLocation
 
Methods inherited from interface graphics.IRotatable
getRotation, rotate, setRotation
 

Constructor Detail

SquareShape

public SquareShape(Window w)
Creates a new SquareGraphic instance.

Method Detail

setOrientation

public void setOrientation(Degree degree)
Sets the orientation (degree of rotation) of the shape

Parameters:
degree - The degree to which the orientation of the shape should be set.

getOrientation

public Degree getOrientation()
Gets the orientation (degree of rotation) of the shape

Returns:
The current degree of orientation.

update

public void update()
Update the position and orientation of the fish based on the velocity. If the fish hits a wall, it reverses velocity in the appropriate direction and points in the appropriate direction too.

Specified by:
update in interface IUpdatable

getVector

public Vector getVector()
Get the vector that controls the movement for this shape.

Returns:
The current movement vector.

setVector

public void setVector(Vector v)
Change the vector that controls the movement for this shape.

Parameters:
v - The new vector.

getDx

public java.lang.Integer getDx()
Get the x component of the movement vector (the change in x).

Returns:
The x component.

getDy

public java.lang.Integer getDy()
Get the y component of the movement vector (the change in y).

Returns:
The y component.

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer
Parameters:
o -
arg -
See Also:
Observer.update(java.util.Observable, java.lang.Object)