com.threerings.media.util
Class LinePath

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

public class LinePath
extends TimedPath

The line path is used to cause a pathable to go from point A to point B in a certain number of milliseconds.


Field Summary
protected  Point _dest
          Our source and destination points.
protected  Point _source
          Our source and destination points.
protected  Point _tpos
          A temporary point used when computing our position along the path.
 
Fields inherited from class com.threerings.media.util.TimedPath
_duration, _startStamp
 
Constructor Summary
LinePath(int x1, int y1, int x2, int y2, long duration)
          Constructs a line path between the two specified points that will be followed in the specified number of milliseconds.
LinePath(Point dest, long duration)
          Constructs a line path that moves a pathable from whatever its location is at init time to the dest point over the specified number of milliseconds.
LinePath(Point source, Point dest, long duration)
          Constructs a line path between the two specified points that will be followed in the specified number of milliseconds.
 
Method Summary
static void computePosition(Point start, Point end, long elapsed, long duration, Point pos)
          Computes the position of an entity along the path defined by the supplied start and end points assuming that it must finish the path in the specified duration (in millis) and has been traveling the path for the specified number of elapsed milliseconds.
 Path getTranslatedInstance(int x, int y)
          Return a copy of the path, translated by the specified amounts.
 void init(Pathable pable, long timestamp)
          Called once to let the path prepare itself for the process of animating the supplied pathable.
 void paint(Graphics2D gfx)
          Paint this path on the screen (used for debugging purposes only).
 boolean tick(Pathable pable, long timestamp)
          Called to request that this path update the position of the specified pathable based on the supplied timestamp information.
protected  void toString(StringBuilder buf)
          An extensible method for generating a string representation of this instance.
 
Methods inherited from class com.threerings.media.util.TimedPath
fastForward, toString, wasRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_source

protected Point _source
Our source and destination points.


_dest

protected Point _dest
Our source and destination points.


_tpos

protected Point _tpos
A temporary point used when computing our position along the path.

Constructor Detail

LinePath

public LinePath(int x1,
                int y1,
                int x2,
                int y2,
                long duration)
Constructs a line path between the two specified points that will be followed in the specified number of milliseconds.


LinePath

public LinePath(Point source,
                Point dest,
                long duration)
Constructs a line path between the two specified points that will be followed in the specified number of milliseconds.


LinePath

public LinePath(Point dest,
                long duration)
Constructs a line path that moves a pathable from whatever its location is at init time to the dest point over the specified number of milliseconds.

Method Detail

getTranslatedInstance

public Path getTranslatedInstance(int x,
                                  int y)
Return a copy of the path, translated by the specified amounts.


init

public void init(Pathable pable,
                 long timestamp)
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
Overrides:
init in class TimedPath

tick

public boolean tick(Pathable pable,
                    long timestamp)
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.

Parameters:
pable - the pathable whose position should be updated.
timestamp - 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.

paint

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


toString

protected void toString(StringBuilder buf)
Description copied from class: TimedPath
An extensible method for generating a string representation of this instance.

Overrides:
toString in class TimedPath

computePosition

public static void computePosition(Point start,
                                   Point end,
                                   long elapsed,
                                   long duration,
                                   Point pos)
Computes the position of an entity along the path defined by the supplied start and end points assuming that it must finish the path in the specified duration (in millis) and has been traveling the path for the specified number of elapsed milliseconds.