com.threerings.media.animation
Class FloatingTextAnimation

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

public class FloatingTextAnimation
extends Animation


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.animation.Animation
Animation.AnimCompletedOp, Animation.AnimStartedOp
 
Field Summary
protected  float _alpha
          The current alpha level used to render the score.
protected  Composite _comp
          The composite used to render the score.
protected  int _destx
          The destination coordinates towards which the animation travels.
protected  int _desty
          The destination coordinates towards which the animation travels.
protected  int _dx
          The distance to be traveled by the score animation.
protected  int _dy
          The distance to be traveled by the score animation.
protected  long _floatPeriod
          The duration for which we float up the screen.
protected  Label _label
          The label we're animating.
protected  long _start
          The starting animation time.
protected  int _startX
          The starting coordinates of the score.
protected  int _startY
          The starting coordinates of the score.
protected  int _x
          The current coordinates of the score.
protected  int _y
          The current coordinates of the score.
protected static long DEFAULT_FLOAT_PERIOD
          The time in milliseconds during which the score is visible.
protected static int DELTA_Y
          The total vertical distance the score travels.
 
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
FloatingTextAnimation(Label label, int x, int y)
          Constructs an animation for the given text centered at the given coordinates.
FloatingTextAnimation(Label label, int sx, int sy, int destx, int desty, long floatPeriod)
          Constructs an animation for the given text starting at the given coordinates and floating toward the specified coordinates.
FloatingTextAnimation(Label label, int x, int y, long floatPeriod)
          Constructs an animation for the given text centered at the given coordinates.
 
Method Summary
 void fastForward(long timeDelta)
          Called when the appropriate media manager has been paused for some length of time and is then unpaused.
 void flipDirection()
          Called to change the direction 180 degrees.
 Label getLabel()
          Returns the label used to render this score animation.
 void paint(Graphics2D gfx)
          Called by the appropriate manager to request that the media render itself with the given graphics context.
protected  void paintLabels(Graphics2D gfx, int x, int y)
          Derived classes may wish to extend score animation and render more than just the standard single label.
 void setFloatPeriod(long floatPeriod)
          Sets the duration of this score animation to the specified time in milliseconds.
 void setLocation(int x, int y)
          Set the location.
 void tick(long timestamp)
          Called periodically by this media's manager to give it a chance to do its thing.
protected  void toString(StringBuilder buf)
          This should be overridden by derived classes (which should be sure to call super.toString()) to append the derived class specific information to the string buffer.
 
Methods inherited from class com.threerings.media.animation.Animation
addAnimationObserver, didFinish, isFinished, removeAnimationObserver, reset, 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, viewLocationDidChange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_start

protected long _start
The starting animation time.


_label

protected Label _label
The label we're animating.


_startX

protected int _startX
The starting coordinates of the score.


_startY

protected int _startY
The starting coordinates of the score.


_x

protected int _x
The current coordinates of the score.


_y

protected int _y
The current coordinates of the score.


_destx

protected int _destx
The destination coordinates towards which the animation travels.


_desty

protected int _desty
The destination coordinates towards which the animation travels.


_dx

protected int _dx
The distance to be traveled by the score animation.


_dy

protected int _dy
The distance to be traveled by the score animation.


_floatPeriod

protected long _floatPeriod
The duration for which we float up the screen.


_alpha

protected float _alpha
The current alpha level used to render the score.


_comp

protected Composite _comp
The composite used to render the score.


DEFAULT_FLOAT_PERIOD

protected static final long DEFAULT_FLOAT_PERIOD
The time in milliseconds during which the score is visible.

See Also:
Constant Field Values

DELTA_Y

protected static final int DELTA_Y
The total vertical distance the score travels.

See Also:
Constant Field Values
Constructor Detail

FloatingTextAnimation

public FloatingTextAnimation(Label label,
                             int x,
                             int y)
Constructs an animation for the given text centered at the given coordinates.


FloatingTextAnimation

public FloatingTextAnimation(Label label,
                             int x,
                             int y,
                             long floatPeriod)
Constructs an animation for the given text centered at the given coordinates. The animation will float up the screen for 30 pixels.


FloatingTextAnimation

public FloatingTextAnimation(Label label,
                             int sx,
                             int sy,
                             int destx,
                             int desty,
                             long floatPeriod)
Constructs an animation for the given text starting at the given coordinates and floating toward the specified coordinates.

Method Detail

flipDirection

public void flipDirection()
Called to change the direction 180 degrees.


getLabel

public Label getLabel()
Returns the label used to render this score animation.


setLocation

public void setLocation(int x,
                        int y)
Description copied from class: AbstractMedia
Set the location.

Overrides:
setLocation in class Animation

setFloatPeriod

public void setFloatPeriod(long floatPeriod)
Sets the duration of this score animation to the specified time in milliseconds. This should be called before the animation is added to the animation manager.


tick

public void tick(long timestamp)
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:
timestamp - 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

paintLabels

protected void paintLabels(Graphics2D gfx,
                           int x,
                           int y)
Derived classes may wish to extend score animation and render more than just the standard single label.

Parameters:
x - the upper left coordinate of the animation.
y - the upper left coordinate of the animation.

toString

protected void toString(StringBuilder buf)
Description copied from class: AbstractMedia
This should be overridden by derived classes (which should be sure to call super.toString()) to append the derived class specific information to the string buffer.

Overrides:
toString in class AbstractMedia