com.threerings.media.sprite
Class FadableImageSprite

java.lang.Object
  extended by com.threerings.media.AbstractMedia
      extended by com.threerings.media.sprite.Sprite
          extended by com.threerings.media.sprite.ImageSprite
              extended by com.threerings.media.sprite.OrientableImageSprite
                  extended by com.threerings.media.sprite.FadableImageSprite
All Implemented Interfaces:
Pathable, DirectionCodes, Shape

public class FadableImageSprite
extends OrientableImageSprite


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.sprite.Sprite
Sprite.CancelledOp, Sprite.CompletedOp
 
Field Summary
protected  AlphaComposite _alphaComposite
          The alpha composite.
protected  long _fadeDelay
          If fading in without moving, the fade-in delay.
protected  long _fadeInDuration
          If fading in, the fade-in duration (otherwise -1).
protected  long _fadeOutDuration
          If fading out, the fade-out duration (otherwise -1).
protected  long _fadeStamp
          The time at which fading started.
protected  long _pathDuration
          If fading out, the path duration.
 
Fields inherited from class com.threerings.media.sprite.ImageSprite
_animMode, _firstStamp, _frameDelay, _frameIdx, _frames, DEFAULT_FRAME_RATE, MOVEMENT_CUED, NO_ANIMATION, TIME_BASED, TIME_SEQUENTIAL
 
Fields inherited from class com.threerings.media.sprite.Sprite
_orient, _ox, _oxoff, _oy, _oyoff, _path, _pathStamp
 
Fields inherited from class com.threerings.media.AbstractMedia
_bounds, _firstTick, _mgr, _observers, _renderOrder, HUD_LAYER
 
Fields inherited from interface com.threerings.util.DirectionCodes
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST
 
Constructor Summary
FadableImageSprite()
          Creates a new fadable image sprite.
FadableImageSprite(Mirage image)
          Creates a new fadable image sprite.
FadableImageSprite(MultiFrameImage frames)
          Creates a new fadable image sprite.
 
Method Summary
protected  void completeFadeIn()
          Completes the process of fading in.
protected  void completeFadeOut()
          Completes the process of fading out.
 void fadeIn(long delay, long duration)
          Fades this sprite in over the specified duration after waiting for the specified delay.
 void fadeOut(long delay, long duration)
          Fades this sprite out over the specified duration after waiting for the specified delay.
 float getAlpha()
          Returns the alpha value of this sprite.
 void moveAndFadeIn(Path path, long pathDuration, float fadePortion)
          Puts this sprite on the specified path and fades it in over the specified duration.
 void moveAndFadeInAndOut(Path path, long pathDuration, float fadePortion)
          Puts this sprite on the specified path, fading it in over the specified duration at the beginning and fading it out at the end.
 void moveAndFadeOut(Path path, long pathDuration, float fadePortion)
          Puts this sprite on the specified path and fades it out over the specified duration.
 void paint(Graphics2D gfx)
          Called by the appropriate manager to request that the media render itself with the given graphics context.
 void pathCompleted(long timestamp)
          Called by the active path when it has completed.
 void setAlpha(float alpha)
          Sets the alpha value of this sprite.
 void tick(long tickStamp)
          Called periodically by this media's manager to give it a chance to do its thing.
 
Methods inherited from class com.threerings.media.sprite.OrientableImageSprite
accomodateFrame, setOrientation
 
Methods inherited from class com.threerings.media.sprite.ImageSprite
hitTest, init, layout, setAnimationMode, setFrameIndex, setFrameRate, setFrames, setMirage, toString
 
Methods inherited from class com.threerings.media.sprite.Sprite
addSpriteObserver, cancelMove, contains, fastForward, getHeight, getOrientation, getPath, getWidth, getX, getXOffset, getY, getYOffset, inside, intersects, isMoving, move, paintPath, pathBeginning, removeSpriteObserver, setLocation, shutdown, tickPath, updateRenderOrigin, viewLocationDidChange
 
