com.threerings.media.util
Class PathSequence

java.lang.Object
  extended by com.threerings.media.util.PathSequence
All Implemented Interfaces:
Path

public class PathSequence
extends Object
implements Path

Used to create a path that is a sequence of several other paths.


Field Summary
protected  Path _curPath
          The current path we're pathing.
protected  long _lastInit
          The timestamp at which we last inited a path.
protected  Pathable _pable
          The pathable we're duping bigtime.
protected  Pathable _pableRep
          A fake pathable that we pass to the subpaths.
protected  List<Path> _paths
          The list of paths.
 
Constructor Summary
PathSequence(List<Path> paths)
          Construct a path sequence with the list of paths.
PathSequence(Path first, Path second)
          Conveniently construct a path sequence with the two specified paths.
 
Method Summary
 void addPath(Path path)
          Add a new path to the end of our current list.
 void fastForward(long timeDelta)
          This is called if the pathable is paused for some length of time and then unpaused.
 void init(Pathable pable, long tickStamp)
          Called once to let the path prepare itself for the process of animating the supplied pathable.
protected  void initNextPath(long initStamp, long tickStamp)
          Initialize and start the next path in the sequence.
 void paint(Graphics2D gfx)
          Paint this path on the screen (used for debugging purposes only).
 boolean tick(Pathable pable, long tickStamp)
          Called to request that this path update the position of the specified pathable based on the supplied timestamp information.
 void wasRemoved(Pathable pable)
          When a path is removed from a pathable, whether that is because the path was completed or because it was replaced by another path, this method will be called to let the path know that it is no longer associated with this pathable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_paths

protected List<Path> _paths
The list of paths.


_lastInit

protected long _lastInit
The timestamp at which we last inited a path.


_curPath

protected Path _curPath
The current path we're pathing.


_pable

protected Pathable _pable
The pathable we're duping bigtime.


_pableRep

protected Pathable _pableRep
A fake pathable that we pass to the subpaths.

Constructor Detail

PathSequence

public PathSequence(Path first,
                    Path second)
Conveniently construct a path sequence with the two specified paths.


PathSequence

public PathSequence(List<Path> paths)
Construct a path sequence with the list of paths. Note: Paths may be added to the end of the list while the pathable is still traversing earlier paths!

Method Detail

addPath

public void addPath(Path path)
Add a new path to the end of our current list.


init

public void init(Pathable pable,
                 long tickStamp)
Description copied from interface: Path
Called once to let the path prepare itself for the process of animating the supplied pathable. Path users should also call Path.tick(com.threerings.media.util.Pathable, long) after Path.init(com.threerings.media.util.Pathable, long) with the same initialization timestamp.

Specified by:
init in interface Path

tick

public boolean tick(Pathable pable,
                    long tickStamp)
Description copied from interface: Path
Called to request that this path update the position of the specified pathable based on the supplied timestamp information. A path should record its initial timestamp and determine the progress of the pathable along the path based on the time elapsed since the pathable began down the path.

Specified by:
tick in interface Path
Parameters:
pable - the pathable whose position should be updated.
tickStamp - the timestamp associated with this frame.
Returns:
true if the pathable's position was updated, false if the path determined that the pathable should not move at this time.

fastForward

public void fastForward(long timeDelta)
Description copied from interface: Path
This is called if the pathable is paused for some length of time and then unpaused. Paths should adjust any time stamps they are maintaining internally by the delta so that time maintains the illusion of flowing smoothly forward.

Specified by:
fastForward in interface Path

paint

public void paint(Graphics2D gfx)
Description copied from interface: Path
Paint this path on the screen (used for debugging purposes only).

Specified by:
paint in interface Path

wasRemoved

public void wasRemoved(Pathable pable)
Description copied from interface: Path
When a path is removed from a pathable, whether that is because the path was completed or because it was replaced by another path, this method will be called to let the path know that it is no longer associated with this pathable.

Specified by:
wasRemoved in interface Path

initNextPath

protected void initNextPath(long initStamp,
                            long tickStamp)
Initialize and start the next path in the sequence.