fang
Class CompositeTracker

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

public final class CompositeTracker
extends Object
implements 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.

Author:
Jam Jenkins

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 advance()
          does nothing.
 void advanceTime(double timePassed)
          does nothing.
 boolean containsTracker(Tracker t)
           
 Tracker[] getAllTrackers()
          gets all of the Trackers in this collection of Trackers
 Tracker[] getFlatContents()
           
 double getRotationAddition()
          composes the trackers' rotation additions
 double getScaleFactor()
          composes the trackers' scaling factors
 Point2D.Double getTranslation()
          composes the trackers' translations
 void removeAllTrackers()
           
 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 Point2D.Double getTranslation()
composes the trackers' translations

Specified by:
getTranslation in interface Tracker
Returns:
the sum of the translations

getScaleFactor

public double getScaleFactor()
composes the trackers' scaling factors

Specified by:
getScaleFactor in interface Tracker
Returns:
the product of all scale factors

getRotationAddition

public double getRotationAddition()
composes the trackers' rotation additions

Specified by:
getRotationAddition in interface Tracker
Returns:
the sum of all rotation additions

advanceTime

public void advanceTime(double timePassed)
does nothing. The AnimationCanvas takes care of advancing the time of all the trackers contained in this tracker.

Specified by:
advanceTime in interface Tracker
Parameters:
timePassed - the duration of time since the last call to advanceTime

advance

public void advance()
does nothing. The AnimationCanvas takes care of advancing the time of all the trackers contained in this tracker.


removeAllTrackers

public void removeAllTrackers()

containsTracker

public boolean containsTracker(Tracker t)

getFlatContents

public Tracker[] getFlatContents()