com.threerings.media
Class HourglassView

java.lang.Object
  extended by com.threerings.media.TimerView
      extended by com.threerings.media.HourglassView
All Implemented Interfaces:
FrameParticipant, HierarchyListener, EventListener

public class HourglassView
extends TimerView

Displays an hourglass with the sand level representing the amount of time remaining.


Field Summary
protected  Point _botOff
          Offsets at which to render the sand images.
protected  Rectangle _botRect
          The bounds of the sand within the top and bottom sand images.
protected  Mirage _hourglass
          Our images.
protected  Mirage _sandBottom
          Our images.
protected  int _sandFrame
          The next sand frame to be painted.
protected  long _sandStamp
          The last time the sand updated moved.
protected  Mirage _sandTop
          Our images.
protected  MultiFrameImage _sandTrickle
          The sand trickle.
protected  int _sandY
          The position of the top of the sand.
protected  Point _topOff
          Offsets at which to render the sand images.
protected  Rectangle _topRect
          The bounds of the sand within the top and bottom sand images.
protected static long SAND_RATE
          How often the sand frame updates.
 
Fields inherited from class com.threerings.media.TimerView
_bounds, _changeThreshold, _complete, _completed, _duration, _enabled, _finisher, _fmgr, _host, _invalidated, _lastUpdate, _paintComplete, _participating, _processUnpause, _renderComplete, _renderOffset, _renderOffsetTime, _running, _start, _transitionTime, _warned, _warner, _warnPercent, DEFAULT_RATE
 
Constructor Summary
HourglassView(FrameManager fmgr, JComponent host, int x, int y, Mirage glassImage, Mirage topImage, Rectangle topRect, Mirage botImage, Rectangle botRect, MultiFrameImage sandTrickle)
          Constructs an hourglass view.
HourglassView(FrameManager fmgr, JComponent host, int x, int y, Mirage glassImage, Mirage topImage, Rectangle topRect, Point topOff, Mirage botImage, Rectangle botRect, Point botOff, MultiFrameImage sandTrickle)
          Constructs an hourglass view.
 
Method Summary
 void changeComplete(float complete)
          Generate an unexpected change in the timer's completion and set up the necessary details to render interpolation from the old to new states
protected  int getSandBottomTop(float completed)
          Returns the current top coordinate of the bottom sand pile.
 void paint(Graphics2D gfx, float completed)
          Paint the timer into the given graphics context at the inputted percent complete (0f means just started, 1f means just finished).
protected  void setSandTrickleY()
          Set the y position of the trickle.
 void tick(long tickStamp)
          This is called on all registered frame participants, one for every frame.
 
Methods inherited from class com.threerings.media.TimerView
checkFrameParticipation, getComponent, getTransitionTime, handleCompleted, handleWarning, hierarchyChanged, invalidate, needsPaint, pause, removeWarning, render, reset, running, setEnabled, setTransitionTime, setWarning, start, stop, triggeredCompleted, triggeredWarning, unpause, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_topRect

protected Rectangle _topRect
The bounds of the sand within the top and bottom sand images.


_botRect

protected Rectangle _botRect
The bounds of the sand within the top and bottom sand images.


_topOff

protected Point _topOff
Offsets at which to render the sand images.


_botOff

protected Point _botOff
Offsets at which to render the sand images.


_hourglass

protected Mirage _hourglass
Our images.


_sandTop

protected Mirage _sandTop
Our images.


_sandBottom

protected Mirage _sandBottom
Our images.


_sandTrickle

protected MultiFrameImage _sandTrickle
The sand trickle.


_sandStamp

protected long _sandStamp
The last time the sand updated moved.


_sandFrame

protected int _sandFrame
The next sand frame to be painted.


_sandY

protected int _sandY
The position of the top of the sand.


SAND_RATE

protected static final long SAND_RATE
How often the sand frame updates.

See Also:
Constant Field Values
Constructor Detail

HourglassView

public HourglassView(FrameManager fmgr,
                     JComponent host,
                     int x,
                     int y,
                     Mirage glassImage,
                     Mirage topImage,
                     Rectangle topRect,
                     Mirage botImage,
                     Rectangle botRect,
                     MultiFrameImage sandTrickle)
Constructs an hourglass view.


HourglassView

public HourglassView(FrameManager fmgr,
                     JComponent host,
                     int x,
                     int y,
                     Mirage glassImage,
                     Mirage topImage,
                     Rectangle topRect,
                     Point topOff,
                     Mirage botImage,
                     Rectangle botRect,
                     Point botOff,
                     MultiFrameImage sandTrickle)
Constructs an hourglass view.

Method Detail

changeComplete

public void changeComplete(float complete)
Description copied from class: TimerView
Generate an unexpected change in the timer's completion and set up the necessary details to render interpolation from the old to new states

Overrides:
changeComplete in class TimerView

tick

public void tick(long tickStamp)
Description copied from interface: FrameParticipant
This is called on all registered frame participants, one for every frame. Following the tick the interface will be rendered, so participants can prepare themselves for their upcoming render in this method (making use of the timestamp provided for the frame if choreography is desired between different participants).

Specified by:
tick in interface FrameParticipant
Overrides:
tick in class TimerView

paint

public void paint(Graphics2D gfx,
                  float completed)
Description copied from class: TimerView
Paint the timer into the given graphics context at the inputted percent complete (0f means just started, 1f means just finished).

Overrides:
paint in class TimerView

setSandTrickleY

protected void setSandTrickleY()
Set the y position of the trickle.


getSandBottomTop

protected int getSandBottomTop(float completed)
Returns the current top coordinate of the bottom sand pile.