Whitespace
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1167 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -290,33 +290,29 @@ public class BundledComponentRepository
|
|||||||
/**
|
/**
|
||||||
* Constructs an instance that will obtain image data from the specified resource bundle.
|
* Constructs an instance that will obtain image data from the specified resource bundle.
|
||||||
*/
|
*/
|
||||||
public ResourceBundleProvider (ImageManager imgr, ResourceBundle bundle)
|
public ResourceBundleProvider (ImageManager imgr, ResourceBundle bundle) {
|
||||||
{
|
|
||||||
super(imgr, (String)null);
|
super(imgr, (String)null);
|
||||||
_dprov = this;
|
_dprov = this;
|
||||||
_bundle = bundle;
|
_bundle = bundle;
|
||||||
}
|
}
|
||||||
|
|
||||||
// from interface ImageDataProvider
|
// from interface ImageDataProvider
|
||||||
public String getIdent ()
|
public String getIdent () {
|
||||||
{
|
|
||||||
return "bcr:" + _bundle.getIdent();
|
return "bcr:" + _bundle.getIdent();
|
||||||
}
|
}
|
||||||
|
|
||||||
// from interface ImageDataProvider
|
// from interface ImageDataProvider
|
||||||
public BufferedImage loadImage (String path) throws IOException
|
public BufferedImage loadImage (String path) throws IOException {
|
||||||
{
|
|
||||||
return _bundle.getImageResource(path, true);
|
return _bundle.getImageResource(path, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// from interface FrameProvider
|
// from interface FrameProvider
|
||||||
public ActionFrames getFrames (CharacterComponent component, String action, String type)
|
public ActionFrames getFrames (CharacterComponent component, String action, String type) {
|
||||||
{
|
|
||||||
// obtain the action sequence definition for this action
|
// obtain the action sequence definition for this action
|
||||||
ActionSequence actseq = _actions.get(action);
|
ActionSequence actseq = _actions.get(action);
|
||||||
if (actseq == null) {
|
if (actseq == null) {
|
||||||
log.warning("Missing action sequence definition [action=" + action +
|
log.warning("Missing action sequence definition",
|
||||||
", component=" + component + "].");
|
"action", action, "component", component);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -373,15 +369,15 @@ public class BundledComponentRepository
|
|||||||
return createTileSetFrameImage(aset, actseq);
|
return createTileSetFrameImage(aset, actseq);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Error loading tset for action '" + imgpath + "' " + component + ".", e);
|
log.warning("Error loading tset for action '" + imgpath + "' " + component + ".",
|
||||||
|
e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// from interface FrameProvider
|
// from interface FrameProvider
|
||||||
public String getFramePath (CharacterComponent component, String action, String type,
|
public String getFramePath (CharacterComponent component, String action, String type,
|
||||||
Set<String> existentPaths)
|
Set<String> existentPaths) {
|
||||||
{
|
|
||||||
String actionPath = makePath(component, action, type);
|
String actionPath = makePath(component, action, type);
|
||||||
if(!existentPaths.contains(actionPath)) {
|
if(!existentPaths.contains(actionPath)) {
|
||||||
return makePath(component, ActionSequence.DEFAULT_SEQUENCE, type);
|
return makePath(component, ActionSequence.DEFAULT_SEQUENCE, type);
|
||||||
@@ -389,8 +385,7 @@ public class BundledComponentRepository
|
|||||||
return actionPath;
|
return actionPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String makePath(CharacterComponent component, String action, String type)
|
protected String makePath(CharacterComponent component, String action, String type) {
|
||||||
{
|
|
||||||
String imgpath = action;
|
String imgpath = action;
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
imgpath += "_" + type;
|
imgpath += "_" + type;
|
||||||
@@ -400,8 +395,7 @@ public class BundledComponentRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mirage getTileImage (String path, Rectangle bounds, Colorization[] zations)
|
public Mirage getTileImage (String path, Rectangle bounds, Colorization[] zations) {
|
||||||
{
|
|
||||||
// we don't need our images prepared for screen rendering
|
// we don't need our images prepared for screen rendering
|
||||||
BufferedImage src = _imgr.getImage(getImageKey(path), zations);
|
BufferedImage src = _imgr.getImage(getImageKey(path), zations);
|
||||||
float percentageOfDataBuffer = 1;
|
float percentageOfDataBuffer = 1;
|
||||||
@@ -429,8 +423,7 @@ public class BundledComponentRepository
|
|||||||
* Constructs a tileset frame image with the specified tileset and for the specified
|
* Constructs a tileset frame image with the specified tileset and for the specified
|
||||||
* orientation.
|
* orientation.
|
||||||
*/
|
*/
|
||||||
public TileSetFrameImage (TileSet set, ActionSequence actseq)
|
public TileSetFrameImage (TileSet set, ActionSequence actseq) {
|
||||||
{
|
|
||||||
this(set, actseq, 0, 0);
|
this(set, actseq, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,8 +431,7 @@ public class BundledComponentRepository
|
|||||||
* Constructs a tileset frame image with the specified tileset and for the specified
|
* Constructs a tileset frame image with the specified tileset and for the specified
|
||||||
* orientation, with an optional translation.
|
* orientation, with an optional translation.
|
||||||
*/
|
*/
|
||||||
public TileSetFrameImage (TileSet set, ActionSequence actseq, int dx, int dy)
|
public TileSetFrameImage (TileSet set, ActionSequence actseq, int dx, int dy) {
|
||||||
{
|
|
||||||
_set = set;
|
_set = set;
|
||||||
_actseq = actseq;
|
_actseq = actseq;
|
||||||
_dx = dx;
|
_dx = dx;
|
||||||
@@ -456,14 +448,12 @@ public class BundledComponentRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int getOrientationCount ()
|
public int getOrientationCount () {
|
||||||
{
|
|
||||||
return _ocount;
|
return _ocount;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public TrimmedMultiFrameImage getFrames (final int orient)
|
public TrimmedMultiFrameImage getFrames (final int orient) {
|
||||||
{
|
|
||||||
return new TrimmedMultiFrameImage() {
|
return new TrimmedMultiFrameImage() {
|
||||||
public int getFrameCount () {
|
public int getFrameCount () {
|
||||||
return _fcount;
|
return _fcount;
|
||||||
@@ -491,8 +481,7 @@ public class BundledComponentRepository
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void paintTile(Graphics2D g, int orient, int index, int x, int y)
|
protected void paintTile(Graphics2D g, int orient, int index, int x, int y) {
|
||||||
{
|
|
||||||
_set.getTile(getTileIndex(orient, index)).paint(g, x + _dx, y + _dy);
|
_set.getTile(getTileIndex(orient, index)).paint(g, x + _dx, y + _dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,36 +496,30 @@ public class BundledComponentRepository
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int getXOrigin (int orient, int index)
|
public int getXOrigin (int orient, int index) {
|
||||||
{
|
|
||||||
return _actseq.origin.x;
|
return _actseq.origin.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int getYOrigin (int orient, int index)
|
public int getYOrigin (int orient, int index) {
|
||||||
{
|
|
||||||
return _actseq.origin.y;
|
return _actseq.origin.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public ActionFrames cloneColorized (Colorization[] zations)
|
public ActionFrames cloneColorized (Colorization[] zations) {
|
||||||
{
|
|
||||||
return new TileSetFrameImage(_set.clone(zations), _actseq);
|
return new TileSetFrameImage(_set.clone(zations), _actseq);
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public ActionFrames cloneTranslated (int dx, int dy)
|
public ActionFrames cloneTranslated (int dx, int dy) {
|
||||||
{
|
|
||||||
return new TileSetFrameImage(_set, _actseq, dx, dy);
|
return new TileSetFrameImage(_set, _actseq, dx, dy);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getTileIndex (int orient, int index)
|
protected int getTileIndex (int orient, int index) {
|
||||||
{
|
|
||||||
return _orients.get(orient) * _fcount + index;
|
return _orients.get(orient) * _fcount + index;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Tile getTile (int orient, int index)
|
public Tile getTile (int orient, int index) {
|
||||||
{
|
|
||||||
return _set.getTile(getTileIndex(orient, index));
|
return _set.getTile(getTileIndex(orient, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,15 +58,14 @@ public class CastUtil
|
|||||||
|
|
||||||
// make sure the component class exists
|
// make sure the component class exists
|
||||||
if (cclass == null) {
|
if (cclass == null) {
|
||||||
log.warning("Missing definition for component class " +
|
log.warning("Missing definition for component class", "class", cname);
|
||||||
"[class=" + cname + "].");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure there are some components in this class
|
// make sure there are some components in this class
|
||||||
Iterator<Integer> iter = crepo.enumerateComponentIds(cclass);
|
Iterator<Integer> iter = crepo.enumerateComponentIds(cclass);
|
||||||
if (!iter.hasNext()) {
|
if (!iter.hasNext()) {
|
||||||
log.info("Skipping class for which we have no components [class=" + cclass + "].");
|
log.info("Skipping class for which we have no components", "class", cclass);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,7 +98,7 @@ public class CastUtil
|
|||||||
int idx = RandomUtil.getInt(choices.size());
|
int idx = RandomUtil.getInt(choices.size());
|
||||||
components[ii] = choices.get(idx).intValue();
|
components[ii] = choices.get(idx).intValue();
|
||||||
} else {
|
} else {
|
||||||
log.info("Have no components in class [class=" + cclass + "].");
|
log.info("Have no components in class", "class", cclass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ import com.samskivert.swing.util.SwingUtil;
|
|||||||
import static com.threerings.media.Log.log;
|
import static com.threerings.media.Log.log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A utility class for positioning animations such that they don't overlap,
|
* A utility class for positioning animations such that they don't overlap, as best as possible.
|
||||||
* as best as possible.
|
|
||||||
*/
|
*/
|
||||||
public class AnimationArranger
|
public class AnimationArranger
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,9 +37,8 @@ public interface AnimationFrameSequencer extends FrameSequencer
|
|||||||
public void setAnimation (Animation anim);
|
public void setAnimation (Animation anim);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sequencer that can step through a series of frames in any order
|
* A sequencer that can step through a series of frames in any order and speed and notify (via
|
||||||
* and speed and notify (via {@link SequencedAnimationObserver}) when
|
* {@link SequencedAnimationObserver}) when specific frames are reached.
|
||||||
* specific frames are reached.
|
|
||||||
*/
|
*/
|
||||||
public static class MultiFunction implements AnimationFrameSequencer
|
public static class MultiFunction implements AnimationFrameSequencer
|
||||||
{
|
{
|
||||||
@@ -48,12 +47,10 @@ public interface AnimationFrameSequencer extends FrameSequencer
|
|||||||
*
|
*
|
||||||
* @param sequence the ordering to display the frames.
|
* @param sequence the ordering to display the frames.
|
||||||
* @param msPerFrame the number of ms to display each frame.
|
* @param msPerFrame the number of ms to display each frame.
|
||||||
* @param loop if false, the sequencer will report the end of
|
* @param loop if false, the sequencer will report the end of the animation after
|
||||||
* the animation after progressing through all of the frames once,
|
* progressing through all of the frames once, otherwise it will loop indefinitely.
|
||||||
* otherwise it will loop indefinitely.
|
|
||||||
*/
|
*/
|
||||||
public MultiFunction (int[] sequence, long msPerFrame, boolean loop)
|
public MultiFunction (int[] sequence, long msPerFrame, boolean loop) {
|
||||||
{
|
|
||||||
_length = sequence.length;
|
_length = sequence.length;
|
||||||
_sequence = sequence;
|
_sequence = sequence;
|
||||||
setDelay(msPerFrame);
|
setDelay(msPerFrame);
|
||||||
@@ -66,20 +63,16 @@ public interface AnimationFrameSequencer extends FrameSequencer
|
|||||||
*
|
*
|
||||||
* @param sequence the ordering to display the frames.
|
* @param sequence the ordering to display the frames.
|
||||||
* @param msPerFrame the number of ms to display each frame.
|
* @param msPerFrame the number of ms to display each frame.
|
||||||
* @param marks if true for a frame, a FrameReachedEvent will
|
* @param marks if true for a frame, a FrameReachedEvent will be generated when that frame
|
||||||
* be generated when that frame is reached.
|
* is reached.
|
||||||
* @param loop if false, the sequencer will report the end of
|
* @param loop if false, the sequencer will report the end of the animation after
|
||||||
* the animation after progressing through all of the frames once,
|
* progressing through all of the frames once, otherwise it will loop indefinitely.
|
||||||
* otherwise it will loop indefinitely.
|
|
||||||
*/
|
*/
|
||||||
public MultiFunction (
|
public MultiFunction (int[] sequence, long[] msPerFrame, boolean[] marks, boolean loop) {
|
||||||
int[] sequence, long[] msPerFrame, boolean[] marks, boolean loop)
|
|
||||||
{
|
|
||||||
_length = sequence.length;
|
_length = sequence.length;
|
||||||
if ((_length != msPerFrame.length) || (_length != marks.length)) {
|
if ((_length != msPerFrame.length) || (_length != marks.length)) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"All MultiFunction FrameSequencer arrays must be " +
|
"All MultiFunction FrameSequencer arrays must be the same length.");
|
||||||
"the same length.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_sequence = sequence;
|
_sequence = sequence;
|
||||||
@@ -91,18 +84,16 @@ public interface AnimationFrameSequencer extends FrameSequencer
|
|||||||
/**
|
/**
|
||||||
* Set the delay to use.
|
* Set the delay to use.
|
||||||
*/
|
*/
|
||||||
public void setDelay (long msPerFrame)
|
public void setDelay (long msPerFrame) {
|
||||||
{
|
|
||||||
_delays = null;
|
_delays = null;
|
||||||
_delay = msPerFrame;
|
_delay = msPerFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the length of the sequence we are to use, or 0 means set
|
* Set the length of the sequence we are to use, or 0 means set it to the length of the
|
||||||
* it to the length of the sequence array that we were constructed with.
|
* sequence array that we were constructed with.
|
||||||
*/
|
*/
|
||||||
public void setLength (int len)
|
public void setLength (int len) {
|
||||||
{
|
|
||||||
_length = (len == 0) ? _sequence.length : len;
|
_length = (len == 0) ? _sequence.length : len;
|
||||||
if (_curIdx >= _length) {
|
if (_curIdx >= _length) {
|
||||||
_curIdx = 0;
|
_curIdx = 0;
|
||||||
@@ -112,14 +103,12 @@ public interface AnimationFrameSequencer extends FrameSequencer
|
|||||||
/**
|
/**
|
||||||
* Do we reset the animation on init? Default is true.
|
* Do we reset the animation on init? Default is true.
|
||||||
*/
|
*/
|
||||||
public void setResetOnInit (boolean resets)
|
public void setResetOnInit (boolean resets) {
|
||||||
{
|
|
||||||
_resets = resets;
|
_resets = resets;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int init (MultiFrameImage source)
|
public int init (MultiFrameImage source) {
|
||||||
{
|
|
||||||
int framecount = source.getFrameCount();
|
int framecount = source.getFrameCount();
|
||||||
// let's make sure our frames are valid
|
// let's make sure our frames are valid
|
||||||
for (int ii=0; ii < _length; ii++) {
|
for (int ii=0; ii < _length; ii++) {
|
||||||
@@ -140,14 +129,12 @@ public interface AnimationFrameSequencer extends FrameSequencer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public void setAnimation (Animation anim)
|
public void setAnimation (Animation anim) {
|
||||||
{
|
|
||||||
_animation = anim;
|
_animation = anim;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int tick (long tickStamp)
|
public int tick (long tickStamp) {
|
||||||
{
|
|
||||||
// obtain our starting timestamp if we don't already have one
|
// obtain our starting timestamp if we don't already have one
|
||||||
if (_lastStamp == 0L) {
|
if (_lastStamp == 0L) {
|
||||||
_lastStamp = tickStamp;
|
_lastStamp = tickStamp;
|
||||||
@@ -179,8 +166,7 @@ public interface AnimationFrameSequencer extends FrameSequencer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public void fastForward (long timeDelta)
|
public void fastForward (long timeDelta) {
|
||||||
{
|
|
||||||
// this method should be called "unpause"
|
// this method should be called "unpause"
|
||||||
_lastStamp += timeDelta;
|
_lastStamp += timeDelta;
|
||||||
}
|
}
|
||||||
@@ -188,20 +174,17 @@ public interface AnimationFrameSequencer extends FrameSequencer
|
|||||||
/**
|
/**
|
||||||
* Get the delay to use for the specified frame.
|
* Get the delay to use for the specified frame.
|
||||||
*/
|
*/
|
||||||
protected final long getDelay (int index)
|
protected final long getDelay (int index) {
|
||||||
{
|
|
||||||
return (_delays == null) ? _delay : _delays[index];
|
return (_delays == null) ? _delay : _delays[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check to see if we need to notify that we've reached a marked frame.
|
* Check to see if we need to notify that we've reached a marked frame.
|
||||||
*/
|
*/
|
||||||
protected void checkNotify (long tickStamp)
|
protected void checkNotify (long tickStamp) {
|
||||||
{
|
|
||||||
if (_marks[_curIdx]) {
|
if (_marks[_curIdx]) {
|
||||||
_animation.queueNotification(
|
_animation.queueNotification(
|
||||||
new FrameReachedOp(_animation, tickStamp,
|
new FrameReachedOp(_animation, tickStamp, _sequence[_curIdx], _curIdx));
|
||||||
_sequence[_curIdx], _curIdx));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,8 +221,7 @@ public interface AnimationFrameSequencer extends FrameSequencer
|
|||||||
/** Used to dispatch {@link SequencedAnimationObserver#frameReached}. */
|
/** Used to dispatch {@link SequencedAnimationObserver#frameReached}. */
|
||||||
protected static class FrameReachedOp implements ObserverList.ObserverOp<Object>
|
protected static class FrameReachedOp implements ObserverList.ObserverOp<Object>
|
||||||
{
|
{
|
||||||
public FrameReachedOp (Animation anim, long when,
|
public FrameReachedOp (Animation anim, long when, int frameIdx, int frameSeq) {
|
||||||
int frameIdx, int frameSeq) {
|
|
||||||
_anim = anim;
|
_anim = anim;
|
||||||
_when = when;
|
_when = when;
|
||||||
_frameIdx = frameIdx;
|
_frameIdx = frameIdx;
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ public class ExplodeAnimation extends Animation
|
|||||||
public long delay;
|
public long delay;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString ()
|
public String toString () {
|
||||||
{
|
|
||||||
return StringUtil.fieldsToString(this);
|
return StringUtil.fieldsToString(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,5 @@ public interface SequencedAnimationObserver extends AnimationObserver
|
|||||||
* Called when the observed animation -- previously configured with an
|
* Called when the observed animation -- previously configured with an
|
||||||
* {@link AnimationFrameSequencer} -- reached the specified frame.
|
* {@link AnimationFrameSequencer} -- reached the specified frame.
|
||||||
*/
|
*/
|
||||||
public void frameReached (Animation anim, long when,
|
public void frameReached (Animation anim, long when, int frameIdx, int frameSeq);
|
||||||
int frameIdx, int frameSeq);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,7 @@ public class FadeEffect
|
|||||||
{
|
{
|
||||||
public FadeEffect (float alpha, float step, float target)
|
public FadeEffect (float alpha, float step, float target)
|
||||||
{
|
{
|
||||||
if ((step == 0f) || (alpha > target && step > 0f) ||
|
if ((step == 0f) || (alpha > target && step > 0f) || (alpha < target && step < 0f)) {
|
||||||
(alpha < target && step < 0f)) {
|
|
||||||
throw new IllegalArgumentException("Step specified is illegal: " +
|
throw new IllegalArgumentException("Step specified is illegal: " +
|
||||||
"Fade would never finish (start=" + alpha + ", step=" + step +
|
"Fade would never finish (start=" + alpha + ", step=" + step +
|
||||||
", target=" + target + ")");
|
", target=" + target + ")");
|
||||||
|
|||||||
@@ -475,7 +475,7 @@ public class ColorPository implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads up a serialized color pository from the supplied resource manager.
|
* Loads up a serialized ColorPository from the supplied resource manager.
|
||||||
*/
|
*/
|
||||||
public static ColorPository loadColorPository (ResourceManager rmgr)
|
public static ColorPository loadColorPository (ResourceManager rmgr)
|
||||||
{
|
{
|
||||||
@@ -488,7 +488,7 @@ public class ColorPository implements Serializable
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads up a serialized color pository from the supplied resource manager.
|
* Loads up a serialized ColorPository from the supplied resource manager.
|
||||||
*/
|
*/
|
||||||
public static ColorPository loadColorPository (InputStream source)
|
public static ColorPository loadColorPository (InputStream source)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -100,8 +100,7 @@ public class Colorization
|
|||||||
{
|
{
|
||||||
// check to see that this color is sufficiently "close" to the
|
// check to see that this color is sufficiently "close" to the
|
||||||
// root color based on the supplied distance parameters
|
// root color based on the supplied distance parameters
|
||||||
if (distance(fhsv[0], _fhsv[0], Short.MAX_VALUE) >
|
if (distance(fhsv[0], _fhsv[0], Short.MAX_VALUE) > range[0] * Short.MAX_VALUE) {
|
||||||
range[0] * Short.MAX_VALUE) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -148,8 +148,7 @@ public class ImageUtil
|
|||||||
Color.RGBtoHSB(red, green, blue, hsv);
|
Color.RGBtoHSB(red, green, blue, hsv);
|
||||||
Colorization.toFixedHSV(hsv, fhsv);
|
Colorization.toFixedHSV(hsv, fhsv);
|
||||||
|
|
||||||
// see if this color matches and of our colorizations and
|
// see if this color matches and of our colorizations and recolor it if it does
|
||||||
// recolor it if it does
|
|
||||||
for (int z = 0; z < zcount; z++) {
|
for (int z = 0; z < zcount; z++) {
|
||||||
Colorization cz = zations[z];
|
Colorization cz = zations[z];
|
||||||
if (cz != null && cz.matches(hsv, fhsv)) {
|
if (cz != null && cz.matches(hsv, fhsv)) {
|
||||||
@@ -171,8 +170,7 @@ public class ImageUtil
|
|||||||
* Paints multiple copies of the supplied image using the supplied graphics context such that
|
* Paints multiple copies of the supplied image using the supplied graphics context such that
|
||||||
* the requested area is filled with the image.
|
* the requested area is filled with the image.
|
||||||
*/
|
*/
|
||||||
public static void tileImage (
|
public static void tileImage (Graphics2D gfx, Mirage image, int x, int y, int width, int height)
|
||||||
Graphics2D gfx, Mirage image, int x, int y, int width, int height)
|
|
||||||
{
|
{
|
||||||
int iwidth = image.getWidth(), iheight = image.getHeight();
|
int iwidth = image.getWidth(), iheight = image.getHeight();
|
||||||
int xnum = width / iwidth, xplus = width % iwidth;
|
int xnum = width / iwidth, xplus = width % iwidth;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public abstract class SimpleCachingImageProvider implements ImageProvider
|
|||||||
image = loadImage(path);
|
image = loadImage(path);
|
||||||
_cache.put(path, image);
|
_cache.put(path, image);
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
log.warning("Failed to load image [path=" + path + ", ioe=" + ioe + "].");
|
log.warning("Failed to load image", "path", path, "ioe", ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,8 +80,7 @@ public class TileManager
|
|||||||
/**
|
/**
|
||||||
*/
|
*/
|
||||||
public UniformTileSet loadTileSet (
|
public UniformTileSet loadTileSet (
|
||||||
ImageProvider improv, String improvKey, String imgPath,
|
ImageProvider improv, String improvKey, String imgPath, int width, int height)
|
||||||
int width, int height)
|
|
||||||
{
|
{
|
||||||
UniformTileSet uts = loadCachedTileSet(improvKey, imgPath, width, height);
|
UniformTileSet uts = loadCachedTileSet(improvKey, imgPath, width, height);
|
||||||
uts.setImageProvider(improv);
|
uts.setImageProvider(improv);
|
||||||
@@ -89,8 +88,7 @@ public class TileManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an image provider that will load images from the specified
|
* Returns an image provider that will load images from the specified resource set.
|
||||||
* resource set.
|
|
||||||
*/
|
*/
|
||||||
public ImageProvider getImageProvider (String rset)
|
public ImageProvider getImageProvider (String rset)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ import java.awt.image.BufferedImage;
|
|||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
import com.samskivert.util.StringUtil;
|
|
||||||
import com.samskivert.util.Throttle;
|
import com.samskivert.util.Throttle;
|
||||||
|
|
||||||
import com.threerings.media.image.BufferedMirage;
|
import com.threerings.media.image.BufferedMirage;
|
||||||
@@ -131,8 +130,8 @@ public abstract class TileSet
|
|||||||
return tset;
|
return tset;
|
||||||
|
|
||||||
} catch (CloneNotSupportedException cnse) {
|
} catch (CloneNotSupportedException cnse) {
|
||||||
log.warning("Unable to clone tileset prior to colorization [tset=" + this +
|
log.warning("Unable to clone tileset prior to colorization",
|
||||||
", zations=" + StringUtil.toString(zations) + ", error=" + cnse + "].");
|
"tset", this, "zations", zations, "error", cnse);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,7 +271,7 @@ public abstract class TileSet
|
|||||||
Mirage mirage = null;
|
Mirage mirage = null;
|
||||||
if (checkTileIndex(tileIndex)) {
|
if (checkTileIndex(tileIndex)) {
|
||||||
if (_improv == null) {
|
if (_improv == null) {
|
||||||
log.warning("Aiya! Tile set missing image provider [path=" + _imagePath + "].");
|
log.warning("Aiya! Tile set missing image provider", "path", _imagePath);
|
||||||
} else {
|
} else {
|
||||||
mirage = _improv.getTileImage(_imagePath, bounds, zations);
|
mirage = _improv.getTileImage(_imagePath, bounds, zations);
|
||||||
}
|
}
|
||||||
@@ -404,9 +403,8 @@ public abstract class TileSet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("Tile caches [amem=" + (amem / 1024) + "k" +
|
log.info("Tile caches", "amem", (amem / 1024) + "k",
|
||||||
", tmem=" + (Tile._totalTileMemory / 1024) + "k" +
|
"tmem", (Tile._totalTileMemory / 1024) + "k", "seen", _atiles.size(), "asize", + asize);
|
||||||
", seen=" + _atiles.size() + ", asize=" + asize + "].");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -498,8 +498,7 @@ public class RecolorImage extends JPanel
|
|||||||
{
|
{
|
||||||
float[] hsv = new float[3];
|
float[] hsv = new float[3];
|
||||||
Color color = new Color(rgb);
|
Color color = new Color(rgb);
|
||||||
Color.RGBtoHSB(color.getRed(), color.getGreen(),
|
Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsv);
|
||||||
color.getBlue(), hsv);
|
|
||||||
return hsv;
|
return hsv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -619,7 +618,6 @@ public class RecolorImage extends JPanel
|
|||||||
protected ColorPository _colRepo;
|
protected ColorPository _colRepo;
|
||||||
|
|
||||||
protected static final String IMAGE_PATH =
|
protected static final String IMAGE_PATH =
|
||||||
// "bundles/components/pirate/torso/regular/standing.png";
|
|
||||||
"bundles/components/pirate/head/regular/standing.png";
|
"bundles/components/pirate/head/regular/standing.png";
|
||||||
|
|
||||||
/** The actions for our various buttons. */
|
/** The actions for our various buttons. */
|
||||||
|
|||||||
@@ -22,63 +22,53 @@
|
|||||||
package com.threerings.media.util;
|
package com.threerings.media.util;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to control animation timing when displaying a {@link
|
* Used to control animation timing when displaying a {@link MultiFrameImage}. This interface
|
||||||
* MultiFrameImage}. This interface allows for constant framerates, or
|
* allows for constant framerates, or more sophisticated animation timing.
|
||||||
* more sophisticated animation timing.
|
|
||||||
*/
|
*/
|
||||||
public interface FrameSequencer
|
public interface FrameSequencer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Called prior to the execution of an animation sequence (not
|
* Called prior to the execution of an animation sequence (not necessarily immediately, so
|
||||||
* necessarily immediately, so time stamps should be obtained in the
|
* time stamps should be obtained in the first call to tick).
|
||||||
* first call to tick).
|
|
||||||
*
|
*
|
||||||
* @param source the multie-frame image that is providing the
|
* @param source the multi-frame image that is providing the animation frames.
|
||||||
* animation frames.
|
|
||||||
* @return initial frame index
|
* @return initial frame index
|
||||||
*/
|
*/
|
||||||
public int init (MultiFrameImage source);
|
public int init (MultiFrameImage source);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called every display frame, the frame sequencer should return the
|
* Called every display frame, the frame sequencer should return the index of the animation
|
||||||
* index of the animation frame that should be displayed during this
|
* frame that should be displayed during this tick. If the sequencer returns -1, it is taken
|
||||||
* tick. If the sequencer returns -1, it is taken as an indication
|
* as an indication that the animation is finished and should be stopped.
|
||||||
* that the animation is finished and should be stopped.
|
|
||||||
*/
|
*/
|
||||||
public int tick (long tickStamp);
|
public int tick (long tickStamp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called if the display is paused for some length of time and then
|
* Called if the display is paused for some length of time and then unpaused. Sequencers
|
||||||
* unpaused. Sequencers should adjust any time stamps they are
|
* should adjust any time stamps they are maintaining internally by the delta so that time
|
||||||
* maintaining internally by the delta so that time maintains the
|
* maintains the illusion of flowing smoothly forward.
|
||||||
* illusion of flowing smoothly forward.
|
|
||||||
*/
|
*/
|
||||||
public void fastForward (long timeDelta);
|
public void fastForward (long timeDelta);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A frame sequencer that delivers a constant frame rate in either one
|
* A frame sequencer that delivers a constant frame rate in either one shot or looping mode.
|
||||||
* shot or looping mode.
|
|
||||||
*/
|
*/
|
||||||
public static class ConstantRate implements FrameSequencer
|
public static class ConstantRate implements FrameSequencer
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Creates a constant rate frame sequencer with the desired target
|
* Creates a constant rate frame sequencer with the desired target frames per second.
|
||||||
* frames per second.
|
|
||||||
*
|
*
|
||||||
* @param framesPerSecond the target frames per second.
|
* @param framesPerSecond the target frames per second.
|
||||||
* @param loop if false, the sequencer will report the end of
|
* @param loop if false, the sequencer will report the end of the animation after
|
||||||
* the animation after progressing through all of the frames once,
|
* progressing through all of the frames once, otherwise it will loop indefinitely.
|
||||||
* otherwise it will loop indefinitely.
|
|
||||||
*/
|
*/
|
||||||
public ConstantRate (double framesPerSecond, boolean loop)
|
public ConstantRate (double framesPerSecond, boolean loop) {
|
||||||
{
|
|
||||||
_millisPerFrame = (long)(1000d / framesPerSecond);
|
_millisPerFrame = (long)(1000d / framesPerSecond);
|
||||||
_loop = loop;
|
_loop = loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int init (MultiFrameImage source)
|
public int init (MultiFrameImage source) {
|
||||||
{
|
|
||||||
_frameCount = source.getFrameCount();
|
_frameCount = source.getFrameCount();
|
||||||
_startStamp = 0l;
|
_startStamp = 0l;
|
||||||
|
|
||||||
@@ -86,8 +76,7 @@ public interface FrameSequencer
|
|||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public int tick (long tickStamp)
|
public int tick (long tickStamp) {
|
||||||
{
|
|
||||||
// obtain our starting timestamp if we don't already have one
|
// obtain our starting timestamp if we don't already have one
|
||||||
if (_startStamp == 0) {
|
if (_startStamp == 0) {
|
||||||
_startStamp = tickStamp;
|
_startStamp = tickStamp;
|
||||||
@@ -98,13 +87,11 @@ public interface FrameSequencer
|
|||||||
|
|
||||||
// if we're not looping and we've exhausted our frames, we
|
// if we're not looping and we've exhausted our frames, we
|
||||||
// return -1 to indicate that the animation should stop
|
// return -1 to indicate that the animation should stop
|
||||||
return (_loop || frameIdx < _frameCount) ? (frameIdx % _frameCount)
|
return (_loop || frameIdx < _frameCount) ? (frameIdx % _frameCount) : -1;
|
||||||
: -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited from interface
|
// documentation inherited from interface
|
||||||
public void fastForward (long timeDelta)
|
public void fastForward (long timeDelta) {
|
||||||
{
|
|
||||||
_startStamp += timeDelta;
|
_startStamp += timeDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ package com.threerings.media.util;
|
|||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides miscellaneous useful utility routines for mathematical
|
* Provides miscellaneous useful utility routines for mathematical calculations.
|
||||||
* calculations.
|
|
||||||
*/
|
*/
|
||||||
public class MathUtil
|
public class MathUtil
|
||||||
{
|
{
|
||||||
@@ -82,10 +81,9 @@ public class MathUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the approximate circumference of the ellipse defined by the
|
* Returns the approximate circumference of the ellipse defined by the specified minor and
|
||||||
* specified minor and major axes. The formula used (due to Ramanujan,
|
* major axes. The formula used (due to Ramanujan, via a paper of his entitled "Modular
|
||||||
* via a paper of his entitled "Modular Equations and Approximations
|
* Equations and Approximations to Pi"), is <code>Pi(3a + 3b - sqrt[(a+3b)(b+3a)])</code>.
|
||||||
* to Pi"), is <code>Pi(3a + 3b - sqrt[(a+3b)(b+3a)])</code>.
|
|
||||||
*/
|
*/
|
||||||
public static double ellipseCircum (double a, double b)
|
public static double ellipseCircum (double a, double b)
|
||||||
{
|
{
|
||||||
@@ -93,8 +91,8 @@ public class MathUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns positive 1 if the sign of the argument is positive, or -1
|
* Returns positive 1 if the sign of the argument is positive, or -1 if the sign of the
|
||||||
* if the sign of the argument is negative.
|
* argument is negative.
|
||||||
*/
|
*/
|
||||||
public static int sign (int value)
|
public static int sign (int value)
|
||||||
{
|
{
|
||||||
@@ -121,8 +119,7 @@ public class MathUtil
|
|||||||
/**
|
/**
|
||||||
* Computes the standard deviation of the supplied values.
|
* Computes the standard deviation of the supplied values.
|
||||||
*
|
*
|
||||||
* @return an array of three values: the mean, variance and standard
|
* @return an array of three values: the mean, variance and standard deviation, in that order.
|
||||||
* deviation, in that order.
|
|
||||||
*/
|
*/
|
||||||
public static float[] stddev (int[] values, int start, int length)
|
public static float[] stddev (int[] values, int start, int length)
|
||||||
{
|
{
|
||||||
@@ -146,8 +143,8 @@ public class MathUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Computes (N choose K), the number of ways to select K different
|
* Computes (N choose K), the number of ways to select K different elements from a set of size
|
||||||
* elements from a set of size N.
|
* N.
|
||||||
*/
|
*/
|
||||||
public static int choose (int n, int k)
|
public static int choose (int n, int k)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ import com.threerings.media.FrameManager;
|
|||||||
import com.threerings.miso.tile.MisoTileManager;
|
import com.threerings.miso.tile.MisoTileManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Miso code with access to the managers that it needs to do its
|
* Provides Miso code with access to the managers that it needs to do its thing.
|
||||||
* thing.
|
|
||||||
*/
|
*/
|
||||||
public interface MisoContext
|
public interface MisoContext
|
||||||
{
|
{
|
||||||
@@ -37,8 +36,8 @@ public interface MisoContext
|
|||||||
public FrameManager getFrameManager ();
|
public FrameManager getFrameManager ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a reference to the tile manager. This reference is valid
|
* Returns a reference to the tile manager. This reference is valid for the lifetime of the
|
||||||
* for the lifetime of the application.
|
* application.
|
||||||
*/
|
*/
|
||||||
public MisoTileManager getTileManager ();
|
public MisoTileManager getTileManager ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -382,14 +382,12 @@ public class OpenALSoundPlayer extends SoundPlayer
|
|||||||
*/
|
*/
|
||||||
protected class TickingQueue extends BasicRunQueue
|
protected class TickingQueue extends BasicRunQueue
|
||||||
{
|
{
|
||||||
public TickingQueue ()
|
public TickingQueue () {
|
||||||
{
|
|
||||||
super("SoundPlayerQueue");
|
super("SoundPlayerQueue");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void iterate ()
|
protected void iterate () {
|
||||||
{
|
|
||||||
long elapsed = _timer.getElapsedMillis() - _lastTick;
|
long elapsed = _timer.getElapsedMillis() - _lastTick;
|
||||||
Runnable r;
|
Runnable r;
|
||||||
if (elapsed >= STREAM_UPDATE_INTERVAL) {
|
if (elapsed >= STREAM_UPDATE_INTERVAL) {
|
||||||
@@ -438,14 +436,12 @@ public class OpenALSoundPlayer extends SoundPlayer
|
|||||||
|
|
||||||
public Sound sound;
|
public Sound sound;
|
||||||
|
|
||||||
public SoundGrabber (String pkgPath, String key)
|
public SoundGrabber (String pkgPath, String key) {
|
||||||
{
|
|
||||||
String[] paths = getPaths(pkgPath, key);
|
String[] paths = getPaths(pkgPath, key);
|
||||||
path = paths[RandomUtil.getInt(paths.length)];
|
path = paths[RandomUtil.getInt(paths.length)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run ()
|
public void run () {
|
||||||
{
|
|
||||||
sound = _group.getSound(path);
|
sound = _group.getSound(path);
|
||||||
soundLoaded();
|
soundLoaded();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user