Prune trailing whitespace & foreachize loops.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@824 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -125,7 +125,7 @@ public class CompositedMaskedImage extends CompositedMultiFrameImage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the x offset into the source image for the image at index
|
* @return the x offset into the source image for the image at index
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class CompositedShadowImage extends CompositedMultiFrameImage
|
|||||||
public int getYOrigin (int index) {
|
public int getYOrigin (int index) {
|
||||||
return _sources[0].frames.getYOrigin(_orient, index);
|
return _sources[0].frames.getYOrigin(_orient, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected CompositedMirage createCompositedMirage (int index) {
|
protected CompositedMirage createCompositedMirage (int index) {
|
||||||
// Always use a CompositedVolatileMirage for ShadowImage since we need to draw into it.
|
// Always use a CompositedVolatileMirage for ShadowImage since we need to draw into it.
|
||||||
@@ -91,7 +91,7 @@ public class CompositedShadowImage extends CompositedMultiFrameImage
|
|||||||
bounds.setBounds(getX(index), getY(index), _images[index].getWidth(),
|
bounds.setBounds(getX(index), getY(index), _images[index].getWidth(),
|
||||||
_images[index].getHeight());
|
_images[index].getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the x offset into the source image for the image at index
|
* @return the x offset into the source image for the image at index
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public interface FrameProvider
|
|||||||
* Returns the file path of the animation frames (in the eight sprite directions) for the
|
* Returns the file path of the animation frames (in the eight sprite directions) for the
|
||||||
* specified action of the specified component. May return a path to the default action or
|
* specified action of the specified component. May return a path to the default action or
|
||||||
* null if the specified action does not exist for the specified component.
|
* null if the specified action does not exist for the specified component.
|
||||||
*
|
*
|
||||||
* @param existentPaths the set of all paths for which there are valid frames.
|
* @param existentPaths the set of all paths for which there are valid frames.
|
||||||
*/
|
*/
|
||||||
public String getFramePath (
|
public String getFramePath (
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ public class BundleUtil
|
|||||||
*
|
*
|
||||||
* @exception IOException thrown if an I/O error occurs while reading the object from the
|
* @exception IOException thrown if an I/O error occurs while reading the object from the
|
||||||
* bundle.
|
* bundle.
|
||||||
*/
|
*/
|
||||||
public static Object loadObject (ResourceBundle bundle, String path, boolean wipeOnFailure)
|
public static Object loadObject (ResourceBundle bundle, String path, boolean wipeOnFailure)
|
||||||
throws IOException, ClassNotFoundException
|
throws IOException, ClassNotFoundException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ public class DumpBundle
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (String arg : args) {
|
||||||
File file = new File(args[i]);
|
File file = new File(arg);
|
||||||
try {
|
try {
|
||||||
ResourceBundle bundle = new FileResourceBundle(file);
|
ResourceBundle bundle = new FileResourceBundle(file);
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class DumpBundle
|
|||||||
dumpTable("components: ", comps);
|
dumpTable("components: ", comps);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Error dumping bundle [path=" + args[i] +
|
System.err.println("Error dumping bundle [path=" + arg +
|
||||||
", error=" + e + "].");
|
", error=" + e + "].");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -81,5 +81,5 @@ public class DumpBundle
|
|||||||
if (table != null) {
|
if (table != null) {
|
||||||
System.out.println(prefix + StringUtil.toString(table.entrySet().iterator()));
|
System.out.println(prefix + StringUtil.toString(table.entrySet().iterator()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,8 +95,8 @@ public class ClassRuleSet extends RuleSetBase
|
|||||||
public Object parse (String text) {
|
public Object parse (String text) {
|
||||||
String[] orients = StringUtil.parseStringArray(text);
|
String[] orients = StringUtil.parseStringArray(text);
|
||||||
ArrayIntSet oset = new ArrayIntSet();
|
ArrayIntSet oset = new ArrayIntSet();
|
||||||
for (int ii = 0; ii < orients.length; ii++) {
|
for (String orient : orients) {
|
||||||
oset.add(DirectionUtil.fromShortString(orients[ii]));
|
oset.add(DirectionUtil.fromShortString(orient));
|
||||||
}
|
}
|
||||||
return oset;
|
return oset;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ public class IconManager
|
|||||||
|
|
||||||
/** A cache of our icon tilesets. */
|
/** A cache of our icon tilesets. */
|
||||||
protected Map<String, TileSet> _icons = new LRUHashMap<String, TileSet>(ICON_CACHE_SIZE);
|
protected Map<String, TileSet> _icons = new LRUHashMap<String, TileSet>(ICON_CACHE_SIZE);
|
||||||
|
|
||||||
/** The suffix we append to an icon set name to obtain the tileset
|
/** The suffix we append to an icon set name to obtain the tileset
|
||||||
* image path configuration parameter. */
|
* image path configuration parameter. */
|
||||||
protected static final String PATH_SUFFIX = ".path";
|
protected static final String PATH_SUFFIX = ".path";
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class TimerView
|
|||||||
|
|
||||||
// Stop any current processing
|
// Stop any current processing
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
// Record the timer's full duration and effective start time
|
// Record the timer's full duration and effective start time
|
||||||
_duration = duration;
|
_duration = duration;
|
||||||
|
|
||||||
@@ -185,7 +185,7 @@ public class TimerView
|
|||||||
|
|
||||||
// Prevent it from being unpaused
|
// Prevent it from being unpaused
|
||||||
_lastUpdate = Long.MIN_VALUE;
|
_lastUpdate = Long.MIN_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pause the timer from processing.
|
* Pause the timer from processing.
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ public abstract class Animation extends AbstractMedia
|
|||||||
{
|
{
|
||||||
removeObserver(obs);
|
removeObserver(obs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Whether the animation is finished. */
|
/** Whether the animation is finished. */
|
||||||
protected boolean _finished = false;
|
protected boolean _finished = false;
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class GleamAnimation extends Animation
|
|||||||
/**
|
/**
|
||||||
* Creates a gleam animation with the supplied sprite. The sprite will be faded to the
|
* Creates a gleam animation with the supplied sprite. The sprite will be faded to the
|
||||||
* specified color and then back again.
|
* specified color and then back again.
|
||||||
*
|
*
|
||||||
* @param fadeIn if true, the sprite itself will be faded in as we fade up to the gleam color
|
* @param fadeIn if true, the sprite itself will be faded in as we fade up to the gleam color
|
||||||
* and the gleam color will fade out, leaving just the sprite imagery.
|
* and the gleam color will fade out, leaving just the sprite imagery.
|
||||||
*/
|
*/
|
||||||
@@ -59,7 +59,7 @@ public class GleamAnimation extends Animation
|
|||||||
* Creates a gleam animation with the supplied sprite. The sprite will be faded to the
|
* Creates a gleam animation with the supplied sprite. The sprite will be faded to the
|
||||||
* specified color and then back again. The sprite may be already added to the supplied sprite
|
* specified color and then back again. The sprite may be already added to the supplied sprite
|
||||||
* manager or not, but when the animation is complete, it will have been added.
|
* manager or not, but when the animation is complete, it will have been added.
|
||||||
*
|
*
|
||||||
* @param fadeIn if true, the sprite itself will be faded in as we fade up to the gleam color
|
* @param fadeIn if true, the sprite itself will be faded in as we fade up to the gleam color
|
||||||
* and the gleam color will fade out, leaving just the sprite imagery.
|
* and the gleam color will fade out, leaving just the sprite imagery.
|
||||||
*/
|
*/
|
||||||
@@ -74,7 +74,7 @@ public class GleamAnimation extends Animation
|
|||||||
_downmillis = downmillis;
|
_downmillis = downmillis;
|
||||||
_fadeIn = fadeIn;
|
_fadeIn = fadeIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override // documentation inherited
|
@Override // documentation inherited
|
||||||
public void tick (long timestamp)
|
public void tick (long timestamp)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class ScaleAnimation extends Animation
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Smooth out the image scaling
|
// Smooth out the image scaling
|
||||||
//
|
//
|
||||||
// FIXME: Should this be turned off when the painting is done?
|
// FIXME: Should this be turned off when the painting is done?
|
||||||
gfx.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
gfx.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
||||||
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class SpriteAnimation extends Animation
|
|||||||
_sprite.move(_path);
|
_sprite.move(_path);
|
||||||
_path = null;
|
_path = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint (Graphics2D gfx)
|
public void paint (Graphics2D gfx)
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class FadeEffect
|
|||||||
}
|
}
|
||||||
|
|
||||||
// save things off
|
// save things off
|
||||||
_startAlpha = alpha;
|
_startAlpha = alpha;
|
||||||
_step = step;
|
_step = step;
|
||||||
_target = target;
|
_target = target;
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class BufferedMirage implements Mirage
|
|||||||
{
|
{
|
||||||
this(image, 1);
|
this(image, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param percentageOfDataBuffer - the percentage of image's data buffer used by image for use
|
* @param percentageOfDataBuffer - the percentage of image's data buffer used by image for use
|
||||||
* in getEstimatedMemory. ie if this image is a subimage of another image, and they share a
|
* in getEstimatedMemory. ie if this image is a subimage of another image, and they share a
|
||||||
@@ -81,7 +81,7 @@ public class BufferedMirage implements Mirage
|
|||||||
{
|
{
|
||||||
return _image;
|
return _image;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected float _percentageOfDataBuffer;
|
protected float _percentageOfDataBuffer;
|
||||||
|
|
||||||
protected BufferedImage _image;
|
protected BufferedImage _image;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class CompositeMirage implements Mirage
|
|||||||
for (Mirage m : _mirages) {
|
for (Mirage m : _mirages) {
|
||||||
mem += m.getEstimatedMemoryUsage();
|
mem += m.getEstimatedMemoryUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
return mem;
|
return mem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ public class ImageUtil
|
|||||||
// */
|
// */
|
||||||
// public static Area createImageMask (BufferedImage src)
|
// public static Area createImageMask (BufferedImage src)
|
||||||
// {
|
// {
|
||||||
// Raster srcdata = src.getData();
|
// Raster srcdata = src.getData();
|
||||||
// int wid = src.getWidth(), hei = src.getHeight();
|
// int wid = src.getWidth(), hei = src.getHeight();
|
||||||
// Log.info("creating area of (" + wid + ", " + hei + ")");
|
// Log.info("creating area of (" + wid + ", " + hei + ")");
|
||||||
// Area a = new Area(new Rectangle(wid, hei));
|
// Area a = new Area(new Rectangle(wid, hei));
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class MirageIcon implements Icon
|
|||||||
{
|
{
|
||||||
_mirage.paint((Graphics2D)g, x, y);
|
_mirage.paint((Graphics2D)g, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int getIconWidth()
|
public int getIconWidth()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ package com.threerings.media.image;
|
|||||||
* nodes in the reduced tree.<p>
|
* nodes in the reduced tree.<p>
|
||||||
*
|
*
|
||||||
* Here is the copyright notice from ImageMagick:
|
* Here is the copyright notice from ImageMagick:
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||||
% Permission is hereby granted, free of charge, to any person obtaining a %
|
% Permission is hereby granted, free of charge, to any person obtaining a %
|
||||||
@@ -283,9 +283,9 @@ public class Quantize {
|
|||||||
% written permission from ISI.
|
% written permission from ISI.
|
||||||
%
|
%
|
||||||
*/
|
*/
|
||||||
|
|
||||||
final static boolean QUICK = false;
|
final static boolean QUICK = false;
|
||||||
|
|
||||||
final static int MAX_RGB = 255;
|
final static int MAX_RGB = 255;
|
||||||
final static int MAX_NODES = 266817;
|
final static int MAX_NODES = 266817;
|
||||||
final static int MAX_TREE_DEPTH = 8;
|
final static int MAX_TREE_DEPTH = 8;
|
||||||
@@ -308,7 +308,7 @@ public class Quantize {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reduce the image to the given number of colors.
|
* Reduce the image to the given number of colors.
|
||||||
*
|
*
|
||||||
* @param pixels an in/out parameter that should initially contain
|
* @param pixels an in/out parameter that should initially contain
|
||||||
* [A]RGB values but that will contain color palette indicies upon return.
|
* [A]RGB values but that will contain color palette indicies upon return.
|
||||||
*
|
*
|
||||||
@@ -321,7 +321,7 @@ public class Quantize {
|
|||||||
cube.assignment();
|
cube.assignment();
|
||||||
return cube.colormap;
|
return cube.colormap;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Cube {
|
static class Cube {
|
||||||
int pixels[][];
|
int pixels[][];
|
||||||
int max_colors;
|
int max_colors;
|
||||||
@@ -329,7 +329,7 @@ public class Quantize {
|
|||||||
|
|
||||||
// do we have transparent pixels?
|
// do we have transparent pixels?
|
||||||
boolean hasTrans = false;
|
boolean hasTrans = false;
|
||||||
|
|
||||||
Node root;
|
Node root;
|
||||||
int depth;
|
int depth;
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ public class Quantize {
|
|||||||
} else if (depth < 2) {
|
} else if (depth < 2) {
|
||||||
depth = 2;
|
depth = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
root = new Node(this);
|
root = new Node(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -506,7 +506,7 @@ public class Quantize {
|
|||||||
colormap = new int[colors];
|
colormap = new int[colors];
|
||||||
colors = 0;
|
colors = 0;
|
||||||
root.colormap();
|
root.colormap();
|
||||||
|
|
||||||
int pixels[][] = this.pixels;
|
int pixels[][] = this.pixels;
|
||||||
|
|
||||||
int width = pixels.length;
|
int width = pixels.length;
|
||||||
@@ -515,7 +515,7 @@ public class Quantize {
|
|||||||
Search search = new Search();
|
Search search = new Search();
|
||||||
|
|
||||||
int transPad = hasTrans ? 1 : 0;
|
int transPad = hasTrans ? 1 : 0;
|
||||||
|
|
||||||
// convert to indexed color
|
// convert to indexed color
|
||||||
for (int x = width; x-- > 0; ) {
|
for (int x = width; x-- > 0; ) {
|
||||||
for (int y = height; y-- > 0; ) {
|
for (int y = height; y-- > 0; ) {
|
||||||
@@ -587,7 +587,7 @@ public class Quantize {
|
|||||||
|
|
||||||
// the pixel count for this node and all children
|
// the pixel count for this node and all children
|
||||||
long number_pixels;
|
long number_pixels;
|
||||||
|
|
||||||
// the pixel count for this node
|
// the pixel count for this node
|
||||||
int unique;
|
int unique;
|
||||||
// the sum of all pixels contained in this node
|
// the sum of all pixels contained in this node
|
||||||
@@ -606,12 +606,12 @@ public class Quantize {
|
|||||||
this.level = 0;
|
this.level = 0;
|
||||||
|
|
||||||
this.number_pixels = Long.MAX_VALUE;
|
this.number_pixels = Long.MAX_VALUE;
|
||||||
|
|
||||||
this.mid_red = (MAX_RGB + 1) >> 1;
|
this.mid_red = (MAX_RGB + 1) >> 1;
|
||||||
this.mid_green = (MAX_RGB + 1) >> 1;
|
this.mid_green = (MAX_RGB + 1) >> 1;
|
||||||
this.mid_blue = (MAX_RGB + 1) >> 1;
|
this.mid_blue = (MAX_RGB + 1) >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node(Node parent, int id, int level) {
|
Node(Node parent, int id, int level) {
|
||||||
this.cube = parent.cube;
|
this.cube = parent.cube;
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
|
|||||||
@@ -40,10 +40,10 @@ public class ButtonSprite extends Sprite
|
|||||||
{
|
{
|
||||||
/** The normal, square button style. */
|
/** The normal, square button style. */
|
||||||
public static final int NORMAL = 0;
|
public static final int NORMAL = 0;
|
||||||
|
|
||||||
/** The rounded button style. */
|
/** The rounded button style. */
|
||||||
public static final int ROUNDED = 1;
|
public static final int ROUNDED = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a button sprite.
|
* Constructs a button sprite.
|
||||||
*
|
*
|
||||||
@@ -78,7 +78,7 @@ public class ButtonSprite extends Sprite
|
|||||||
* @param commandArgument the button's command argument
|
* @param commandArgument the button's command argument
|
||||||
*/
|
*/
|
||||||
public ButtonSprite (Label label, int style, int arcWidth, int arcHeight,
|
public ButtonSprite (Label label, int style, int arcWidth, int arcHeight,
|
||||||
Color backgroundColor, Color alternateColor, String actionCommand,
|
Color backgroundColor, Color alternateColor, String actionCommand,
|
||||||
Object commandArgument)
|
Object commandArgument)
|
||||||
{
|
{
|
||||||
_label = label;
|
_label = label;
|
||||||
@@ -90,7 +90,7 @@ public class ButtonSprite extends Sprite
|
|||||||
_actionCommand = actionCommand;
|
_actionCommand = actionCommand;
|
||||||
_commandArgument = commandArgument;
|
_commandArgument = commandArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the label displayed by this sprite.
|
* Returns a reference to the label displayed by this sprite.
|
||||||
*/
|
*/
|
||||||
@@ -106,17 +106,17 @@ public class ButtonSprite extends Sprite
|
|||||||
{
|
{
|
||||||
// invalidate the old...
|
// invalidate the old...
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
||||||
// size the bounds to fit our label
|
// size the bounds to fit our label
|
||||||
Dimension size = _label.getSize();
|
Dimension size = _label.getSize();
|
||||||
_bounds.width = size.width + PADDING*2 +
|
_bounds.width = size.width + PADDING*2 +
|
||||||
(_style == ROUNDED ? _arcWidth : 0);
|
(_style == ROUNDED ? _arcWidth : 0);
|
||||||
_bounds.height = size.height + PADDING*2;
|
_bounds.height = size.height + PADDING*2;
|
||||||
|
|
||||||
// ...and the new
|
// ...and the new
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the style of this button.
|
* Sets the style of this button.
|
||||||
*/
|
*/
|
||||||
@@ -125,7 +125,7 @@ public class ButtonSprite extends Sprite
|
|||||||
_style = style;
|
_style = style;
|
||||||
updateBounds();
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the style of this button.
|
* Returns the style of this button.
|
||||||
*/
|
*/
|
||||||
@@ -133,16 +133,16 @@ public class ButtonSprite extends Sprite
|
|||||||
{
|
{
|
||||||
return _style;
|
return _style;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the arc width for rounded buttons.
|
* Sets the arc width for rounded buttons.
|
||||||
*/
|
*/
|
||||||
public void setArcWidth (int arcWidth)
|
public void setArcWidth (int arcWidth)
|
||||||
{
|
{
|
||||||
_arcWidth = arcWidth;
|
_arcWidth = arcWidth;
|
||||||
updateBounds();
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the arc width for rounded buttons.
|
* Returns the arc width for rounded buttons.
|
||||||
*/
|
*/
|
||||||
@@ -150,16 +150,16 @@ public class ButtonSprite extends Sprite
|
|||||||
{
|
{
|
||||||
return _arcWidth;
|
return _arcWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the arc height for rounded buttons.
|
* Sets the arc height for rounded buttons.
|
||||||
*/
|
*/
|
||||||
public void setArcHeight (int arcHeight)
|
public void setArcHeight (int arcHeight)
|
||||||
{
|
{
|
||||||
_arcHeight = arcHeight;
|
_arcHeight = arcHeight;
|
||||||
updateBounds();
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the arc height for rounded buttons.
|
* Returns the arc height for rounded buttons.
|
||||||
*/
|
*/
|
||||||
@@ -167,7 +167,7 @@ public class ButtonSprite extends Sprite
|
|||||||
{
|
{
|
||||||
return _arcHeight;
|
return _arcHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the background color of this button.
|
* Sets the background color of this button.
|
||||||
*/
|
*/
|
||||||
@@ -175,7 +175,7 @@ public class ButtonSprite extends Sprite
|
|||||||
{
|
{
|
||||||
_backgroundColor = backgroundColor;
|
_backgroundColor = backgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the background color of this button.
|
* Returns the background color of this button.
|
||||||
*/
|
*/
|
||||||
@@ -183,7 +183,7 @@ public class ButtonSprite extends Sprite
|
|||||||
{
|
{
|
||||||
return _backgroundColor;
|
return _backgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the action command generated by this button.
|
* Sets the action command generated by this button.
|
||||||
*/
|
*/
|
||||||
@@ -191,13 +191,13 @@ public class ButtonSprite extends Sprite
|
|||||||
{
|
{
|
||||||
_actionCommand = actionCommand;
|
_actionCommand = actionCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface CommandSprite
|
// documentation inherited from interface CommandSprite
|
||||||
public String getActionCommand ()
|
public String getActionCommand ()
|
||||||
{
|
{
|
||||||
return _actionCommand;
|
return _actionCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the command argument generated by this button.
|
* Sets the command argument generated by this button.
|
||||||
*/
|
*/
|
||||||
@@ -205,13 +205,13 @@ public class ButtonSprite extends Sprite
|
|||||||
{
|
{
|
||||||
_commandArgument = commandArgument;
|
_commandArgument = commandArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface CommandSprite
|
// documentation inherited from interface CommandSprite
|
||||||
public Object getCommandArgument ()
|
public Object getCommandArgument ()
|
||||||
{
|
{
|
||||||
return _commandArgument;
|
return _commandArgument;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether or not this button is enabled.
|
* Sets whether or not this button is enabled.
|
||||||
*/
|
*/
|
||||||
@@ -222,13 +222,13 @@ public class ButtonSprite extends Sprite
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface DisableableSprite
|
// documentation inherited from interface DisableableSprite
|
||||||
public boolean isEnabled ()
|
public boolean isEnabled ()
|
||||||
{
|
{
|
||||||
return _enabled;
|
return _enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface ArmingSprite
|
// documentation inherited from interface ArmingSprite
|
||||||
public void setArmed (boolean pressed)
|
public void setArmed (boolean pressed)
|
||||||
{
|
{
|
||||||
@@ -237,15 +237,15 @@ public class ButtonSprite extends Sprite
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether or not this button appears pressed.
|
* Checks whether or not this button appears pressed.
|
||||||
*/
|
*/
|
||||||
public boolean isArmed ()
|
public boolean isArmed ()
|
||||||
{
|
{
|
||||||
return _pressed;
|
return _pressed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init ()
|
protected void init ()
|
||||||
{
|
{
|
||||||
@@ -271,17 +271,17 @@ public class ButtonSprite extends Sprite
|
|||||||
{
|
{
|
||||||
Color baseTextColor = _label.getTextColor(),
|
Color baseTextColor = _label.getTextColor(),
|
||||||
baseAlternateColor = _label.getAlternateColor();
|
baseAlternateColor = _label.getAlternateColor();
|
||||||
|
|
||||||
if (!_enabled) {
|
if (!_enabled) {
|
||||||
_label.setTextColor(baseTextColor.darker());
|
_label.setTextColor(baseTextColor.darker());
|
||||||
_label.setAlternateColor(baseAlternateColor.darker());
|
_label.setAlternateColor(baseAlternateColor.darker());
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (_style) {
|
switch (_style) {
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
gfx.setColor(_enabled ? _backgroundColor :
|
gfx.setColor(_enabled ? _backgroundColor :
|
||||||
_backgroundColor.darker());
|
_backgroundColor.darker());
|
||||||
gfx.fill3DRect(_bounds.x, _bounds.y, _bounds.width,
|
gfx.fill3DRect(_bounds.x, _bounds.y, _bounds.width,
|
||||||
_bounds.height, !_pressed);
|
_bounds.height, !_pressed);
|
||||||
_label.render(gfx, _bounds.x + (_pressed ? PADDING :
|
_label.render(gfx, _bounds.x + (_pressed ? PADDING :
|
||||||
PADDING - 1), _bounds.y + (_pressed ? PADDING :
|
PADDING - 1), _bounds.y + (_pressed ? PADDING :
|
||||||
@@ -296,7 +296,7 @@ public class ButtonSprite extends Sprite
|
|||||||
// draw foreground
|
// draw foreground
|
||||||
gfx.setColor(_enabled ? _backgroundColor :
|
gfx.setColor(_enabled ? _backgroundColor :
|
||||||
_backgroundColor.darker());
|
_backgroundColor.darker());
|
||||||
int innerBoundsX = _bounds.x+1, innerBoundsY = _bounds.y+1,
|
int innerBoundsX = _bounds.x+1, innerBoundsY = _bounds.y+1,
|
||||||
innerBoundsWidth = _bounds.width-2,
|
innerBoundsWidth = _bounds.width-2,
|
||||||
innerBoundsHeight = _bounds.height-2,
|
innerBoundsHeight = _bounds.height-2,
|
||||||
innerBoundsArcWidth = _arcWidth-2,
|
innerBoundsArcWidth = _arcWidth-2,
|
||||||
@@ -327,28 +327,28 @@ public class ButtonSprite extends Sprite
|
|||||||
innerBoundsArcWidth, innerBoundsArcHeight, 0, 90);
|
innerBoundsArcWidth, innerBoundsArcHeight, 0, 90);
|
||||||
gfx.drawLine(innerBoundsX + innerBoundsWidth - 1,
|
gfx.drawLine(innerBoundsX + innerBoundsWidth - 1,
|
||||||
innerBoundsY + innerBoundsArcHeight/2,
|
innerBoundsY + innerBoundsArcHeight/2,
|
||||||
innerBoundsX + innerBoundsWidth - 1, innerBoundsY +
|
innerBoundsX + innerBoundsWidth - 1, innerBoundsY +
|
||||||
innerBoundsHeight - innerBoundsArcHeight/2);
|
innerBoundsHeight - innerBoundsArcHeight/2);
|
||||||
// draw the lower left (light when pressed)
|
// draw the lower left (light when pressed)
|
||||||
gfx.setColor(_pressed ? brighter : darker);
|
gfx.setColor(_pressed ? brighter : darker);
|
||||||
gfx.drawLine(innerBoundsX, innerBoundsY +
|
gfx.drawLine(innerBoundsX, innerBoundsY +
|
||||||
innerBoundsArcHeight/2, innerBoundsX,
|
innerBoundsArcHeight/2, innerBoundsX,
|
||||||
innerBoundsY + innerBoundsHeight -
|
innerBoundsY + innerBoundsHeight -
|
||||||
innerBoundsArcHeight/2);
|
innerBoundsArcHeight/2);
|
||||||
gfx.drawArc(innerBoundsX, innerBoundsY + innerBoundsHeight -
|
gfx.drawArc(innerBoundsX, innerBoundsY + innerBoundsHeight -
|
||||||
innerBoundsArcHeight - 1,
|
innerBoundsArcHeight - 1,
|
||||||
innerBoundsArcWidth, innerBoundsArcHeight, 180, 90);
|
innerBoundsArcWidth, innerBoundsArcHeight, 180, 90);
|
||||||
gfx.drawLine(innerBoundsX + innerBoundsArcWidth/2,
|
gfx.drawLine(innerBoundsX + innerBoundsArcWidth/2,
|
||||||
innerBoundsY + innerBoundsHeight - 1,
|
innerBoundsY + innerBoundsHeight - 1,
|
||||||
innerBoundsX + innerBoundsWidth - innerBoundsArcWidth/2,
|
innerBoundsX + innerBoundsWidth - innerBoundsArcWidth/2,
|
||||||
innerBoundsY + innerBoundsHeight - 1);
|
innerBoundsY + innerBoundsHeight - 1);
|
||||||
SwingUtil.restoreAntiAliasing(gfx, aaState);
|
SwingUtil.restoreAntiAliasing(gfx, aaState);
|
||||||
_label.render(gfx, _bounds.x + PADDING + _arcWidth/2 -
|
_label.render(gfx, _bounds.x + PADDING + _arcWidth/2 -
|
||||||
(_pressed ? 2 : 1),
|
(_pressed ? 2 : 1),
|
||||||
_bounds.y + PADDING + (_pressed ? 1 : 0));
|
_bounds.y + PADDING + (_pressed ? 1 : 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_enabled) {
|
if (!_enabled) {
|
||||||
_label.setTextColor(baseTextColor);
|
_label.setTextColor(baseTextColor);
|
||||||
_label.setAlternateColor(baseAlternateColor);
|
_label.setAlternateColor(baseAlternateColor);
|
||||||
@@ -357,34 +357,34 @@ public class ButtonSprite extends Sprite
|
|||||||
|
|
||||||
/** The number of pixels to add between the text and the border. */
|
/** The number of pixels to add between the text and the border. */
|
||||||
protected static final int PADDING = 2;
|
protected static final int PADDING = 2;
|
||||||
|
|
||||||
/** The label associated with this sprite. */
|
/** The label associated with this sprite. */
|
||||||
protected Label _label;
|
protected Label _label;
|
||||||
|
|
||||||
/** The button style. */
|
/** The button style. */
|
||||||
protected int _style;
|
protected int _style;
|
||||||
|
|
||||||
/** The width of the corner arcs for rounded rectangle buttons. */
|
/** The width of the corner arcs for rounded rectangle buttons. */
|
||||||
protected int _arcWidth;
|
protected int _arcWidth;
|
||||||
|
|
||||||
/** The height of the corner arcs for rounded rectangle buttons. */
|
/** The height of the corner arcs for rounded rectangle buttons. */
|
||||||
protected int _arcHeight;
|
protected int _arcHeight;
|
||||||
|
|
||||||
/** The action command generated by this button. */
|
/** The action command generated by this button. */
|
||||||
protected String _actionCommand;
|
protected String _actionCommand;
|
||||||
|
|
||||||
/** The command argument generated by this button. */
|
/** The command argument generated by this button. */
|
||||||
protected Object _commandArgument;
|
protected Object _commandArgument;
|
||||||
|
|
||||||
/** The background color of this sprite. */
|
/** The background color of this sprite. */
|
||||||
protected Color _backgroundColor;
|
protected Color _backgroundColor;
|
||||||
|
|
||||||
/** The alternate (outline) color of this sprite. */
|
/** The alternate (outline) color of this sprite. */
|
||||||
protected Color _alternateColor;
|
protected Color _alternateColor;
|
||||||
|
|
||||||
/** Whether or not the button is currently enabled. */
|
/** Whether or not the button is currently enabled. */
|
||||||
protected boolean _enabled = true;
|
protected boolean _enabled = true;
|
||||||
|
|
||||||
/** Whether or not the button is currently pressed. */
|
/** Whether or not the button is currently pressed. */
|
||||||
protected boolean _pressed;
|
protected boolean _pressed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public class LabelSprite extends Sprite
|
|||||||
_bounds.width = size.width;
|
_bounds.width = size.width;
|
||||||
_bounds.height = size.height;
|
_bounds.height = size.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init ()
|
protected void init ()
|
||||||
{
|
{
|
||||||
@@ -81,7 +81,7 @@ public class LabelSprite extends Sprite
|
|||||||
}
|
}
|
||||||
|
|
||||||
// size the bounds to fit our label
|
// size the bounds to fit our label
|
||||||
updateBounds();
|
updateBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public class OrientableImageSprite extends ImageSprite
|
|||||||
*/
|
*/
|
||||||
public OrientableImageSprite ()
|
public OrientableImageSprite ()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new orientable image sprite.
|
* Creates a new orientable image sprite.
|
||||||
*
|
*
|
||||||
@@ -50,7 +50,7 @@ public class OrientableImageSprite extends ImageSprite
|
|||||||
{
|
{
|
||||||
super(image);
|
super(image);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new orientable image sprite.
|
* Creates a new orientable image sprite.
|
||||||
*
|
*
|
||||||
@@ -60,91 +60,91 @@ public class OrientableImageSprite extends ImageSprite
|
|||||||
{
|
{
|
||||||
super(frames);
|
super(frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes and returns the rotation transform for this
|
* Computes and returns the rotation transform for this
|
||||||
* sprite.
|
* sprite.
|
||||||
*
|
*
|
||||||
* @return the newly computed rotation transform
|
* @return the newly computed rotation transform
|
||||||
*/
|
*/
|
||||||
private AffineTransform getRotationTransform ()
|
private AffineTransform getRotationTransform ()
|
||||||
{
|
{
|
||||||
double theta;
|
double theta;
|
||||||
|
|
||||||
switch (_orient) {
|
switch (_orient) {
|
||||||
case NORTH:
|
case NORTH:
|
||||||
default:
|
default:
|
||||||
theta = 0.0;
|
theta = 0.0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOUTH:
|
case SOUTH:
|
||||||
theta = Math.PI;
|
theta = Math.PI;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EAST:
|
case EAST:
|
||||||
theta = Math.PI*0.5;
|
theta = Math.PI*0.5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WEST:
|
case WEST:
|
||||||
theta = -Math.PI*0.5;
|
theta = -Math.PI*0.5;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NORTHEAST:
|
case NORTHEAST:
|
||||||
theta = Math.PI*0.25;
|
theta = Math.PI*0.25;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NORTHWEST:
|
case NORTHWEST:
|
||||||
theta = -Math.PI*0.25;
|
theta = -Math.PI*0.25;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOUTHEAST:
|
case SOUTHEAST:
|
||||||
theta = Math.PI*0.75;
|
theta = Math.PI*0.75;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOUTHWEST:
|
case SOUTHWEST:
|
||||||
theta = -Math.PI*0.75;
|
theta = -Math.PI*0.75;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NORTHNORTHEAST:
|
case NORTHNORTHEAST:
|
||||||
theta = -Math.PI*0.125;
|
theta = -Math.PI*0.125;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NORTHNORTHWEST:
|
case NORTHNORTHWEST:
|
||||||
theta = Math.PI*0.125;
|
theta = Math.PI*0.125;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOUTHSOUTHEAST:
|
case SOUTHSOUTHEAST:
|
||||||
theta = -Math.PI*0.875;
|
theta = -Math.PI*0.875;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SOUTHSOUTHWEST:
|
case SOUTHSOUTHWEST:
|
||||||
theta = Math.PI*0.875;
|
theta = Math.PI*0.875;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EASTNORTHEAST:
|
case EASTNORTHEAST:
|
||||||
theta = -Math.PI*0.375;
|
theta = -Math.PI*0.375;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EASTSOUTHEAST:
|
case EASTSOUTHEAST:
|
||||||
theta = -Math.PI*0.625;
|
theta = -Math.PI*0.625;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WESTNORTHWEST:
|
case WESTNORTHWEST:
|
||||||
theta = Math.PI*0.375;
|
theta = Math.PI*0.375;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WESTSOUTHWEST:
|
case WESTSOUTHWEST:
|
||||||
theta = Math.PI*0.625;
|
theta = Math.PI*0.625;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return AffineTransform.getRotateInstance(
|
return AffineTransform.getRotateInstance(
|
||||||
theta,
|
theta,
|
||||||
(_ox - _oxoff) + _frames.getWidth(_frameIdx)/2,
|
(_ox - _oxoff) + _frames.getWidth(_frameIdx)/2,
|
||||||
(_oy - _oyoff) + _frames.getHeight(_frameIdx)/2
|
(_oy - _oyoff) + _frames.getHeight(_frameIdx)/2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void accomodateFrame (int frameIdx, int width, int height)
|
protected void accomodateFrame (int frameIdx, int width, int height)
|
||||||
{
|
{
|
||||||
@@ -156,39 +156,39 @@ public class OrientableImageSprite extends ImageSprite
|
|||||||
height
|
height
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
area.transform(getRotationTransform());
|
area.transform(getRotationTransform());
|
||||||
|
|
||||||
_bounds = area.getBounds();
|
_bounds = area.getBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOrientation (int orient)
|
public void setOrientation (int orient)
|
||||||
{
|
{
|
||||||
super.setOrientation(orient);
|
super.setOrientation(orient);
|
||||||
|
|
||||||
layout();
|
layout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint (Graphics2D graphics)
|
public void paint (Graphics2D graphics)
|
||||||
{
|
{
|
||||||
AffineTransform at = graphics.getTransform();
|
AffineTransform at = graphics.getTransform();
|
||||||
|
|
||||||
graphics.transform(getRotationTransform());
|
graphics.transform(getRotationTransform());
|
||||||
|
|
||||||
if (_frames != null) {
|
if (_frames != null) {
|
||||||
_frames.paintFrame(
|
_frames.paintFrame(
|
||||||
graphics,
|
graphics,
|
||||||
_frameIdx,
|
_frameIdx,
|
||||||
_ox - _oxoff,
|
_ox - _oxoff,
|
||||||
_oy - _oyoff
|
_oy - _oyoff
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
super.paint(graphics);
|
super.paint(graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics.setTransform(at);
|
graphics.setTransform(at);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class SpriteIcon implements Icon
|
|||||||
y + _sprite.getYOffset() + _padding);
|
y + _sprite.getYOffset() + _padding);
|
||||||
_sprite.paint((Graphics2D)g);
|
_sprite.paint((Graphics2D)g);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int getIconWidth ()
|
public int getIconWidth ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public class SpriteManager extends AbstractMediaManager
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a sprite to the set of sprites managed by this manager.
|
* Add a sprite to the set of sprites managed by this manager.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ public class SwissArmyTileSet extends TileSet
|
|||||||
{
|
{
|
||||||
// compute our number of tiles
|
// compute our number of tiles
|
||||||
_numTiles = 0;
|
_numTiles = 0;
|
||||||
for (int i = 0; i < _tileCounts.length; i++) {
|
for (int count : _tileCounts) {
|
||||||
_numTiles += _tileCounts[i];
|
_numTiles += count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class TileIcon implements Icon
|
|||||||
{
|
{
|
||||||
_tile.paint((Graphics2D)g, x, y);
|
_tile.paint((Graphics2D)g, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int getIconWidth ()
|
public int getIconWidth ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ import static com.threerings.media.Log.log;
|
|||||||
* it can provide a tileset repository which loads up tilesets using whatever repository mechanism
|
* it can provide a tileset repository which loads up tilesets using whatever repository mechanism
|
||||||
* is implemented by the supplied repository. In the latter case, tilesets are loaded by a unique
|
* is implemented by the supplied repository. In the latter case, tilesets are loaded by a unique
|
||||||
* identifier.
|
* identifier.
|
||||||
*
|
*
|
||||||
* <p> Loading tilesets by hand is intended for things like toolbar icons or games with a single
|
* <p> Loading tilesets by hand is intended for things like toolbar icons or games with a single
|
||||||
* set of tiles (think Stratego, for example). Loading tilesets from a repository supports games
|
* set of tiles (think Stratego, for example). Loading tilesets from a repository supports games
|
||||||
* with vast numbers of tiles to which more tiles may be added on the fly (think the tiles for an
|
* with vast numbers of tiles to which more tiles may be added on the fly (think the tiles for an
|
||||||
@@ -51,7 +51,7 @@ public class TileManager
|
|||||||
/**
|
/**
|
||||||
* Creates a tile manager and provides it with a reference to the image manager from which it
|
* Creates a tile manager and provides it with a reference to the image manager from which it
|
||||||
* will load tileset images.
|
* will load tileset images.
|
||||||
*
|
*
|
||||||
* @param imgr the image manager via which the tile manager will decode and cache images.
|
* @param imgr the image manager via which the tile manager will decode and cache images.
|
||||||
*/
|
*/
|
||||||
public TileManager (ImageManager imgr)
|
public TileManager (ImageManager imgr)
|
||||||
@@ -145,9 +145,9 @@ public class TileManager
|
|||||||
/**
|
/**
|
||||||
* Returns the tileset with the specified id. Tilesets are fetched from the tileset repository
|
* Returns the tileset with the specified id. Tilesets are fetched from the tileset repository
|
||||||
* supplied via {@link #setTileSetRepository}, and are subsequently cached.
|
* supplied via {@link #setTileSetRepository}, and are subsequently cached.
|
||||||
*
|
*
|
||||||
* @param tileSetId the unique identifier for the desired tileset.
|
* @param tileSetId the unique identifier for the desired tileset.
|
||||||
*
|
*
|
||||||
* @exception NoSuchTileSetException thrown if no tileset exists with the specified id or if
|
* @exception NoSuchTileSetException thrown if no tileset exists with the specified id or if
|
||||||
* an underlying error occurs with the tileset repository's persistence mechanism.
|
* an underlying error occurs with the tileset repository's persistence mechanism.
|
||||||
*/
|
*/
|
||||||
@@ -169,7 +169,7 @@ public class TileManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the tileset with the specified name.
|
* Returns the tileset with the specified name.
|
||||||
*
|
*
|
||||||
* @throws NoSuchTileSetException if no tileset with the specified name is available via our
|
* @throws NoSuchTileSetException if no tileset with the specified name is available via our
|
||||||
* configured tile set repository.
|
* configured tile set repository.
|
||||||
*/
|
*/
|
||||||
@@ -191,7 +191,7 @@ public class TileManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link Tile} object with the specified fully qualified tile id.
|
* Returns the {@link Tile} object with the specified fully qualified tile id.
|
||||||
*
|
*
|
||||||
* @see TileUtil#getFQTileId
|
* @see TileUtil#getFQTileId
|
||||||
*/
|
*/
|
||||||
public Tile getTile (int fqTileId)
|
public Tile getTile (int fqTileId)
|
||||||
@@ -203,7 +203,7 @@ public class TileManager
|
|||||||
/**
|
/**
|
||||||
* Returns the {@link Tile} object with the specified fully qualified tile id. The supplied
|
* Returns the {@link Tile} object with the specified fully qualified tile id. The supplied
|
||||||
* colorizer will be used to recolor the tile.
|
* colorizer will be used to recolor the tile.
|
||||||
*
|
*
|
||||||
* @see TileUtil#getFQTileId
|
* @see TileUtil#getFQTileId
|
||||||
*/
|
*/
|
||||||
public Tile getTile (int fqTileId, TileSet.Colorizer rizer)
|
public Tile getTile (int fqTileId, TileSet.Colorizer rizer)
|
||||||
@@ -214,10 +214,10 @@ public class TileManager
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link Tile} object from the specified tileset at the specified index.
|
* Returns the {@link Tile} object from the specified tileset at the specified index.
|
||||||
*
|
*
|
||||||
* @param tileSetId the tileset id.
|
* @param tileSetId the tileset id.
|
||||||
* @param tileIndex the index of the tile to be retrieved.
|
* @param tileIndex the index of the tile to be retrieved.
|
||||||
*
|
*
|
||||||
* @return the tile object.
|
* @return the tile object.
|
||||||
*/
|
*/
|
||||||
public Tile getTile (int tileSetId, int tileIndex, TileSet.Colorizer rizer)
|
public Tile getTile (int tileSetId, int tileIndex, TileSet.Colorizer rizer)
|
||||||
|
|||||||
@@ -88,21 +88,21 @@ public class DirectoryTileSetBundler extends TileSetBundler
|
|||||||
// write the trimmed tileset image to the destination output stream
|
// write the trimmed tileset image to the destination output stream
|
||||||
File outFile = new File(target, imagePath);
|
File outFile = new File(target, imagePath);
|
||||||
FileOutputStream fout = null;
|
FileOutputStream fout = null;
|
||||||
|
|
||||||
if (outFile.lastModified() > newestMod) {
|
if (outFile.lastModified() > newestMod) {
|
||||||
// Our file's newer than the newest bundle mod - up to date.
|
// Our file's newer than the newest bundle mod - up to date.
|
||||||
// So don't actually do anything
|
// So don't actually do anything
|
||||||
|
|
||||||
// TODO: Ideally, we'd like to skip re-trimming altogether, since that's
|
// TODO: Ideally, we'd like to skip re-trimming altogether, since that's
|
||||||
// expensive, but for the moment, we're at least doing half as much by
|
// expensive, but for the moment, we're at least doing half as much by
|
||||||
// not writing out the trimmed image.
|
// not writing out the trimmed image.
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// It's changed, so let's open the file & do all that jazz
|
// It's changed, so let's open the file & do all that jazz
|
||||||
outFile.getParentFile().mkdirs();
|
outFile.getParentFile().mkdirs();
|
||||||
fout = new FileOutputStream(outFile);
|
fout = new FileOutputStream(outFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrimmedObjectTileSet tset =
|
TrimmedObjectTileSet tset =
|
||||||
TrimmedObjectTileSet.trimObjectTileSet((ObjectTileSet)set, fout, "png");
|
TrimmedObjectTileSet.trimObjectTileSet((ObjectTileSet)set, fout, "png");
|
||||||
tset.setImagePath(imagePath);
|
tset.setImagePath(imagePath);
|
||||||
|
|||||||
@@ -49,17 +49,17 @@ public class DumpBundle
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (String arg : args) {
|
||||||
// oh the hackery
|
// oh the hackery
|
||||||
if (args[i].equals("-tiles")) {
|
if (arg.equals("-tiles")) {
|
||||||
dumpTiles = true;
|
dumpTiles = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(args[i]);
|
File file = new File(arg);
|
||||||
try {
|
try {
|
||||||
TileSetBundle tsb = null;
|
TileSetBundle tsb = null;
|
||||||
if (args[i].endsWith(".jar")) {
|
if (arg.endsWith(".jar")) {
|
||||||
ResourceBundle bundle = new FileResourceBundle(file);
|
ResourceBundle bundle = new FileResourceBundle(file);
|
||||||
tsb = BundleUtil.extractBundle(bundle);
|
tsb = BundleUtil.extractBundle(bundle);
|
||||||
tsb.init(bundle);
|
tsb.init(bundle);
|
||||||
@@ -81,7 +81,7 @@ public class DumpBundle
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.err.println("Error dumping bundle [path=" + args[i] +
|
System.err.println("Error dumping bundle [path=" + arg +
|
||||||
", error=" + e + "].");
|
", error=" + e + "].");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ public class ObjectTileSetRuleSet extends SwissArmyTileSetRuleSet
|
|||||||
set.setSpotOrients(sorients);
|
set.setSpotOrients(sorients);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
digester.addRule(
|
digester.addRule(
|
||||||
_path + "/constraints",
|
_path + "/constraints",
|
||||||
new CallMethodSpecialRule() {
|
new CallMethodSpecialRule() {
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public abstract class TileSetRuleSet
|
|||||||
public String getPath(){
|
public String getPath(){
|
||||||
return _path;
|
return _path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instructs the tileset rule set to match tilesets with the supplied
|
* Instructs the tileset rule set to match tilesets with the supplied
|
||||||
* prefix. For example, passing a prefix of
|
* prefix. For example, passing a prefix of
|
||||||
@@ -129,9 +129,9 @@ public abstract class TileSetRuleSet
|
|||||||
*/
|
*/
|
||||||
protected abstract Class<? extends TileSet> getTileSetClass ();
|
protected abstract Class<? extends TileSet> getTileSetClass ();
|
||||||
|
|
||||||
/** The tileset path we append to the prefix to get the full path. */
|
/** The tileset path we append to the prefix to get the full path. */
|
||||||
protected String _tilesetPath = TILESET_PATH;
|
protected String _tilesetPath = TILESET_PATH;
|
||||||
|
|
||||||
/** The full path at which me match our tilesets. */
|
/** The full path at which me match our tilesets. */
|
||||||
protected String _path;
|
protected String _path;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,11 +47,11 @@ public class UniformTileSetRuleSet extends TileSetRuleSet
|
|||||||
public UniformTileSetRuleSet(){
|
public UniformTileSetRuleSet(){
|
||||||
this(TILESET_PATH);
|
this(TILESET_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UniformTileSetRuleSet(String tilesetPath){
|
public UniformTileSetRuleSet(String tilesetPath){
|
||||||
_tilesetPath = tilesetPath;
|
_tilesetPath = tilesetPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addRuleInstances (Digester digester)
|
public void addRuleInstances (Digester digester)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -71,12 +71,12 @@ public class ModeUtil
|
|||||||
|
|
||||||
// but we only add modes that meet our minimum requirements
|
// but we only add modes that meet our minimum requirements
|
||||||
TreeSet<DisplayMode> mset = new TreeSet<DisplayMode>(mcomp);
|
TreeSet<DisplayMode> mset = new TreeSet<DisplayMode>(mcomp);
|
||||||
for (int i = 0; i < modes.length; i++) {
|
for (DisplayMode mode : modes) {
|
||||||
if (modes[i].getWidth() == width &&
|
if (mode.getWidth() == width &&
|
||||||
modes[i].getHeight() == height &&
|
mode.getHeight() == height &&
|
||||||
modes[i].getBitDepth() >= minimumDepth &&
|
mode.getBitDepth() >= minimumDepth &&
|
||||||
modes[i].getRefreshRate() <= 75) {
|
mode.getRefreshRate() <= 75) {
|
||||||
mset.add(modes[i]);
|
mset.add(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class SceneBlockResolver extends LoopingThread
|
|||||||
{
|
{
|
||||||
super("SceneBlockResolver");
|
super("SceneBlockResolver");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queues up a scene block for resolution.
|
* Queues up a scene block for resolution.
|
||||||
*/
|
*/
|
||||||
@@ -51,7 +51,7 @@ public class SceneBlockResolver extends LoopingThread
|
|||||||
_queue.append(block);
|
_queue.append(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Temporarily suspends the scene block resolution thread.
|
* Temporarily suspends the scene block resolution thread.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ public class SceneObject
|
|||||||
refreshObjectTile(panel.getSceneMetrics(), panel.getTileManager(),
|
refreshObjectTile(panel.getSceneMetrics(), panel.getTileManager(),
|
||||||
panel.getColorizer(info));
|
panel.getColorizer(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reloads and recolorizes our object tile. It is not intended for the actual object tile used
|
* Reloads and recolorizes our object tile. It is not intended for the actual object tile used
|
||||||
* by a scene object to change in its lifetime, only attributes of that object like its
|
* by a scene object to change in its lifetime, only attributes of that object like its
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ package com.threerings.miso.client;
|
|||||||
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exposes an operation to be applied to tiles by {@link TileOpApplicator}.
|
* Exposes an operation to be applied to tiles by {@link TileOpApplicator}.
|
||||||
*/
|
*/
|
||||||
public interface TileOp
|
public interface TileOp
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -130,8 +130,7 @@ public class SimpleMisoSceneModel extends MisoSceneModel
|
|||||||
public void getObjects (Rectangle region, ObjectSet set)
|
public void getObjects (Rectangle region, ObjectSet set)
|
||||||
{
|
{
|
||||||
// first look for intersecting interesting objects
|
// first look for intersecting interesting objects
|
||||||
for (int ii = 0; ii < objectInfo.length; ii++) {
|
for (ObjectInfo info : objectInfo) {
|
||||||
ObjectInfo info = objectInfo[ii];
|
|
||||||
if (region.contains(info.x, info.y)) {
|
if (region.contains(info.x, info.y)) {
|
||||||
set.insert(info);
|
set.insert(info);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ public class SimpleMisoSceneWriter implements NestableWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// write our uninteresting object tile information
|
// write our uninteresting object tile information
|
||||||
for (int ii = 0; ii < model.objectInfo.length; ii++) {
|
for (ObjectInfo info : model.objectInfo) {
|
||||||
ObjectInfo info = model.objectInfo[ii];
|
|
||||||
AttributesImpl attrs = new AttributesImpl();
|
AttributesImpl attrs = new AttributesImpl();
|
||||||
attrs.addAttribute("", "tileId", "", "",
|
attrs.addAttribute("", "tileId", "", "",
|
||||||
String.valueOf(info.tileId));
|
String.valueOf(info.tileId));
|
||||||
|
|||||||
@@ -96,8 +96,8 @@ public class SparseMisoSceneWriter implements NestableWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
// write our interesting object tile information
|
// write our interesting object tile information
|
||||||
for (int ii = 0; ii < sect.objectInfo.length; ii++) {
|
for (ObjectInfo element : sect.objectInfo) {
|
||||||
writeInterestingObject(sect.objectInfo[ii], writer);
|
writeInterestingObject(element, writer);
|
||||||
}
|
}
|
||||||
writer.endElement("objects");
|
writer.endElement("objects");
|
||||||
writer.endElement("section");
|
writer.endElement("section");
|
||||||
@@ -106,7 +106,7 @@ public class SparseMisoSceneWriter implements NestableWriter
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes <code>info</code> out to <code>writer</code>.
|
* Writes <code>info</code> out to <code>writer</code>.
|
||||||
*/
|
*/
|
||||||
public static void writeInterestingObject (ObjectInfo info, DataWriter writer)
|
public static void writeInterestingObject (ObjectInfo info, DataWriter writer)
|
||||||
throws SAXException
|
throws SAXException
|
||||||
|
|||||||
@@ -154,13 +154,13 @@ public class Handler extends URLStreamHandler
|
|||||||
String[] bits = StringUtil.split(query, "&");
|
String[] bits = StringUtil.split(query, "&");
|
||||||
int width = -1, height = -1, tidx = -1;
|
int width = -1, height = -1, tidx = -1;
|
||||||
try {
|
try {
|
||||||
for (int ii = 0; ii < bits.length; ii++) {
|
for (String bit : bits) {
|
||||||
if (bits[ii].startsWith("width=")) {
|
if (bit.startsWith("width=")) {
|
||||||
width = Integer.parseInt(bits[ii].substring(6));
|
width = Integer.parseInt(bit.substring(6));
|
||||||
} else if (bits[ii].startsWith("height=")) {
|
} else if (bit.startsWith("height=")) {
|
||||||
height = Integer.parseInt(bits[ii].substring(7));
|
height = Integer.parseInt(bit.substring(7));
|
||||||
} else if (bits[ii].startsWith("tile=")) {
|
} else if (bit.startsWith("tile=")) {
|
||||||
tidx = Integer.parseInt(bits[ii].substring(5));
|
tidx = Integer.parseInt(bit.substring(5));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException nfe) {
|
} catch (NumberFormatException nfe) {
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ public class BrowserUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
// if we're on windows, make a last ditch effort
|
// if we're on windows, make a last ditch effort
|
||||||
String[] cmd = new String[] {
|
String[] cmd = new String[] {
|
||||||
"C:\\Program Files\\Internet Explorer\\" +
|
"C:\\Program Files\\Internet Explorer\\" +
|
||||||
"IEXPLORE.EXE", "\"" + _url.toString() + "\""};
|
"IEXPLORE.EXE", "\"" + _url.toString() + "\""};
|
||||||
Process process = Runtime.getRuntime().exec(cmd);
|
Process process = Runtime.getRuntime().exec(cmd);
|
||||||
|
|||||||
@@ -232,7 +232,7 @@ public abstract class IdleTracker
|
|||||||
protected static final int ABANDONED = 2;
|
protected static final int ABANDONED = 2;
|
||||||
|
|
||||||
// we want to observe all mouse and keyboard events
|
// we want to observe all mouse and keyboard events
|
||||||
protected static final long EVENT_MASK =
|
protected static final long EVENT_MASK =
|
||||||
AWTEvent.MOUSE_EVENT_MASK |
|
AWTEvent.MOUSE_EVENT_MASK |
|
||||||
AWTEvent.MOUSE_MOTION_EVENT_MASK |
|
AWTEvent.MOUSE_MOTION_EVENT_MASK |
|
||||||
AWTEvent.MOUSE_WHEEL_EVENT_MASK |
|
AWTEvent.MOUSE_WHEEL_EVENT_MASK |
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public interface KeyTranslator
|
|||||||
* or both.
|
* or both.
|
||||||
*/
|
*/
|
||||||
public boolean hasCommand (int keyCode);
|
public boolean hasCommand (int keyCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether there is an action command for the key corresponding to the given character
|
* Returns whether there is an action command for the key corresponding to the given character
|
||||||
* in the case of a keyTyped event corresponding to it.
|
* in the case of a keyTyped event corresponding to it.
|
||||||
@@ -47,7 +47,7 @@ public interface KeyTranslator
|
|||||||
* the given key code, or <code>null</code> if there is no associated command.
|
* the given key code, or <code>null</code> if there is no associated command.
|
||||||
*/
|
*/
|
||||||
public String getPressCommand (int keyCode);
|
public String getPressCommand (int keyCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the action command string associated with a key press of the given character,
|
* Returns the action command string associated with a key press of the given character,
|
||||||
* or <code>null</code> if there is no associated command.
|
* or <code>null</code> if there is no associated command.
|
||||||
@@ -59,19 +59,19 @@ public interface KeyTranslator
|
|||||||
* the given key code, or <code>null</code> if there is no associated command.
|
* the given key code, or <code>null</code> if there is no associated command.
|
||||||
*/
|
*/
|
||||||
public String getReleaseCommand (int keyCode);
|
public String getReleaseCommand (int keyCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the action command string associated with a key release of the given character,
|
* Returns the action command string associated with a key release of the given character,
|
||||||
* or <code>null</code> if there is no associated command.
|
* or <code>null</code> if there is no associated command.
|
||||||
*/
|
*/
|
||||||
public String getReleaseCommand (char ch);
|
public String getReleaseCommand (char ch);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of times each second that key presses are to be automatically repeated
|
* Returns the number of times each second that key presses are to be automatically repeated
|
||||||
* while the key is held down, or <code>0</code> to disable auto-repeat for the key.
|
* while the key is held down, or <code>0</code> to disable auto-repeat for the key.
|
||||||
*/
|
*/
|
||||||
public int getRepeatRate (int keyCode);
|
public int getRepeatRate (int keyCode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of times each second that key presses are to be automatically repeated
|
* Returns the number of times each second that key presses are to be automatically repeated
|
||||||
* while the key is held down, or <code>0</code> to disable auto-repeat for the key.
|
* while the key is held down, or <code>0</code> to disable auto-repeat for the key.
|
||||||
@@ -89,7 +89,7 @@ public interface KeyTranslator
|
|||||||
* specified key.
|
* specified key.
|
||||||
*/
|
*/
|
||||||
public long getRepeatDelay (char ch);
|
public long getRepeatDelay (char ch);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an iterator that iterates over the available press commands.
|
* Returns an iterator that iterates over the available press commands.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class Keyboard
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the native keyboard interface is available.
|
* Returns whether the native keyboard interface is available.
|
||||||
*/
|
*/
|
||||||
public static boolean isAvailable ()
|
public static boolean isAvailable ()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user