com.threerings.media.animation
Class RainAnimation

java.lang.Object
  extended by com.threerings.media.AbstractMedia
      extended by com.threerings.media.animation.Animation
          extended by com.threerings.media.animation.RainAnimation
All Implemented Interfaces:
Shape

public class RainAnimation
extends Animation

An animation that displays raindrops spattering across an image.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.animation.Animation
Animation.AnimCompletedOp, Animation.AnimStartedOp
 
Field Summary
protected  int _count
          The number of raindrops.
protected  int[] _drops
          The raindrop locations.
protected  long _duration
          Animation ending timing information.
protected  long _end
          Animation ending timing information.
protected  int _hei
          The dimensions of each raindrop's bounding rectangle.
protected  int _wid
          The dimensions of each raindrop's bounding rectangle.
protected static int DEFAULT_COUNT
          The number of raindrops.
protected static int DEFAULT_HEIGHT
           
protected static int DEFAULT_WIDTH
          The raindrop streak dimensions.
 
Fields inherited from class com.threerings.media.animation.Animation
_finished
 
Fields inherited from class com.threerings.media.AbstractMedia
_bounds, _firstTick, _mgr, _observers, _renderOrder, HUD_LAYER
 
Constructor Summary
RainAnimation(Rectangle bounds, long duration)
          Constructs a rain animation with reasonable defaults for the number of raindrops and their dimensions.
RainAnimation(Rectangle bounds, long duration, int count, int wid, int hei)
          Constructs a rain animation.
 
Method Summary
 void fastForward(long timeDelta)
          Called when the appropriate media manager has been paused for some length of time and is then unpaused.
protected  void init(long duration, int count, int wid, int hei)
           
 void paint(Graphics2D gfx)
          Called by the appropriate manager to request that the media render itself with the given graphics context.
 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.animation.Animation
addAnimationObserver, didFinish, isFinished, removeAnimationObserver, reset, setLocation, willFinish, willStart
 
Methods inherited from class com.threerings.media.AbstractMedia
addObserver, contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, getRenderOrder, init, init, intersects, intersects, invalidate, invalidateAfterChange, naturalCompareTo, queueNotification, removeObserver, renderCompareTo, setRenderOrder, shutdown, toString, toString, viewLocationDidChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_COUNT

protected static final int DEFAULT_COUNT
The number of raindrops.

See Also:
Constant Field Values

DEFAULT_WIDTH

protected static final int DEFAULT_WIDTH
The raindrop streak dimensions.

See Also:
Constant Field Values

DEFAULT_HEIGHT

protected static final int DEFAULT_HEIGHT
See Also:
Constant Field Values

_count

protected int _count
The number of raindrops.


_wid

protected int _wid
The dimensions of each raindrop's bounding rectangle.


_hei

protected int _hei
The dimensions of each raindrop's bounding rectangle.


_drops

protected int[] _drops
The raindrop locations.


_duration

protected long _duration
Animation ending timing information.


_end

protected long _end
Animation ending timing information.

Constructor Detail

RainAnimation

public RainAnimation(Rectangle bounds,
                     long duration)
Constructs a rain animation with reasonable defaults for the number of raindrops and their dimensions.

Parameters:
bounds - the bounding rectangle for the animation.
duration - the number of seconds the animation should last.

RainAnimation

public RainAnimation(Rectangle bounds,
                     long duration,
                     int count,
                     int wid,
                     int hei)
Constructs a rain animation.

Parameters:
bounds - the bounding rectangle for the animation.
duration - the number of seconds the animation should last.
count - the number of raindrops to render in each frame.
wid - the width of a raindrop's bounding rectangle.
hei - the height of a raindrop's bounding rectangle.
Method Detail

init

protected void init(long duration,
                    int count,
                    int wid,
                    int hei)

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.

Specified by:
tick in class AbstractMedia
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.

fastForward

public void fastForward(long timeDelta)
Description copied from class: AbstractMedia
Called when the appropriate media manager has been paused for some length of time and is then unpaused. Media should adjust any time stamps that are maintained internally forward by the delta so that time maintains the illusion of flowing smoothly forward.

Overrides:
fastForward in class AbstractMedia

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.

Specified by:
paint in class AbstractMedia