Whitespace

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1014 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Dave Hoover
2010-09-17 20:39:13 +00:00
parent 178fa9db35
commit 87919b5f6f
4 changed files with 73 additions and 104 deletions
@@ -79,7 +79,8 @@ public class AnimationSprite extends Sprite
}
@Override
public void paint (Graphics2D gfx) {
public void paint (Graphics2D gfx)
{
// Nothing to paint for ourselves.
_anim.paint(gfx);
@@ -190,8 +190,8 @@ public class ColorPository implements Serializable
}
/**
* Used to store information on a particular color. These are public
* to simplify the XML parsing process, so pay them no mind.
* Used to store information on a particular color. These are public to simplify the XML
* parsing process, so pay them no mind.
*/
public static class ColorRecord implements Serializable
{
@@ -208,15 +208,14 @@ public class ColorPository implements Serializable
* source color to recolor to this color. */
public float[] offsets;
/** Tags this color as a legal starting color or not. This is a
* shameful copout, placing application-specific functionality
* into a general purpose library class. */
/** Tags this color as a legal starting color or not. This is a shameful copout, placing
* application-specific functionality into a general purpose library class. */
public boolean starter;
/**
* Returns a value that is the composite of our class id and color
* id which can be used to identify a colorization record. This
* value will always be a positive integer that fits into 16 bits.
* Returns a value that is the composite of our class id and color id which can be used
* to identify a colorization record. This value will always be a positive integer that
* fits into 16 bits.
*/
public int getColorPrint ()
{
@@ -224,8 +223,7 @@ public class ColorPository implements Serializable
}
/**
* Returns the data in this record configured as a colorization
* instance.
* Returns the data in this record configured as a colorization instance.
*/
public Colorization getColorization ()
{
@@ -234,16 +232,14 @@ public class ColorPository implements Serializable
// cclass.range, offsets);
// }
// return _zation;
return new Colorization(getColorPrint(), cclass.source,
cclass.range, offsets);
return new Colorization(getColorPrint(), cclass.source, cclass.range, offsets);
}
@Override
public String toString ()
{
return "[id=" + colorId + ", name=" + name +
", offsets=" + StringUtil.toString(offsets) +
", starter=" + starter + "]";
", offsets=" + StringUtil.toString(offsets) + ", starter=" + starter + "]";
}
/** Our data represented as a colorization. */
@@ -73,18 +73,15 @@ public class AStarPathUtil
*/
public static class Stepper
{
public Stepper ()
{
public Stepper () {
this(true);
}
public Stepper (boolean considerDiagonals)
{
public Stepper (boolean considerDiagonals) {
_considerDiagonals = considerDiagonals;
}
public void init (Info info, Node n)
{
public void init (Info info, Node n) {
_info = info;
_node = n;
}
@@ -94,8 +91,7 @@ public class AStarPathUtil
* coordinates. No checking must be done as to whether the step is legal, that will be
* handled later. Just enumerate all possible steps.
*/
public void considerSteps (int x, int y)
{
public void considerSteps (int x, int y) {
considerStep(x, y - 1, ADJACENT_COST);
considerStep(x, y + 1, ADJACENT_COST);
considerStep(x - 1, y, ADJACENT_COST);
@@ -108,8 +104,7 @@ public class AStarPathUtil
}
}
protected void considerStep (int x, int y, int cost)
{
protected void considerStep (int x, int y, int cost) {
AStarPathUtil.considerStep(_info, _node, x, y, cost);
}
@@ -337,8 +332,7 @@ public class AStarPathUtil
/** The maximum cost of any path that we'll consider. */
public int maxcost;
public Info (TraversalPred tpred, Object trav, int longest, int destx, int desty)
{
public Info (TraversalPred tpred, Object trav, int longest, int destx, int desty) {
// save off references
this.tpred = tpred;
this.trav = trav;
@@ -357,8 +351,7 @@ public class AStarPathUtil
* Returns whether moving from the given source to destination coordinates is a valid
* move.
*/
protected boolean isStepValid (int sx, int sy, int dx, int dy)
{
protected boolean isStepValid (int sx, int sy, int dx, int dy) {
// not traversable if the destination itself fails test
if (tpred instanceof ExtendedTraversalPred) {
if (!((ExtendedTraversalPred)tpred).canTraverse(trav, sx, sy, dx, dy)) {
@@ -380,16 +373,14 @@ public class AStarPathUtil
/**
* Returns whether the given coordinate is valid and traversable.
*/
protected boolean isTraversable (int x, int y)
{
protected boolean isTraversable (int x, int y) {
return tpred.canTraverse(trav, x, y);
}
/**
* Get or create the node for the specified point.
*/
public Node getNode (int x, int y)
{
public Node getNode (int x, int y) {
// note: this _could_ break for unusual values of x and y.
// perhaps use a IntTuple as a key? Bleah.
int key = (x << 16) | (y & 0xffff);
@@ -429,15 +420,13 @@ public class AStarPathUtil
/** The node's monotonically-increasing unique identifier. */
public int id;
public Node (int x, int y)
{
public Node (int x, int y) {
this.x = x;
this.y = y;
id = _nextid++;
}
public int compareTo (Node o)
{
public int compareTo (Node o) {
int bf = o.f;
// since the set contract is fulfilled using the equality results returned here, and
+50 -67
View File
@@ -48,8 +48,7 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns an abbreviated string representation of the supplied
* direction code.
* Returns an abbreviated string representation of the supplied direction code.
*/
public static String toShortString (int direction)
{
@@ -58,9 +57,8 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns the direction code that corresponds to the supplied string
* or {@link #NONE} if the string does not correspond to a known
* direction code.
* Returns the direction code that corresponds to the supplied string or {@link #NONE} if the
* string does not correspond to a known direction code.
*/
public static int fromString (String dirstr)
{
@@ -73,9 +71,8 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns the direction code that corresponds to the supplied short
* string or {@link #NONE} if the string does not correspond to a
* known direction code.
* Returns the direction code that corresponds to the supplied short string or {@link #NONE}
* if the string does not correspond to a known direction code.
*/
public static int fromShortString (String dirstr)
{
@@ -88,8 +85,8 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns a string representation of an array of direction codes. The
* directions are represented by the abbreviated names.
* Returns a string representation of an array of direction codes. The directions are
* represented by the abbreviated names.
*/
public static String toString (int[] directions)
{
@@ -104,8 +101,8 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Rotates the requested <em>fine</em> direction constant clockwise by
* the requested number of ticks.
* Rotates the requested <em>fine</em> direction constant clockwise by the requested number of
* ticks.
*/
public static int rotateCW (int direction, int ticks)
{
@@ -116,8 +113,8 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Rotates the requested <em>fine</em> direction constant
* counter-clockwise by the requested number of ticks.
* Rotates the requested <em>fine</em> direction constant counter-clockwise by the requested
* number of ticks.
*/
public static int rotateCCW (int direction, int ticks)
{
@@ -144,8 +141,8 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Get the direction closest to the specified direction, out of
* the directions in the possible list (preferring a clockwise match).
* Get the direction closest to the specified direction, out of the directions in the possible
* list (preferring a clockwise match).
*/
public static int getClosest (int direction, int[] possible)
{
@@ -153,11 +150,10 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Get the direction closest to the specified direction, out of
* the directions in the possible list.
* Get the direction closest to the specified direction, out of the directions in the possible
* list.
*
* @param preferCW whether to prefer a clockwise match or a
* counter-clockwise match.
* @param preferCW whether to prefer a clockwise match or a counter-clockwise match.
*/
public static int getClosest (int direction, int[] possible,
boolean preferCW)
@@ -182,12 +178,10 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns which of the eight compass directions that point
* <code>b</code> lies in from point <code>a</code> as one of the
* {@link DirectionCodes} direction constants. <em>Note:</em> that the
* coordinates supplied are assumed to be logical (screen) rather than
* cartesian coordinates and <code>NORTH</code> is considered to point
* toward the top of the screen.
* Returns which of the eight compass directions that point <code>b</code> lies in from point
* <code>a</code> as one of the {@link DirectionCodes} direction constants. <em>Note:</em>
* that the coordinates supplied are assumed to be logical (screen) rather than cartesian
* coordinates and <code>NORTH</code> is considered to point toward the top of the screen.
*/
public static int getDirection (Point a, Point b)
{
@@ -195,12 +189,10 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns which of the eight compass directions that point
* <code>b</code> lies in from point <code>a</code> as one of the
* {@link DirectionCodes} direction constants. <em>Note:</em> that the
* coordinates supplied are assumed to be logical (screen) rather than
* cartesian coordinates and <code>NORTH</code> is considered to point
* toward the top of the screen.
* Returns which of the eight compass directions that point <code>b</code> lies in from point
* <code>a</code> as one of the {@link DirectionCodes} direction constants. <em>Note:</em>
* that the coordinates supplied are assumed to be logical (screen) rather than cartesian
* coordinates and <code>NORTH</code> is considered to point toward the top of the screen.
*/
public static int getDirection (int ax, int ay, int bx, int by)
{
@@ -208,12 +200,10 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns which of the eight compass directions that point
* <code>b</code> lies in from point <code>a</code> as one of the
* {@link DirectionCodes} direction constants. <em>Note:</em> that the
* coordinates supplied are assumed to be logical (screen) rather than
* cartesian coordinates and <code>NORTH</code> is considered to point
* toward the top of the screen.
* Returns which of the eight compass directions that point <code>b</code> lies in from point
* <code>a</code> as one of the {@link DirectionCodes} direction constants. <em>Note:</em>
* that the coordinates supplied are assumed to be logical (screen) rather than cartesian
* coordinates and <code>NORTH</code> is considered to point toward the top of the screen.
*/
public static int getDirection (double ax, double ay, double bx, double by)
{
@@ -221,12 +211,10 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns which of the eight compass directions is associated with
* the specified angle theta. <em>Note:</em> that the angle supplied
* is assumed to increase clockwise around the origin (which screen
* angles do) rather than counter-clockwise around the origin (which
* cartesian angles do) and <code>NORTH</code> is considered to point
* toward the top of the screen.
* Returns which of the eight compass directions is associated with the specified angle theta.
* <em>Note:</em> that the angle supplied is assumed to increase clockwise around the origin
* (which screen angles do) rather than counter-clockwise around the origin (which cartesian
* angles do) and <code>NORTH</code> is considered to point toward the top of the screen.
*/
public static int getDirection (double theta)
{
@@ -235,12 +223,11 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns which of the sixteen compass directions that point
* <code>b</code> lies in from point <code>a</code> as one of the
* {@link DirectionCodes} direction constants. <em>Note:</em> that the
* coordinates supplied are assumed to be logical (screen) rather than
* cartesian coordinates and <code>NORTH</code> is considered to point
* toward the top of the screen.
* Returns which of the sixteen compass directions that point <code>b</code> lies in from
* point <code>a</code> as one of the {@link DirectionCodes} direction constants.
* <em>Note:</em> that the coordinates supplied are assumed to be logical (screen) rather than
* cartesian coordinates and <code>NORTH</code> is considered to point toward the top of the
* screen.
*/
public static int getFineDirection (Point a, Point b)
{
@@ -248,12 +235,11 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns which of the sixteen compass directions that point
* <code>b</code> lies in from point <code>a</code> as one of the
* {@link DirectionCodes} direction constants. <em>Note:</em> that the
* coordinates supplied are assumed to be logical (screen) rather than
* cartesian coordinates and <code>NORTH</code> is considered to point
* toward the top of the screen.
* Returns which of the sixteen compass directions that point <code>b</code> lies in from
* point <code>a</code> as one of the {@link DirectionCodes} direction constants.
* <em>Note:</em> that the coordinates supplied are assumed to be logical (screen) rather than
* cartesian coordinates and <code>NORTH</code> is considered to point toward the top of the
* screen.
*/
public static int getFineDirection (int ax, int ay, int bx, int by)
{
@@ -261,12 +247,11 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Returns which of the sixteen compass directions is associated with
* the specified angle theta. <em>Note:</em> that the angle supplied
* is assumed to increase clockwise around the origin (which screen
* angles do) rather than counter-clockwise around the origin (which
* cartesian angles do) and <code>NORTH</code> is considered to point
* toward the top of the screen.
* Returns which of the sixteen compass directions is associated with the specified angle
* theta. <em>Note:</em> that the angle supplied is assumed to increase clockwise around the
* origin (which screen angles do) rather than counter-clockwise around the origin (which
* cartesian angles do) and <code>NORTH</code> is considered to point toward the top of the
* screen.
*/
public static int getFineDirection (double theta)
{
@@ -275,15 +260,13 @@ public class DirectionUtil implements DirectionCodes
}
/**
* Move the specified point in the specified screen direction,
* adjusting by the specified adjustments. Fine directions are
* not supported.
* Move the specified point in the specified screen direction, adjusting by the specified
* adjustments. Fine directions are not supported.
*/
public static void moveDirection (Point p, int direction, int dx, int dy)
{
if (direction >= DIRECTION_COUNT) {
throw new IllegalArgumentException(
"Fine coordinates not supported.");
throw new IllegalArgumentException("Fine coordinates not supported.");
}
switch (direction) {