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