fang
Class CompositeTracker

java.lang.Object
  extended by fang.Tracker
      extended by fang.CompositeTracker

public final class CompositeTracker
extends Tracker

This class combines several trackers into a single tracker by composing the scaling, rotating, and translating. Since these operations are commutative, they compose seamlessly.


Field Summary
 
Fields inherited from class fang.Tracker
random
 
Constructor Summary
CompositeTracker(Tracker... tracker)
          makes the CompositeTracker and adds all of the arguments to the list of trackers
 
Method Summary
 void addTracker(Tracker tracker)
          adds one tracker to compose.
 void advanceTime(double timePassed)
          Advancing the time of all the trackers contained in this tracker.
 Tracker[] getAllTrackers()
          gets all of the Trackers in this collection of Trackers
 double getRotationAddition()
          composes the trackers' rotation additions
 double getScaleFactor()
          composes the trackers' scaling factors
 Coordinate getTranslation()
          composes the trackers' translations
 void removeTracker(Tracker tracker)
          removes the tracker from the list of trackers composed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeTracker

public CompositeTracker(Tracker... tracker)
makes the CompositeTracker and adds all of the arguments to the list of trackers

Parameters:
tracker - the trackers to compose
Method Detail

getAllTrackers

public Tracker[] getAllTrackers()
gets all of the Trackers in this collection of Trackers

Returns:
all the trackers in this group of trackers

addTracker

public void addTracker(Tracker tracker)
adds one tracker to compose. The tracker being added must create a cycle of Trackers. For example, adding this tracker to itself would cause infinite recursion. Be sure to avoid more complex cyclic structures as well. CompositeTracker

Parameters:
tracker - the tracker to compose

removeTracker

public void removeTracker(Tracker tracker)
removes the tracker from the list of trackers composed. Trying to remove non-exitent trackers is ignored.

Parameters:
tracker - the tracker to remove

getTranslation

public Coordinate getTranslation()
composes the trackers' translations

Overrides:
getTranslation in class Tracker
Returns:
the sum of the translations

getScaleFactor

public double getScaleFactor()
composes the trackers' scaling factors

Overrides:
getScaleFactor in class Tracker
Returns:
the product of all scale factors

getRotationAddition

public double getRotationAddition()
composes the trackers' rotation additions

Overrides:
getRotationAddition in class Tracker
Returns:
the sum of all rotation additions

advanceTime

public void advanceTime(double timePassed)
Advancing the time of all the trackers contained in this tracker.

Overrides:
advanceTime in class Tracker
Parameters:
timePassed - the duration of time since the last call to advanceTime