fang
Class AlternateTracker

java.lang.Object
  extended by fang.TrackerAdapter
      extended by fang.AlternateTracker
All Implemented Interfaces:
Tracker

public abstract class AlternateTracker
extends TrackerAdapter

This class provides an alternative interface to the Tracker interface. Instead of providing relative location, scaling, and rotation information, this one allow setting the absolute location, scaling, and rotation information. The class takes care of taking the differences and returning the relative values that the Tracker interface expects. To use this class, simply provide an advanceTime method which calls setScale, setLocation, or setRotation methods.

Author:
Jam Jenkins

Constructor Summary
AlternateTracker()
           
AlternateTracker(double rotation, double scale, Point2D.Double location)
          sets up the current state of the tracker
 
Method Summary
abstract  void advanceTime(double time)
          this method is called automatically every time the frame is advanced.
 double getRotationAddition()
          gets the amount to scale from the current rotation in radians
 double getScaleFactor()
          gets the amount to scale from the current scale
 Point2D.Double getTranslation()
          gets the amount to move from the current location
 void setLocation(Point2D.Double l)
          sets the next location.
 void setRotation(double r)
          sets the next rotation.
 void setRotationDegrees(double d)
          sets the next rotation.
 void setRotationRevolutions(double rev)
          sets the next rotation.
 void setScale(double s)
          sets the next scale.
 
Methods inherited from class fang.TrackerAdapter
getRotationAdditionDegrees, getRotationAdditionRadians, getRotationAdditionRevolutions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AlternateTracker

public AlternateTracker()

AlternateTracker

public AlternateTracker(double rotation,
                        double scale,
                        Point2D.Double location)
sets up the current state of the tracker

Parameters:
rotation - the rotation in radians
scale - the current scale
location - the current position
Method Detail

getRotationAddition

public final double getRotationAddition()
gets the amount to scale from the current rotation in radians

Specified by:
getRotationAddition in interface Tracker
Overrides:
getRotationAddition in class TrackerAdapter
Returns:
the amount to rotate in radians
See Also:
fang.core.Tracker#getRotationAddition()

getScaleFactor

public final double getScaleFactor()
gets the amount to scale from the current scale

Specified by:
getScaleFactor in interface Tracker
Overrides:
getScaleFactor in class TrackerAdapter
Returns:
the scaling factor
See Also:
fang.core.Tracker#getScaleFactor()

getTranslation

public final Point2D.Double getTranslation()
gets the amount to move from the current location

Specified by:
getTranslation in interface Tracker
Overrides:
getTranslation in class TrackerAdapter
Returns:
the amount to move in the horizontal and vertical direction
See Also:
fang.core.Tracker#getTranslation()

setRotation

public final void setRotation(double r)
sets the next rotation. Calling this method updates what is returned from the getRotationAddition method.

Parameters:
r - the next orientation in radians

setRotationDegrees

public final void setRotationDegrees(double d)
sets the next rotation. Calling this method updates what is returned from the getRotationAddition method.

Parameters:
d - the next orientation in degrees

setRotationRevolutions

public final void setRotationRevolutions(double rev)
sets the next rotation. Calling this method updates what is returned from the getRotationAddition method.

Parameters:
rev - the next orientation in degrees

setScale

public final void setScale(double s)
sets the next scale. Calling this method updates what is returned from the getScaleFactor method.

Parameters:
s - the next scale

setLocation

public final void setLocation(Point2D.Double l)
sets the next location. Calling this method updates what is returned from the getTranslation method.

Parameters:
l - the next location

advanceTime

public abstract void advanceTime(double time)
this method is called automatically every time the frame is advanced. The methods setScale, setLocation, and setRotation should only be called from this method and nowhere else.

Specified by:
advanceTime in interface Tracker
Specified by:
advanceTime in class TrackerAdapter
Parameters:
time - the amount of time which has passed since the last frame