gizmoball.board
Class RotatingGizmo

java.lang.Object
  extended by gizmoball.board.Gizmo
      extended by gizmoball.board.RotatingGizmo

public class RotatingGizmo
extends Gizmo

This class represents a rotating gizmo, such as a flipper, that extends the abstract Gizmo class. A rotating gizmo has an angular velocity, a range of angles in which it can rotate, a center of rotation, and an enclosing polygon which represents the polygon that the flipper occupies at different times during its rotation.

Author:
Michal Wexler

Field Summary
 
Fields inherited from class gizmoball.board.Gizmo
color, connections, name, reverseConnections
 
Constructor Summary
RotatingGizmo(java.lang.String name, java.awt.Color color, Shape shape, double rotatingVel, double currentRotVel, Polygon enclosingPoly, Vect centerOfRotation, Angle maxAngle, Angle currentAngle)
          Constructs a RotatingGizmo object
 
Method Summary
 void action()
          executes the action of the rotating gizmo which changes the mode of the flipper from stationary to rotating and vice versa.
 double getAngularVelocity()
          returns the current angular velocity.
 Vect getCenterOfRotation()
          returns the center of rotation of the gizmo.
 Angle getCurrentAngle()
          returns the current angle that the rotating gizmo is at.
 Polygon getEnclosingPolygon()
          returns the enclosing polygon of the gizmo
 Angle getMaxAngle()
          returns the max angle that the gizmo can be rotated by.
 void rotateAroundCenter(double dt)
          rotates the gizmo around its center of rotation.
 double timeToNextStop()
          The expected time until the gizmo will stop again.
 
Methods inherited from class gizmoball.board.Gizmo
getColor, getName, getShape, getTriggeredGizmos, getTriggeringGizmos, setColor, triggerConnections
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RotatingGizmo

public RotatingGizmo(java.lang.String name,
                     java.awt.Color color,
                     Shape shape,
                     double rotatingVel,
                     double currentRotVel,
                     Polygon enclosingPoly,
                     Vect centerOfRotation,
                     Angle maxAngle,
                     Angle currentAngle)
Constructs a RotatingGizmo object

Parameters:
name - the name of the gizmo
color - the color of the gizmo
shape - the shape of the gizmo
rotatingVel - the rotating velocity
enclosingPoly - the enclosing shape of the gizmo
centerOfRotation - the center of rotation
maxAngle - the maximus angle that the RotatingGizmo can rotate by
Method Detail

timeToNextStop

public double timeToNextStop()
The expected time until the gizmo will stop again. If it is not moving, inifinity is returned.

Returns:
the time until the gizmo will stop again

getEnclosingPolygon

public Polygon getEnclosingPolygon()
returns the enclosing polygon of the gizmo

Returns:
the enclosing polygon

getAngularVelocity

public double getAngularVelocity()
returns the current angular velocity.

Returns:
the current angular velocity

getCurrentAngle

public Angle getCurrentAngle()
returns the current angle that the rotating gizmo is at.

Returns:
the current angle

getMaxAngle

public Angle getMaxAngle()
returns the max angle that the gizmo can be rotated by.

Returns:
the max angle

getCenterOfRotation

public Vect getCenterOfRotation()
returns the center of rotation of the gizmo.

Returns:
the center of rotation

rotateAroundCenter

public void rotateAroundCenter(double dt)
rotates the gizmo around its center of rotation.

Parameters:
dt - how long the rotating gizmo is rotated for

action

public void action()
executes the action of the rotating gizmo which changes the mode of the flipper from stationary to rotating and vice versa.

Overrides:
action in class Gizmo