lab7lib
Class HexagonShape

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

public class HexagonShape
extends Polygon
implements IUpdatable

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

Author:
Carl Alphonce

Constructor Summary
HexagonShape(Window w)
          Creates a new instance of HexagonShape
 
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.Polygon
actualPaint, addPoint, getShape, removePoint, setDimension, setLocation
 
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, 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
 
Methods inherited from interface graphics.CenterLocatable
getCenterLocation, setCenterLocation
 
Methods inherited from interface graphics.ILocatable
getLocation, move
 
Methods inherited from interface graphics.IRotatable
getRotation, rotate, setRotation
 

Constructor Detail

HexagonShape

public HexagonShape(Window w)
Creates a new instance of HexagonShape

Parameters:
w - The window where the shape should appear.
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)