com.threerings.media
Class FrameInterval

java.lang.Object
  extended by com.threerings.media.FrameInterval
All Implemented Interfaces:
FrameParticipant

public abstract class FrameInterval
extends Object
implements FrameParticipant


Field Summary
protected  long _initDelay
          Time between expirations.
protected  FrameManager _mgr
          The context whose FrameManager we are using.
protected  long _nextTime
          Time of the next expiration.
protected  long _repeatDelay
          Time between expirations.
 
Constructor Summary
FrameInterval(FrameManager mgr)
          Constructor - registers the interval as a frame participant
 
Method Summary
 void cancel()
          Cancel the current schedule, and ensure that any expirations that are queued up but have not yet run do not run.
abstract  void expired()
          The main method where your interval should do its work.
 Component getComponent()
          If a frame participant wishes also to be actively rendered every frame rather than use passive rendering (which for Swing, at least, is hijacked when using the frame manager such that we take care of repainting dirty Swing components every frame into our off-screen buffer), it can return a component here which will have Component.paint(java.awt.Graphics) called on it once per frame with a translated but unclipped graphics object.
 boolean needsPaint()
          Called immediately prior to FrameParticipant.getComponent() and then Component.paint(java.awt.Graphics) on said component, to determine whether or not this frame participant needs to be painted.
 void schedule(long delay)
          Schedule the interval to execute once, after the specified delay.
 void schedule(long delay, boolean repeat)
          Schedule the interval to execute repeatedly, with the same delay.
 void schedule(long initialDelay, long repeatDelay)
          Schedule the interval to execute repeatedly with the specified initial delay and repeat delay.
 void tick(long tickStamp)
          This is called on all registered frame participants, one for every frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_nextTime

protected long _nextTime
Time of the next expiration.


_repeatDelay

protected long _repeatDelay
Time between expirations.


_initDelay

protected long _initDelay
Time between expirations.


_mgr

protected FrameManager _mgr
The context whose FrameManager we are using.

Constructor Detail

FrameInterval

public FrameInterval(FrameManager mgr)
Constructor - registers the interval as a frame participant

Method Detail

getComponent

public Component getComponent()
Description copied from interface: FrameParticipant
If a frame participant wishes also to be actively rendered every frame rather than use passive rendering (which for Swing, at least, is hijacked when using the frame manager such that we take care of repainting dirty Swing components every frame into our off-screen buffer), it can return a component here which will have Component.paint(java.awt.Graphics) called on it once per frame with a translated but unclipped graphics object.

Because clipping is expensive in terms of rectangle object allocation, frame participants are given the opportunity to do their own clipping because they are likely to want to clip to a more fine grained region than their entire bounds. If a participant does not wish to be actively rendered, it can safely return null.

Specified by:
getComponent in interface FrameParticipant

needsPaint

public boolean needsPaint()
Description copied from interface: FrameParticipant
Called immediately prior to FrameParticipant.getComponent() and then Component.paint(java.awt.Graphics) on said component, to determine whether or not this frame participant needs to be painted.

Specified by:
needsPaint in interface FrameParticipant

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

expired

public abstract void expired()
The main method where your interval should do its work.


schedule

public final void schedule(long delay)
Schedule the interval to execute once, after the specified delay. Supersedes any previous schedule that this Interval may have had.


schedule

public final void schedule(long delay,
                           boolean repeat)
Schedule the interval to execute repeatedly, with the same delay. Supersedes any previous schedule that this Interval may have had.


schedule

public final void schedule(long initialDelay,
                           long repeatDelay)
Schedule the interval to execute repeatedly with the specified initial delay and repeat delay. Supersedes any previous schedule that this Interval may have had.


cancel

public final void cancel()
Cancel the current schedule, and ensure that any expirations that are queued up but have not yet run do not run.