Whitespace

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@886 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Dave Hoover
2010-02-12 19:36:44 +00:00
parent f49b351b27
commit 1bd06bf2cb
4 changed files with 36 additions and 50 deletions
+13 -19
View File
@@ -91,23 +91,19 @@ public class ArcPath extends TimedPath
*/ */
public Path getTranslatedInstance (int x, int y) public Path getTranslatedInstance (int x, int y)
{ {
int startx = int startx = (int)(_center.x + Math.round(Math.cos(_sangle) * _xradius));
(int)(_center.x + Math.round(Math.cos(_sangle) * _xradius)); int starty = (int)(_center.y + Math.round(Math.sin(_sangle) * _yradius));
int starty =
(int)(_center.y + Math.round(Math.sin(_sangle) * _yradius));
return new ArcPath(new Point(startx + x, starty + y), return new ArcPath(new Point(startx + x, starty + y),
_xradius, _yradius, _sangle, _delta, _duration, _orient); _xradius, _yradius, _sangle, _delta, _duration, _orient);
} }
/** /**
* Sets the offset that is applied to the pathable whenever it is * Sets the offset that is applied to the pathable whenever it is oriented. This offset is in
* oriented. This offset is in clockwise units whose granularity is * clockwise units whose granularity is specified by the {@link #NORMAL} or {@link #FINE}
* specified by the {@link #NORMAL} or {@link #FINE} setting supplied * setting supplied to the path at construct time. The intent here is to allow arc paths to be
* to the path at construct time. The intent here is to allow arc * applied that don't orient the pathable in the direction they are traveling but instead in
* paths to be applied that don't orient the pathable in the direction * some fixed offset from that direction.
* they are traveling but instead in some fixed offset from that
* direction.
*/ */
public void setOrientOffset (int offset) public void setOrientOffset (int offset)
{ {
@@ -136,8 +132,8 @@ public class ArcPath extends TimedPath
angle = _sangle + _delta; angle = _sangle + _delta;
} else { } else {
// otherwise, compute the angle at which we should place the // otherwise, compute the angle at which we should place the pathable based on the
// pathable based on the elapsed time // elapsed time
long elapsed = timestamp - _startStamp; long elapsed = timestamp - _startStamp;
angle = _sangle + _delta * elapsed / _duration; angle = _sangle + _delta * elapsed / _duration;
} }
@@ -215,10 +211,9 @@ public class ArcPath extends TimedPath
} }
/** /**
* Computes the position of an entity along the path defined by the * Computes the position of an entity along the path defined by the supplied parameters
* supplied parameters assuming that it must finish the path in the * assuming that it must finish the path in the specified duration (in millis) and has been
* specified duration (in millis) and has been traveling the path for * traveling the path for the specified number of elapsed milliseconds.
* the specified number of elapsed milliseconds.
*/ */
public static void computePosition ( public static void computePosition (
Point center, double xradius, double yradius, double angle, Point pos) Point center, double xradius, double yradius, double angle, Point pos)
@@ -242,7 +237,6 @@ public class ArcPath extends TimedPath
/** An orientation offset used when orienting our pathable. */ /** An orientation offset used when orienting our pathable. */
protected int _orientOffset = 0; protected int _orientOffset = 0;
/** A temporary point used when computing our position along the /** A temporary point used when computing our position along the path. */
* path. */
protected Point _tpos = new Point(); protected Point _tpos = new Point();
} }
@@ -36,8 +36,7 @@ public class BobblePath implements Path
* *
* @param dx the variance in the x direction. * @param dx the variance in the x direction.
* @param dy the variance in the y direction. * @param dy the variance in the y direction.
* @param duration the duration to bobble, or -1 to bobble until * @param duration the duration to bobble, or -1 to bobble until stop() is called.
* stop() is called.
*/ */
public BobblePath (int dx, int dy, long duration) public BobblePath (int dx, int dy, long duration)
{ {
@@ -49,8 +48,7 @@ public class BobblePath implements Path
* *
* @param dx the variance in the x direction. * @param dx the variance in the x direction.
* @param dy the variance in the y direction. * @param dy the variance in the y direction.
* @param duration the duration to bobble, or -1 to bobble until * @param duration the duration to bobble, or -1 to bobble until stop() is called.
* stop() is called.
* @param updateFreq how often to update the Pathable's location. * @param updateFreq how often to update the Pathable's location.
*/ */
public BobblePath (int dx, int dy, long duration, long updateFreq) public BobblePath (int dx, int dy, long duration, long updateFreq)
@@ -67,8 +65,7 @@ public class BobblePath implements Path
{ {
if ((dx < 0) || (dy < 0) || ((dx == 0) && (dy == 0))) { if ((dx < 0) || (dy < 0) || ((dx == 0) && (dy == 0))) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Variance values must be positive, " + "Variance values must be positive, and at least one must be non-zero.");
"and at least one must be non-zero.");
} else { } else {
_dx = dx; _dx = dx;
_dy = dy; _dy = dy;
@@ -156,8 +153,7 @@ public class BobblePath implements Path
} }
/** /**
* Update the position of the pathable or return false * Update the position of the pathable or return false if it's already there.
* if it's already there.
*/ */
protected boolean updatePositionTo (Pathable pable, int x, int y) protected boolean updatePositionTo (Pathable pable, int x, int y)
{ {
@@ -28,14 +28,14 @@ import java.awt.Point;
import com.samskivert.util.StringUtil; import com.samskivert.util.StringUtil;
/** /**
* The line path is used to cause a pathable to go from point A to point B * The line path is used to cause a pathable to go from point A to point B in a certain number of
* in a certain number of milliseconds. * milliseconds.
*/ */
public class LinePath extends TimedPath public class LinePath extends TimedPath
{ {
/** /**
* Constructs a line path between the two specified points that will * Constructs a line path between the two specified points that will be followed in the
* be followed in the specified number of milliseconds. * specified number of milliseconds.
*/ */
public LinePath (int x1, int y1, int x2, int y2, long duration) public LinePath (int x1, int y1, int x2, int y2, long duration)
{ {
@@ -43,8 +43,8 @@ public class LinePath extends TimedPath
} }
/** /**
* Constructs a line path between the two specified points that will * Constructs a line path between the two specified points that will be followed in the
* be followed in the specified number of milliseconds. * specified number of milliseconds.
*/ */
public LinePath (Point source, Point dest, long duration) public LinePath (Point source, Point dest, long duration)
{ {
@@ -54,9 +54,8 @@ public class LinePath extends TimedPath
} }
/** /**
* Constructs a line path that moves a pathable from * Constructs a line path that moves a pathable from whatever its location is at init time to
* whatever its location is at init time to the dest point over * the dest point over the specified number of milliseconds.
* the specified number of milliseconds.
*/ */
public LinePath (Point dest, long duration) public LinePath (Point dest, long duration)
{ {
@@ -128,13 +127,12 @@ public class LinePath extends TimedPath
} }
/** /**
* Computes the position of an entity along the path defined by the * Computes the position of an entity along the path defined by the supplied start and end
* supplied start and end points assuming that it must finish the path * points assuming that it must finish the path in the specified duration (in millis) and has
* in the specified duration (in millis) and has been traveling the * been traveling the path for the specified number of elapsed milliseconds.
* path for the specified number of elapsed milliseconds.
*/ */
public static void computePosition (Point start, Point end, long elapsed, public static void computePosition (
long duration, Point pos) Point start, Point end, long elapsed, long duration, Point pos)
{ {
float pct = (float)elapsed / duration; float pct = (float)elapsed / duration;
int travx = (int)((end.x - start.x) * pct); int travx = (int)((end.x - start.x) * pct);
@@ -145,7 +143,6 @@ public class LinePath extends TimedPath
/** Our source and destination points. */ /** Our source and destination points. */
protected Point _source, _dest; protected Point _source, _dest;
/** A temporary point used when computing our position along the /** A temporary point used when computing our position along the path. */
* path. */
protected Point _tpos = new Point(); protected Point _tpos = new Point();
} }
@@ -24,8 +24,8 @@ package com.threerings.media.util;
import static com.threerings.media.Log.log; import static com.threerings.media.Log.log;
/** /**
* A base class for path implementations that endeavor to move their * A base class for path implementations that endeavor to move their pathables along a path in a
* pathables along a path in a specified number of milliseconds. * specified number of milliseconds.
*/ */
public abstract class TimedPath implements Path public abstract class TimedPath implements Path
{ {
@@ -37,8 +37,8 @@ public abstract class TimedPath implements Path
{ {
// sanity check some things // sanity check some things
if (duration <= 0) { if (duration <= 0) {
log.warning("Requested path with illegal duration (<=0) " + log.warning("Requested path with illegal duration (<=0)",
"[duration=" + duration + "]", new Exception()); "duration", duration, new Exception());
duration = 1; // assume something short but non-zero duration = 1; // assume something short but non-zero
} }
@@ -79,8 +79,7 @@ public abstract class TimedPath implements Path
} }
/** /**
* An extensible method for generating a string representation of this * An extensible method for generating a string representation of this instance.
* instance.
*/ */
protected void toString (StringBuilder buf) protected void toString (StringBuilder buf)
{ {