fang
Class AbsoluteTransformer

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

public abstract class AbsoluteTransformer
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
AbsoluteTransformer()
           
AbsoluteTransformer(double rotation, double scale, Location2D location)
          sets up the current state of the tracker
 
Method Summary
abstract  void advanceFrame(double time)
          this method is called automatically every time the frame is advanced.
 void advanceTime(double time)
          this method is called between each frame.
 double getRotationAddition()
          gets the amount to scale from the current rotation in radians
 double getScaleFactor()
          gets the amount to scale from the current scale
 Location2D getTranslation()
          gets the amount to move from the current location
 void setLocation(Location2D l)
          sets the next location.
 void setRotationDegrees(double d)
          sets the next rotation.
 void setRotationRadians(double r)
          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

AbsoluteTransformer

public AbsoluteTransformer()

AbsoluteTransformer

public AbsoluteTransformer(double rotation,
                           double scale,
                           Location2D 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 Location2D 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()

setRotationRadians

public final void setRotationRadians(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(Location2D l)
sets the next location. Calling this method updates what is returned from the getTranslation method.

Parameters:
l - the next location

advanceFrame

public abstract void advanceFrame(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.

Parameters:
time - the amount of time which has passed since the last frame

advanceTime

public final void advanceTime(double time)
Description copied from class: TrackerAdapter
this method is called between each frame. The time parameter is the amount of time which has pased since the last frame, which is typically about 1/26 of a second.

Specified by:
advanceTime in interface Tracker
Specified by:
advanceTime in class TrackerAdapter
Parameters:
time - the amount of time passed since the last call to this method