Methods inherited from class com.threerings.media.AbstractMedia
addObserver, contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, getRenderOrder, init, intersects, intersects, invalidate, invalidateAfterChange, naturalCompareTo, queueNotification, removeObserver, renderCompareTo, setRenderOrder, toString, willStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.threerings.media.util.Pathable
getBounds
 

Field Detail

_alphaComposite

protected AlphaComposite _alphaComposite
The alpha composite.


_fadeInDuration

protected long _fadeInDuration
If fading in, the fade-in duration (otherwise -1).


_fadeDelay

protected long _fadeDelay
If fading in without moving, the fade-in delay.


_fadeStamp

protected long _fadeStamp
The time at which fading started.


_fadeOutDuration

protected long _fadeOutDuration
If fading out, the fade-out duration (otherwise -1).


_pathDuration

protected long _pathDuration
If fading out, the path duration.

Constructor Detail

FadableImageSprite

public FadableImageSprite()
Creates a new fadable image sprite.


FadableImageSprite

public FadableImageSprite(Mirage image)
Creates a new fadable image sprite.

Parameters:
image - the image to render

FadableImageSprite

public FadableImageSprite(MultiFrameImage frames)
Creates a new fadable image sprite.

Parameters:
frames - the frames to render
Method Detail

fadeIn

public void fadeIn(long delay,
                   long duration)
Fades this sprite in over the specified duration after waiting for the specified delay.


fadeOut

public void fadeOut(long delay,
                    long duration)
Fades this sprite out over the specified duration after waiting for the specified delay.


moveAndFadeIn

public void moveAndFadeIn(Path path,
                          long pathDuration,
                          float fadePortion)
Puts this sprite on the specified path and fades it in over the specified duration.

Parameters:
path - the path to move along
fadePortion - the portion of time to spend fading in, from 0.0f (no time) to 1.0f (the entire time)

moveAndFadeOut

public void moveAndFadeOut(Path path,
                           long pathDuration,
                           float fadePortion)
Puts this sprite on the specified path and fades it out over the specified duration.

Parameters:
path - the path to move along
pathDuration - the duration of the path
fadePortion - the portion of time to spend fading out, from 0.0f (no time) to 1.0f (the entire time)

moveAndFadeInAndOut

public void moveAndFadeInAndOut(Path path,
                                long pathDuration,
                                float fadePortion)
Puts this sprite on the specified path, fading it in over the specified duration at the beginning and fading it out at the end.

Parameters:
path - the path to move along
pathDuration - the duration of the path
fadePortion - the portion of time to spend fading in/out, from 0.0f (no time) to 1.0f (the entire time)

tick

public void tick(long tickStamp)
Description copied from class: AbstractMedia
Called periodically by this media's manager to give it a chance to do its thing.

Overrides:
tick in class ImageSprite
Parameters:
tickStamp - a time stamp associated with this tick. Note: this is not obtained from a call to System.currentTimeMillis() and cannot be compared to timestamps obtained there from.

pathCompleted

public void pathCompleted(long timestamp)
Description copied from class: Sprite
Called by the active path when it has completed.

Specified by:
pathCompleted in interface Pathable
Overrides:
pathCompleted in class Sprite

completeFadeIn

protected void completeFadeIn()
Completes the process of fading in.


completeFadeOut

protected void completeFadeOut()
Completes the process of fading out.


paint

public void paint(Graphics2D gfx)
Description copied from class: AbstractMedia
Called by the appropriate manager to request that the media render itself with the given graphics context. The media may wish to inspect the clipping region that has been set on the graphics context to render itself more efficiently. This method will only be called after it has been established that this media's bounds intersect the clipping region.

Overrides:
paint in class OrientableImageSprite

setAlpha

public void setAlpha(float alpha)
Sets the alpha value of this sprite.


getAlpha

public float getAlpha()
Returns the alpha value of this sprite.