com.jogamp.opengl.util
Class FPSAnimator

java.lang.Object
  extended by com.jogamp.opengl.util.AnimatorBase
      extended by com.jogamp.opengl.util.FPSAnimator
All Implemented Interfaces:
FPSCounter, GLAnimatorControl

public class FPSAnimator
extends AnimatorBase

An Animator subclass which attempts to achieve a target frames-per-second rate to avoid using all CPU time. The target FPS is only an estimate and is not guaranteed.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.jogamp.opengl.util.AnimatorBase
AnimatorBase.AnimatorImpl
 
Field Summary
 
Fields inherited from interface javax.media.opengl.FPSCounter
DEFAULT_FRAMES_PER_INTERVAL
 
Constructor Summary
FPSAnimator(GLAutoDrawable drawable, int fps)
          Creates an FPSAnimator with a given target frames-per-second value and an initial drawable to animate.
FPSAnimator(GLAutoDrawable drawable, int fps, boolean scheduleAtFixedRate)
          Creates an FPSAnimator with a given target frames-per-second value, an initial drawable to animate, and a flag indicating whether to use fixed-rate scheduling.
FPSAnimator(int fps)
          Creates an FPSAnimator with a given target frames-per-second value.
FPSAnimator(int fps, boolean scheduleAtFixedRate)
          Creates an FPSAnimator with a given target frames-per-second value and a flag indicating whether to use fixed-rate scheduling.
 
Method Summary
 boolean isAnimating()
          Indicates whether this animator is running and animating,
the latter is true if it has GLAutoDrawables to render and is not paused.
 boolean isPaused()
          Indicates whether this animator is running and paused.
 boolean isStarted()
          Indicates whether this animator is running, ie.
 boolean pause()
          Pauses this animator.
 boolean resume()
          Resumes animation if paused.
 boolean start()
          Starts this animator, if not running.
 boolean stop()
          Stops this FPSAnimator.
 
Methods inherited from class com.jogamp.opengl.util.AnimatorBase
add, getFPSStartTime, getLastFPS, getLastFPSPeriod, getLastFPSUpdateTime, getThread, getTotalFPS, getTotalFPSDuration, getTotalFPSFrames, getUpdateFPSFrames, remove, resetFPSCounter, setIgnoreExceptions, setPrintExceptions, setUpdateFPSFrames, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FPSAnimator

public FPSAnimator(int fps)
Creates an FPSAnimator with a given target frames-per-second value. Equivalent to FPSAnimator(null, fps).


FPSAnimator

public FPSAnimator(int fps,
                   boolean scheduleAtFixedRate)
Creates an FPSAnimator with a given target frames-per-second value and a flag indicating whether to use fixed-rate scheduling. Equivalent to FPSAnimator(null, fps, scheduleAtFixedRate).


FPSAnimator

public FPSAnimator(GLAutoDrawable drawable,
                   int fps)
Creates an FPSAnimator with a given target frames-per-second value and an initial drawable to animate. Equivalent to FPSAnimator(null, fps, false).


FPSAnimator

public FPSAnimator(GLAutoDrawable drawable,
                   int fps,
                   boolean scheduleAtFixedRate)
Creates an FPSAnimator with a given target frames-per-second value, an initial drawable to animate, and a flag indicating whether to use fixed-rate scheduling.

Method Detail

isStarted

public final boolean isStarted()
Description copied from interface: GLAnimatorControl
Indicates whether this animator is running, ie. has been started and not stopped.

See Also:
GLAnimatorControl.start(), GLAnimatorControl.stop(), GLAnimatorControl.pause(), GLAnimatorControl.resume()

isAnimating

public final boolean isAnimating()
Description copied from interface: GLAnimatorControl
Indicates whether this animator is running and animating,
the latter is true if it has GLAutoDrawables to render and is not paused.

See Also:
GLAnimatorControl.start(), GLAnimatorControl.stop(), GLAnimatorControl.pause(), GLAnimatorControl.resume()

isPaused

public final boolean isPaused()
Description copied from interface: GLAnimatorControl
Indicates whether this animator is running and paused.

See Also:
GLAnimatorControl.start(), GLAnimatorControl.stop(), GLAnimatorControl.pause(), GLAnimatorControl.resume()

start

public boolean start()
Description copied from interface: GLAnimatorControl
Starts this animator, if not running.

In most situations this method blocks until completion, except when called from the animation thread itself or in some cases from an implementation-internal thread like the AWT event queue thread.

If started, all counters (time, frames, ..) are reset to zero.

Returns:
true is started due to this call, otherwise false, ie started already or unable to start.
See Also:
GLAnimatorControl.stop(), GLAnimatorControl.isAnimating(), GLAnimatorControl.getThread()

stop

public boolean stop()
Stops this FPSAnimator. Due to the implementation of the FPSAnimator it is not guaranteed that the FPSAnimator will be completely stopped by the time this method returns.

Returns:
true is stopped due to this call, otherwise false, ie not started or unable to stop.
See Also:
GLAnimatorControl.start(), GLAnimatorControl.isAnimating(), GLAnimatorControl.getThread()

pause

public boolean pause()
Description copied from interface: GLAnimatorControl
Pauses this animator.

In most situations this method blocks until completion, except when called from the animation thread itself or in some cases from an implementation-internal thread like the AWT event queue thread.

Returns:
false if if not started or already paused, otherwise true
See Also:
GLAnimatorControl.resume(), GLAnimatorControl.isAnimating()

resume

public boolean resume()
Description copied from interface: GLAnimatorControl
Resumes animation if paused.

In most situations this method blocks until completion, except when called from the animation thread itself or in some cases from an implementation-internal thread like the AWT event queue thread.

If resumed, all counters (time, frames, ..) are reset to zero.

Returns:
false if if not started or not paused, otherwise true
See Also:
GLAnimatorControl.pause(), GLAnimatorControl.isAnimating()


Copyright 2010 JogAmp Community.