Whitespace

git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@1031 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Dave Hoover
2010-10-15 20:16:01 +00:00
parent b443c0e48c
commit 082bd4399b
28 changed files with 233 additions and 324 deletions
+1 -2
View File
@@ -144,8 +144,7 @@ public class ObjectSet
};
/**
* Returns the index of the object or its insertion index if it is
* not in the set.
* Returns the index of the object or its insertion index if it is not in the set.
*/
protected function indexOf (info :ObjectInfo) :int
{
+14 -19
View File
@@ -26,49 +26,44 @@ import com.threerings.util.DirectionCodes;
import com.threerings.media.image.Colorization;
/**
* Encapsulates a set of frames in each of {@link
* DirectionCodes#DIRECTION_COUNT} orientations that are used to render a
* character sprite.
* Encapsulates a set of frames in each of {@link DirectionCodes#DIRECTION_COUNT} orientations
* that are used to render a character sprite.
*/
public interface ActionFrames
{
/**
* Returns the number of orientations available in this set of action
* frames.
* Returns the number of orientations available in this set of action frames.
*/
public int getOrientationCount ();
/**
* Returns the multi-frame image that comprises the frames for the
* specified orientation.
* Returns the multi-frame image that comprises the frames for the specified orientation.
*/
public TrimmedMultiFrameImage getFrames (int orient);
/**
* Returns the x offset from the upper left of the image to the
* "origin" for this character frame. A sprite with location (x, y)
* will be rendered such that its origin is coincident with that
* location.
* Returns the x offset from the upper left of the image to the "origin" for this character
* frame. A sprite with location (x, y) will be rendered such that its origin is coincident
* with that location.
*/
public int getXOrigin (int orient, int frameIdx);
/**
* Returns the y offset from the upper left of the image to the
* "origin" for this character frame. A sprite with location (x, y)
* will be rendered such that its origin is coincident with that
* location.
* Returns the y offset from the upper left of the image to the "origin" for this character
* frame. A sprite with location (x, y) will be rendered such that its origin is coincident
* with that location.
*/
public int getYOrigin (int orient, int frameIdx);
/**
* Creates a clone of these action frames which will have the supplied
* colorizations applied to the frame images.
* Creates a clone of these action frames which will have the supplied colorizations applied
* to the frame images.
*/
public ActionFrames cloneColorized (Colorization[] zations);
/**
* Creates a clone of these action frames which will have the supplied
* translation applied to the frame images.
* Creates a clone of these action frames which will have the supplied translation applied to
* the frame images.
*/
public ActionFrames cloneTranslated (int dx, int dy);
}
@@ -32,16 +32,14 @@ import com.threerings.media.sprite.ImageSprite;
import static com.threerings.cast.Log.log;
/**
* A character sprite is a sprite that animates itself while walking
* about in a scene.
* A character sprite is a sprite that animates itself while walking about in a scene.
*/
public class CharacterSprite extends ImageSprite
implements StandardActions
{
/**
* Initializes this character sprite with the specified character
* descriptor and character manager. It will obtain animation data
* from the supplied character manager.
* Initializes this character sprite with the specified character descriptor and character
* manager. It will obtain animation data from the supplied character manager.
*/
public void init (CharacterDescriptor descrip, CharacterManager charmgr)
{
@@ -60,9 +58,8 @@ public class CharacterSprite extends ImageSprite
}
/**
* Called after this sprite has been initialized with its character
* descriptor and character manager. Derived classes can do post-init
* business here.
* Called after this sprite has been initialized with its character descriptor and character
* manager. Derived classes can do post-init business here.
*/
protected void didInit ()
{
@@ -84,8 +81,8 @@ public class CharacterSprite extends ImageSprite
}
/**
* Specifies the action to use when the sprite is at rest. The default
* is <code>STANDING</code>.
* Specifies the action to use when the sprite is at rest. The default is
* <code>STANDING</code>.
*/
public void setRestingAction (String action)
{
@@ -93,9 +90,8 @@ public class CharacterSprite extends ImageSprite
}
/**
* Returns the action to be used when the sprite is at rest. Derived
* classes may wish to override this method and vary the action based
* on external parameters (or randomly).
* Returns the action to be used when the sprite is at rest. Derived classes may wish to
* override this method and vary the action based on external parameters (or randomly).
*/
public String getRestingAction ()
{
@@ -103,8 +99,8 @@ public class CharacterSprite extends ImageSprite
}
/**
* Specifies the action to use when the sprite is following a path.
* The default is <code>WALKING</code>.
* Specifies the action to use when the sprite is following a path. The default is
* <code>WALKING</code>.
*/
public void setFollowingPathAction (String action)
{
@@ -112,9 +108,8 @@ public class CharacterSprite extends ImageSprite
}
/**
* Returns the action to be used when the sprite is following a path.
* Derived classes may wish to override this method and vary the
* action based on external parameters (or randomly).
* Returns the action to be used when the sprite is following a path. Derived classes may wish
* to override this method and vary the action based on external parameters (or randomly).
*/
public String getFollowingPathAction ()
{
@@ -122,8 +117,8 @@ public class CharacterSprite extends ImageSprite
}
/**
* Sets the action sequence used when rendering the character, from
* the set of available sequences.
* Sets the action sequence used when rendering the character, from the set of available
* sequences.
*/
public void setActionSequence (String action)
{
@@ -145,8 +140,8 @@ public class CharacterSprite extends ImageSprite
public void setOrientation (int orient)
{
if (orient < 0 || orient >= FINE_DIRECTION_COUNT) {
log.info("Refusing to set invalid orientation [sprite=" + this +
", orient=" + orient + "].", new Exception());
log.info("Refusing to set invalid orientation",
"sprite", this, "orient", orient, new Exception());
return;
}
@@ -172,8 +167,7 @@ public class CharacterSprite extends ImageSprite
// tick caused them to become invalid
compositeActionFrames();
super.tick(tickStamp);
// composite our action frames if something during tick() caused
// them to become invalid
// composite our action frames if something during tick() caused them to become invalid
compositeActionFrames();
}
@@ -217,25 +211,22 @@ public class CharacterSprite extends ImageSprite
}
/**
* Called to paint any decorations that should appear behind the
* character sprite image.
* Called to paint any decorations that should appear behind the character sprite image.
*/
protected void decorateBehind (Graphics2D gfx)
{
}
/**
* Called to paint any decorations that should appear in front of the
* character sprite image.
* Called to paint any decorations that should appear in front of the character sprite image.
*/
protected void decorateInFront (Graphics2D gfx)
{
}
/**
* Rebuilds our action frames given our current character descriptor
* and action sequence. This is called when either of those two things
* changes.
* Rebuilds our action frames given our current character descriptor and action sequence. This
* is called when either of those two things changes.
*/
protected void updateActionFrames ()
{
@@ -258,12 +249,12 @@ public class CharacterSprite extends ImageSprite
setFrameRate(actseq.framesPerSecond);
} catch (NoSuchComponentException nsce) {
log.warning("Character sprite references non-existent " +
"component [sprite=" + this + ", err=" + nsce + "].");
log.warning("Character sprite references non-existent component",
"sprite", this, "err", nsce);
} catch (Exception e) {
log.warning("Failed to obtain action frames [sprite=" + this +
", descrip=" + _descrip + ", action=" + _action + "].", e);
log.warning("Failed to obtain action frames",
"sprite", this, "descrip", _descrip, "action", _action, e);
}
}
@@ -291,8 +282,7 @@ public class CharacterSprite extends ImageSprite
protected boolean tickPath (long tickStamp)
{
boolean moved = super.tickPath(tickStamp);
// composite our action frames if our path caused them to become
// invalid
// composite our action frames if our path caused them to become invalid
compositeActionFrames();
return moved;
}
@@ -341,22 +331,21 @@ public class CharacterSprite extends ImageSprite
}
/**
* Called by {@link #accomodateFrame} to give derived classes an
* opportunity to incorporate the bounds of any decorations that will
* be drawn along with this sprite. The {@link #_ibounds} rectangle
* will contain the bounds of the image that comprises the undecorated
* sprite. From that the position and size of decorations can be
* computed and unioned with the supplied bounds rectangle (most
* likely by using {@link SwingUtilities#computeUnion} which applies
* the union in place rather than creating a new rectangle).
* Called by {@link #accomodateFrame} to give derived classes an opportunity to incorporate
* the bounds of any decorations that will be drawn along with this sprite. The
* {@link #_ibounds} rectangle will contain the bounds of the image that comprises the
* undecorated sprite. From that the position and size of decorations can be computed and
* unioned with the supplied bounds rectangle (most likely by using
* {@link SwingUtilities#computeUnion} which applies the union in place rather than creating a
* new rectangle).
*/
protected void unionDecorationBounds (Rectangle bounds)
{
}
/**
* Updates the sprite animation frame to reflect the cessation of
* movement and disables any further animation.
* Updates the sprite animation frame to reflect the cessation of movement and disables any
* further animation.
*/
protected void halt ()
{
@@ -378,8 +367,7 @@ public class CharacterSprite extends ImageSprite
/** The action to use when following a path. */
protected String _followingPathAction = WALKING;
/** A reference to the descriptor for the character that we're
* visualizing. */
/** A reference to the descriptor for the character that we're visualizing. */
protected CharacterDescriptor _descrip;
/** A reference to the character manager that created us. */
@@ -388,12 +376,11 @@ public class CharacterSprite extends ImageSprite
/** The action we are currently displaying. */
protected String _action;
/** The animation frames for the active action sequence in each
* orientation. */
/** The animation frames for the active action sequence in each orientation. */
protected ActionFrames _aframes;
/** The offset from the upper-left of the total sprite bounds to the
* upper-left of the image within those bounds. */
/** The offset from the upper-left of the total sprite bounds to the upper-left of the image
* within those bounds. */
protected Point _ioff = new Point();
/** The bounds of the current sprite image. */
@@ -108,12 +108,11 @@ public class ActiveRepaintManager extends RepaintManager
return;
}
// make sure that the component is actually in a window or applet
// that is showing
// make sure that the component is actually in a window or applet that is showing
if (getRoot(vroot) == null) {
if (DEBUG) {
log.info("Skipping rootless component [comp=" + toString(comp) +
", vroot=" + toString(vroot) + "].");
log.info("Skipping rootless component",
"comp", toString(comp), "vroot", toString(vroot));
}
return;
}
@@ -154,8 +153,7 @@ public class ActiveRepaintManager extends RepaintManager
drect = new Rectangle(x, y, width, height);
if (DEBUG) {
log.info("Dirtying component [comp=" + toString(comp) +
", drect=" + StringUtil.toString(drect) + "]");
log.info("Dirtying component", "comp", toString(comp), "drect", drect);
}
// if we made it this far, we can queue up a dirty region for this component to be
@@ -278,10 +276,9 @@ public class ActiveRepaintManager extends RepaintManager
drect.y = y;
if (DEBUG) {
log.info("Found dirty parent [comp=" + toString(comp) +
", drect=" + StringUtil.toString(drect) +
", pcomp=" + toString(c) +
", prect=" + StringUtil.toString(prect) + "].");
log.info("Found dirty parent",
"comp", toString(comp), "drect", StringUtil.toString(drect),
"pcomp", toString(c), "prect", StringUtil.toString(prect));
}
prect.add(drect);
@@ -294,8 +291,7 @@ public class ActiveRepaintManager extends RepaintManager
continue PRUNE;
}
// translate the coordinates into this component's
// coordinate system
// translate the coordinates into this component's coordinate system
x += c.getX();
y += c.getY();
}
@@ -364,9 +360,8 @@ public class ActiveRepaintManager extends RepaintManager
// instance
if (root == _root) {
if (DEBUG) {
log.info("Repainting [comp=" + toString(comp) + StringUtil.toString(_cbounds) +
", ocomp=" + toString(ocomp) +
", drect=" + StringUtil.toString(drect) + "].");
log.info("Repainting", "comp", toString(comp) + StringUtil.toString(_cbounds),
"ocomp", toString(ocomp), "drect", StringUtil.toString(drect));
}
g.setClip(drect);
@@ -377,7 +372,7 @@ public class ActiveRepaintManager extends RepaintManager
ocomp.paint(g);
} catch (Exception e) {
log.warning("Exception while painting component [comp=" + ocomp + "].", e);
log.warning("Exception while painting component", "comp", ocomp, e);
}
g.translate(-_cbounds.x, -_cbounds.y);
@@ -387,9 +382,9 @@ public class ActiveRepaintManager extends RepaintManager
} else if (root != null) {
if (DEBUG) {
log.info("Repainting old-school [comp=" + toString(comp) +
", ocomp=" + toString(ocomp) + ", root=" + toString(root) +
", bounds=" + StringUtil.toString(_cbounds) + "].");
log.info("Repainting old-school",
"comp", toString(comp), "ocomp", toString(ocomp), "root", toString(root),
"bounds", StringUtil.toString(_cbounds));
dumpHierarchy(comp);
}
@@ -445,10 +440,10 @@ public class ActiveRepaintManager extends RepaintManager
protected Object[] _invalid;
/** A mapping of invalid rectangles for each widget that is dirty. */
protected Map<JComponent,Rectangle> _dirty = Maps.newHashMap();
protected Map<JComponent, Rectangle> _dirty = Maps.newHashMap();
/** A spare hashmap that we swap in while repainting dirty components in the old hashmap. */
protected Map<JComponent,Rectangle> _spare = Maps.newHashMap();
protected Map<JComponent, Rectangle> _spare = Maps.newHashMap();
/** Used to compute dirty components' bounds. */
protected Rectangle _cbounds = new Rectangle();
@@ -30,8 +30,7 @@ import java.awt.image.VolatileImage;
import static com.threerings.media.Log.log;
/**
* A {@link FrameManager} extension that uses a volatile off-screen image
* to do its rendering.
* A {@link FrameManager} extension that uses a volatile off-screen image to do its rendering.
*/
public class BackFrameManager extends FrameManager
{
@@ -92,8 +91,7 @@ public class BackFrameManager extends FrameManager
}
_fgfx.drawImage(_backimg, 0, 0, null);
// if we loop through a second time, we'll need to rerender
// everything
// if we loop through a second time, we'll need to rerender everything
incremental = false;
} while (_backimg.contentsLost());
@@ -118,8 +116,8 @@ public class BackFrameManager extends FrameManager
}
/**
* Creates the off-screen buffer used to perform double buffered
* rendering of the animated panel.
* Creates the off-screen buffer used to perform double buffered rendering of the animated
* panel.
*/
protected void createBackBuffer (GraphicsConfiguration gc)
{
@@ -31,8 +31,8 @@ import java.awt.image.BufferStrategy;
import static com.threerings.media.Log.log;
/**
* A {@link FrameManager} extension that uses a flip-buffer (via {@link
* BufferStrategy} to do its rendering.
* A {@link FrameManager} extension that uses a flip-buffer (via {@link BufferStrategy} to do its
* rendering.
*/
public class FlipFrameManager extends FrameManager
{
@@ -64,15 +64,13 @@ public class FlipFrameManager extends FrameManager
// dirty everything if we're not incrementally rendering
if (!incremental) {
log.info("Doing non-incremental render; contents lost " +
"[lost=" + _bufstrat.contentsLost() +
", rest=" + _bufstrat.contentsRestored() + "].");
log.info("Doing non-incremental render; contents lost",
"lost", _bufstrat.contentsLost(), "rest", _bufstrat.contentsRestored());
_root.getRootPane().revalidate();
_root.getRootPane().repaint();
}
// request to paint our participants and components and bail
// if they paint nothing
// request to paint our participants and components and bail if they paint nothing
if (!paint(gfx)) {
return;
}
@@ -80,8 +78,7 @@ public class FlipFrameManager extends FrameManager
// flip our buffer to visible
_bufstrat.show();
// if we loop through a second time, we'll need to rerender
// everything
// if we loop through a second time, we'll need to rerender everything
incremental = false;
} finally {
+21 -27
View File
@@ -211,7 +211,7 @@ public abstract class FrameManager
/**
* Returns a millisecond granularity time stamp using the {@link MediaTimer} with which this
* frame manager was configured. <em>Note:</em> this should only be called from the AWT
* frame manager was configured. <em>Note:</em> this should only be called from the AWT
* thread.
*/
public long getTimeStamp ()
@@ -220,8 +220,8 @@ public abstract class FrameManager
}
/**
* Returns the highest drift ratio our timer has seen. 1.0 means no drift (and is what we return
* if we're not using a CalibratingTimer)
* Returns the highest drift ratio our timer has seen. 1.0 means no drift (and is what we
* return if we're not using a CalibratingTimer)
*/
public float getMaxTimerDriftRatio ()
{
@@ -245,9 +245,9 @@ public abstract class FrameManager
/**
* Returns an overlay that can be used to render sprites and animations on top of the entire
* frame. This is lazily created the first time this method is called and the overlay will
* remain a frame participant until {@link #clearMediaOverlay} is called. Be sure to coordinate
* access to the overlay in your application as there is only one overlay in existence at any
* time, and attempts to use an overlay after it has been cleared will fail.
* remain a frame participant until {@link #clearMediaOverlay} is called. Be sure to
* coordinate access to the overlay in your application as there is only one overlay in
* existence at any time, and attempts to use an overlay after it has been cleared will fail.
*/
public MediaOverlay getMediaOverlay ()
{
@@ -439,14 +439,14 @@ public abstract class FrameManager
if (HANG_DEBUG) {
long delay = (System.currentTimeMillis() - start);
if (delay > HANG_GAP) {
log.info("Whoa nelly! Ticker took a long time " +
"[part=" + part + ", time=" + delay + "ms].");
log.info("Whoa nelly! Ticker took a long time",
"part", part, "time", delay + "ms");
}
}
} catch (Throwable t) {
log.warning("Frame participant choked during tick " +
"[part=" + StringUtil.safeToString(part) + "].", t);
log.warning("Frame participant choked during tick",
"part", StringUtil.safeToString(part), t);
}
}
@@ -529,8 +529,8 @@ public abstract class FrameManager
if (HANG_DEBUG) {
long delay = (System.currentTimeMillis() - start);
if (delay > HANG_GAP) {
log.warning("Whoa nelly! Painter took a long time " +
"[part=" + part + ", time=" + delay + "ms].");
log.warning("Whoa nelly! Painter took a long time",
"part", part, "time", delay + "ms");
}
}
}
@@ -630,16 +630,13 @@ public abstract class FrameManager
/** Used to effect periodic calls to {@link FrameManager#tick}. */
protected class Ticker extends Thread
{
public Ticker ()
{
public Ticker () {
super("FrameManagerTicker");
}
@Override
public void run ()
{
log.info("Frame manager ticker running " +
"[sleepGran=" + _sleepGranularity.getValue() + "].");
public void run () {
log.info("Frame manager ticker running", "sleepGran", _sleepGranularity.getValue());
while (_running) {
long start = 0L;
if (_perfDebug.getValue()) {
@@ -652,15 +649,15 @@ public abstract class FrameManager
getPerfMetrics()[0].record((int)(woke-start)/100);
int elapsed = (int)(woke-start);
if (elapsed > _sleepGranularity.getValue()*1500) {
log.warning("Long tick [elapsed=" + elapsed + "us].");
log.warning("Long tick", "elapsed", elapsed + "us");
}
}
// work around sketchy bug on WinXP that causes the clock to leap into the past
// from time to time
if (woke < _lastAttempt) {
log.warning("Zoiks! We've leapt into the past, coping as best we can " +
"[dt=" + (woke - _lastAttempt) + "].");
log.warning("Zoiks! We've leapt into the past, coping as best we can",
"dt", (woke - _lastAttempt));
_lastAttempt = woke;
}
@@ -674,13 +671,11 @@ public abstract class FrameManager
}
}
public void cancel ()
{
public void cancel () {
_running = false;
}
protected final synchronized boolean testAndSet ()
{
protected final synchronized boolean testAndSet () {
_tries++;
if (!_ticking) {
_ticking = true;
@@ -689,8 +684,7 @@ public abstract class FrameManager
return false;
}
protected final synchronized void clearTicking (long elapsed)
{
protected final synchronized void clearTicking (long elapsed) {
if (++_ticks == 100) {
long time = (elapsed - _lastTick);
_fps[0] = _tries * 1000f / time;
@@ -27,8 +27,7 @@ import java.awt.Window;
import javax.swing.JApplet;
/**
* When using the {@link FrameManager} in an Applet, one must use this
* top-level class.
* When using the {@link FrameManager} in an Applet, one must use this top-level class.
*/
public class ManagedJApplet extends JApplet
implements FrameManager.ManagedRoot
@@ -31,8 +31,7 @@ import java.awt.Window;
import javax.swing.JFrame;
/**
* When using the {@link FrameManager}, one must use this top-level frame
* class.
* When using the {@link FrameManager}, one must use this top-level frame class.
*/
public class ManagedJFrame extends JFrame
implements FrameManager.ManagedRoot
@@ -82,8 +81,7 @@ public class ManagedJFrame extends JFrame
}
/**
* We catch paint requests and forward them on to the repaint
* infrastructure.
* We catch paint requests and forward them on to the repaint infrastructure.
*/
@Override
public void paint (Graphics g)
@@ -92,8 +90,7 @@ public class ManagedJFrame extends JFrame
}
/**
* We catch update requests and forward them on to the repaint
* infrastructure.
* We catch update requests and forward them on to the repaint infrastructure.
*/
@Override
public void update (Graphics g)
+8 -15
View File
@@ -216,8 +216,7 @@ public class MediaPanel extends JComponent
}
/**
* Adds an animation to this panel. Animations are automatically
* removed when they finish.
* Adds an animation to this panel. Animations are automatically removed when they finish.
*/
public void addAnimation (Animation anim)
{
@@ -233,9 +232,8 @@ public class MediaPanel extends JComponent
}
/**
* Aborts a currently running animation and removes it from this
* panel. Animations are normally automatically removed when they
* finish.
* Aborts a currently running animation and removes it from this panel. Animations are
* normally automatically removed when they finish.
*/
public void abortAnimation (Animation anim)
{
@@ -566,8 +564,7 @@ public class MediaPanel extends JComponent
protected class ActionSpriteHandler extends MouseInputAdapter
{
@Override
public void mousePressed (MouseEvent me)
{
public void mousePressed (MouseEvent me) {
if (_activeSprite == null) {
// see if we can find one
Sprite s = getHit(me);
@@ -582,8 +579,7 @@ public class MediaPanel extends JComponent
}
@Override
public void mouseReleased (MouseEvent me)
{
public void mouseReleased (MouseEvent me) {
if (_activeSprite instanceof ArmingSprite) {
((ArmingSprite)_activeSprite).setArmed(false);
}
@@ -615,8 +611,7 @@ public class MediaPanel extends JComponent
}
@Override
public void mouseDragged (MouseEvent me)
{
public void mouseDragged (MouseEvent me) {
if (_activeSprite instanceof ArmingSprite) {
((ArmingSprite) _activeSprite).setArmed(
_activeSprite.hitTest(me.getX(), me.getY()));
@@ -624,8 +619,7 @@ public class MediaPanel extends JComponent
}
@Override
public void mouseMoved (MouseEvent me)
{
public void mouseMoved (MouseEvent me) {
Sprite s = getHit(me);
if (_activeSprite == s) {
return;
@@ -642,8 +636,7 @@ public class MediaPanel extends JComponent
/**
* Utility method, get the highest non-disabled action/hover sprite.
*/
protected Sprite getHit (MouseEvent me)
{
protected Sprite getHit (MouseEvent me) {
ArrayList<Sprite> list = Lists.newArrayList();
getSpriteManager().getHitSprites(list, me.getX(), me.getY());
for (int ii = 0, nn = list.size(); ii < nn; ii++) {
@@ -345,8 +345,7 @@ public class VirtualMediaPanel extends MediaPanel
break;
default:
log.warning("Eh? Set to invalid pathable mode " +
"[mode=" + _fmode + "].");
log.warning("Eh? Set to invalid pathable mode", "mode", _fmode);
break;
}
@@ -28,11 +28,10 @@ import com.threerings.media.MediaPanel;
import com.threerings.media.sprite.Sprite;
/**
* A Sprite that wraps an animation so that a sequence of frames can be easily
* moved around the screen. Animations embedded here should not be added
* directly to a media panel as this sprite will manage them. If the enclosed
* animation completes, we remove the sprite from the media panel, since the
* animation would normally do that itself.
* A Sprite that wraps an animation so that a sequence of frames can be easily moved around the
* screen. Animations embedded here should not be added directly to a media panel as this sprite
* will manage them. If the enclosed animation completes, we remove the sprite from the media
* panel, since the animation would normally do that itself.
*/
public class AnimationSprite extends Sprite
{
@@ -411,16 +411,14 @@ public abstract class Sprite extends AbstractMedia
protected long _when;
}
/** The location of the sprite's origin in pixel coordinates. If the
* sprite positions itself via a hotspot that is not the upper left
* coordinate of the sprite's bounds, the offset to the hotspot should
* be maintained in {@link #_oxoff} and {@link #_oyoff}. */
/** The location of the sprite's origin in pixel coordinates. If the sprite positions itself
* via a hotspot that is not the upper left coordinate of the sprite's bounds, the offset to
* the hotspot should be maintained in {@link #_oxoff} and {@link #_oyoff}. */
protected int _ox = Integer.MIN_VALUE, _oy = Integer.MIN_VALUE;
/** The offsets from our upper left coordinate to our origin (or hot
* spot). Derived classes will need to update these values if the
* sprite's origin is not coincident with the upper left coordinate of
* its bounds. */
/** The offsets from our upper left coordinate to our origin (or hot spot). Derived classes
* will need to update these values if the sprite's origin is not coincident with the upper
* left coordinate of its bounds. */
protected int _oxoff, _oyoff;
/** The orientation of this sprite. */
@@ -22,8 +22,7 @@
package com.threerings.media.sprite.action;
/**
* An ActionSprite that wishes to be notified of events when it is armed
* or not.
* An ActionSprite that wishes to be notified of events when it is armed or not.
*/
public interface ArmingSprite extends ActionSprite
{
@@ -22,8 +22,7 @@
package com.threerings.media.sprite.action;
/**
* An interface indicating that a sprite wishes to be notified when
* the mouse hovers over it.
* An interface indicating that a sprite wishes to be notified when the mouse hovers over it.
*/
public interface HoverSprite
{
@@ -280,8 +280,7 @@ public class TileSetBundler
continue;
}
// make sure this tileset's image file exists and check
// its last modified date
// make sure this tileset's image file exists and check its last modified date
File tsfile = new File(bundleDesc.getParent(),
set.getImagePath());
if (!tsfile.exists()) {
@@ -39,11 +39,10 @@ import com.threerings.util.DirectionUtil;
import static com.threerings.media.Log.log;
/**
* The line segment path is used to cause a pathable to follow a path that
* is made up of a sequence of line segments. There must be at least two
* nodes in any worthwhile path. The direction of the first node in the
* path is meaningless since the pathable begins at that node and will
* therefore never be heading towards it.
* The line segment path is used to cause a pathable to follow a path that is made up of a
* sequence of line segments. There must be at least two nodes in any worthwhile path. The
* direction of the first node in the path is meaningless since the pathable begins at that node
* and will therefore never be heading towards it.
*/
public class LineSegmentPath
implements DirectionCodes, Path
@@ -56,11 +55,10 @@ public class LineSegmentPath
}
/**
* Constructs a line segment path that consists of a single segment
* connecting the point <code>(x1, y1)</code> with <code>(x2,
* y2)</code>. The orientation for the first node is set arbitrarily
* and the second node is oriented based on the vector between the two
* nodes (in top-down coordinates).
* Constructs a line segment path that consists of a single segment connecting the point
* <code>(x1, y1)</code> with <code>(x2, y2)</code>. The orientation for the first node is set
* arbitrarily and the second node is oriented based on the vector between the two nodes (in
* top-down coordinates).
*/
public LineSegmentPath (int x1, int y1, int x2, int y2)
{
@@ -71,8 +69,7 @@ public class LineSegmentPath
}
/**
* Construct a line segment path between the two nodes with the
* specified direction.
* Construct a line segment path between the two nodes with the specified direction.
*/
public LineSegmentPath (Point p1, Point p2, int dir)
{
@@ -81,8 +78,8 @@ public class LineSegmentPath
}
/**
* Constructs a line segment path with the specified list of points.
* An arbitrary direction will be assigned to the starting node.
* Constructs a line segment path with the specified list of points. An arbitrary direction
* will be assigned to the starting node.
*/
public LineSegmentPath (List<Point> points)
{
@@ -90,8 +87,7 @@ public class LineSegmentPath
}
/**
* Returns the orientation the sprite will face at the end of the
* path.
* Returns the orientation the sprite will face at the end of the path.
*/
public int getFinalOrientation ()
{
@@ -99,8 +95,7 @@ public class LineSegmentPath
}
/**
* Add a node to the path with the specified destination point and
* facing direction.
* Add a node to the path with the specified destination point and facing direction.
*
* @param x the x-position.
* @param y the y-position.
@@ -112,8 +107,7 @@ public class LineSegmentPath
}
/**
* Return the requested node index in the path, or null if no such
* index exists.
* Return the requested node index in the path, or null if no such index exists.
*
* @param idx the node index.
*
@@ -133,12 +127,10 @@ public class LineSegmentPath
}
/**
* Sets the velocity of this pathable in pixels per millisecond. The
* velocity is measured as pixels traversed along the path that the
* pathable is traveling rather than in the x or y directions
* individually. Note that the pathable velocity should not be
* changed while a path is being traversed; doing so may result in the
* pathable position changing unexpectedly.
* Sets the velocity of this pathable in pixels per millisecond. The velocity is measured as
* pixels traversed along the path that the pathable is traveling rather than in the x or y
* directions individually. Note that the pathable velocity should not be changed while a path
* is being traversed; doing so may result in the pathable position changing unexpectedly.
*
* @param velocity the pathable velocity in pixels per millisecond.
*/
@@ -148,12 +140,10 @@ public class LineSegmentPath
}
/**
* Computes the velocity at which the pathable will need to travel
* along this path such that it will arrive at the destination in
* approximately the specified number of milliseconds. Efforts are
* taken to get the pathable there as close to the desired time as
* possible, but framerate variation may prevent it from arriving
* exactly on time.
* Computes the velocity at which the pathable will need to travel along this path such that
* it will arrive at the destination in approximately the specified number of milliseconds.
* Efforts are taken to get the pathable there as close to the desired time as possible, but
* framerate variation may prevent it from arriving exactly on time.
*/
public void setDuration (long millis)
{
@@ -161,8 +151,8 @@ public class LineSegmentPath
// information to compute our velocity
int ncount = _nodes.size();
if (ncount < 2) {
log.warning("Requested to set duration of bogus path " +
"[path=" + this + ", duration=" + millis + "].");
log.warning("Requested to set duration of bogus path",
"path", this, "duration", millis);
return;
}
@@ -185,8 +175,7 @@ public class LineSegmentPath
// give the pathable a chance to perform any starting antics
pable.pathBeginning();
// if we have only one node then let the pathable know that we're
// done straight away
// if we have only one node then let the pathable know that we're done straight away
if (size() < 2) {
// move the pathable to the location specified by the first
// node (assuming we have a first node)
@@ -257,16 +246,14 @@ public class LineSegmentPath
}
/**
* Place the pathable moving along the path at the end of the previous
* path node, face it appropriately for the next node, and start it on
* its way. Returns whether the pathable position moved.
* Place the pathable moving along the path at the end of the previous path node, face it
* appropriately for the next node, and start it on its way. Returns whether the pathable
* position moved.
*/
protected boolean headToNextNode (
Pathable pable, long startstamp, long now)
protected boolean headToNextNode (Pathable pable, long startstamp, long now)
{
if (_niter == null) {
throw new IllegalStateException(
"headToNextNode() called before init()");
throw new IllegalStateException("headToNextNode() called before init()");
}
// check to see if we've completed our path
@@ -327,9 +314,8 @@ public class LineSegmentPath
}
/**
* Populate the path with the path nodes that lead the pathable from
* its starting position to the given destination coordinates
* following the given list of screen coordinates.
* Populate the path with the path nodes that lead the pathable from its starting position to
* the given destination coordinates following the given list of screen coordinates.
*/
protected void createPath (List<Point> points)
{
@@ -57,9 +57,9 @@ public class PathNode
}
/**
* This should be overridden by derived classes (which should be sure
* to call <code>super.toString()</code>) to append the derived class
* specific path node information to the string buffer.
* This should be overridden by derived classes (which should be sure to call
* <code>super.toString()</code>) to append the derived class specific path node information
* to the string buffer.
*/
public void toString (StringBuilder buf)
{
@@ -51,17 +51,16 @@ public interface Pathable
public void setLocation (int x, int y);
/**
* Will be called by a path when it moves the pathable in the
* specified direction. Pathables that wish to face in the direction
* they are moving can take advantage of this callback.
* Will be called by a path when it moves the pathable in the specified direction. Pathables
* that wish to face in the direction they are moving can take advantage of this callback.
*
* @see DirectionCodes
*/
public void setOrientation (int orient);
/**
* Should return the orientation of the pathable, or {@link
* DirectionCodes#NONE} if the pathable does not support orientation.
* Should return the orientation of the pathable, or {@link DirectionCodes#NONE} if the
* pathable does not support orientation.
*/
public int getOrientation ();
@@ -146,8 +146,7 @@ public class ObjectSet
}
/**
* Returns the index of the object or its insertion index if it is
* not in the set.
* Returns the index of the object or its insertion index if it is not in the set.
*/
protected final int indexOf (ObjectInfo info)
{