Top Description Inners Fields Constructors Methods
com.jogamp.opengl.util

public Class FPSAnimator

extends AnimatorBase
Class Inheritance
Imports
java.util.Timer, .TimerTask, com.jogamp.opengl.GLAutoDrawable, .GLException, com.jogamp.common.ExceptionUtils

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.

The Animator execution thread does not run as a daemon thread, so it is able to keep an application from terminating.
Call stop() to terminate the animation and it's execution thread.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class

Field Summary

Modifier and TypeField and Description
private int
private boolean
private volatile boolean
private final boolean
private volatile boolean
private FPSAnimator.MainTask
private Timer
pack-priv static int
private final AnimatorBase.Condition
private final AnimatorBase.Condition
private final AnimatorBase.Condition
private final AnimatorBase.Condition
private final AnimatorBase.Condition
Inherited from com.jogamp.opengl.util.AnimatorBase:
animThreadbaseNameDEBUGdrawablesdrawablesEmptyexclusiveContextfpsCounterignoreExceptionsimplMODE_EXPECT_AWT_RENDERING_THREADmodeBitsPOLLP_WAIT_FOR_FINISH_LIFECYCLE_ACTIONprintExceptionsTO_WAIT_FOR_FINISH_LIFECYCLE_ACTIONuncaughtExceptionHandleruserExclusiveContextThread

Constructor Summary

AccessConstructor and Description
public
FPSAnimator(final int fps)

Creates an FPSAnimator with a given target frames-per-second value.

public
FPSAnimator(final int fps, final boolean scheduleAtFixedRate)

Creates an FPSAnimator with a given target frames-per-second value and a flag indicating whether to use fixed-rate scheduling.

public
FPSAnimator(final GLAutoDrawable drawable, final int fps)

Creates an FPSAnimator with a given target frames-per-second value and an initial drawable to animate.

public
FPSAnimator(final GLAutoDrawable drawable, final int fps, final 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 Summary

Modifier and TypeMethod and Description
protected String
public final int
public final synchronized boolean
isAnimating()

Implements com.jogamp.opengl.GLAnimatorControl.isAnimating.

Indicates whether this animator is started and is not paused.
private final boolean
public final synchronized boolean
isPaused()

Implements com.jogamp.opengl.GLAnimatorControl.isPaused.

Indicates whether this animator is started and either manually paused or paused automatically due to no added GLAutoDrawables.
public final synchronized boolean
pause()

Implements com.jogamp.opengl.GLAnimatorControl.pause.

Pauses this animator.
public final synchronized boolean
resume()

Implements com.jogamp.opengl.GLAnimatorControl.resume.

Resumes animation if paused.
public final void
setFPS(final int fps)

public final synchronized boolean
start()

Implements com.jogamp.opengl.GLAnimatorControl.start.

Starts this animator, if not running.
public final synchronized boolean
stop()

Implements com.jogamp.opengl.GLAnimatorControl.stop.

Stops this FPSAnimator.
Inherited from com.jogamp.opengl.util.AnimatorBase:
adddisplayfinishLifecycleActionflushGLRunnablesgetExclusiveContextThreadgetFPSStartTimegetLastFPSgetLastFPSPeriodgetLastFPSUpdateTimegetModeBitsgetThreadgetThreadNamegetTotalFPSgetTotalFPSDurationgetTotalFPSFramesgetUncaughtExceptionHandlergetUpdateFPSFrameshandleUncaughtExceptioninitImplisExclusiveContextEnabledisStartedremoveresetFPSCountersetDrawablesExclCtxStatesetExclusiveContextsetExclusiveContextsetIgnoreExceptionssetModeBitssetPrintExceptionssetUncaughtExceptionHandlersetUpdateFPSFramestoStringvalidateDrawablesExclCtxState

Field Detail

fpsback to summary
private int fps
isAnimatingback to summary
private boolean isAnimating
pauseIssuedback to summary
private volatile boolean pauseIssued
scheduleAtFixedRateback to summary
private final boolean scheduleAtFixedRate
stopIssuedback to summary
private volatile boolean stopIssued
taskback to summary
private FPSAnimator.MainTask task
timerback to summary
private Timer timer
timerNoback to summary
pack-priv static int timerNo
waitForPausedConditionback to summary
private final AnimatorBase.Condition waitForPausedCondition
waitForResumeConditionback to summary
private final AnimatorBase.Condition waitForResumeCondition
waitForStartedAddedConditionback to summary
private final AnimatorBase.Condition waitForStartedAddedCondition
waitForStartedEmptyConditionback to summary
private final AnimatorBase.Condition waitForStartedEmptyCondition
waitForStoppedConditionback to summary
private final AnimatorBase.Condition waitForStoppedCondition

Constructor Detail

FPSAnimatorback to summary
public FPSAnimator(final int fps)

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

FPSAnimatorback to summary
public FPSAnimator(final int fps, final 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).

FPSAnimatorback to summary
public FPSAnimator(final GLAutoDrawable drawable, final 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).

FPSAnimatorback to summary
public FPSAnimator(final GLAutoDrawable drawable, final int fps, final 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

getBaseNameback to summary
protected String getBaseName(final String prefix)

Implements abstract com.jogamp.opengl.util.AnimatorBase.getBaseName.

Annotations
@Override
getFPSback to summary
public final int getFPS()
isAnimatingback to summary
public final synchronized boolean isAnimating()

Implements com.jogamp.opengl.GLAnimatorControl.isAnimating.

Doc from com.jogamp.opengl.GLAnimatorControl.isAnimating.

Indicates whether this animator is started and is not paused.

Annotations
@Override
isAnimatingImplback to summary
private final boolean isAnimatingImpl()
isPausedback to summary
public final synchronized boolean isPaused()

Implements com.jogamp.opengl.GLAnimatorControl.isPaused.

Doc from com.jogamp.opengl.GLAnimatorControl.isPaused.

Indicates whether this animator is started and either manually paused or paused automatically due to no added GLAutoDrawables.

Annotations
@Override
pauseback to summary
public final synchronized boolean pause()

Implements com.jogamp.opengl.GLAnimatorControl.pause.

Doc from com.jogamp.opengl.GLAnimatorControl.pause.

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:boolean

false if not started, already paused or failed to pause, otherwise true

Annotations
@Override
resumeback to summary
public final synchronized boolean resume()

Implements com.jogamp.opengl.GLAnimatorControl.resume.

Doc from com.jogamp.opengl.GLAnimatorControl.resume.

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:boolean

false if not started, not paused or unable to resume, otherwise true

Annotations
@Override
setFPSback to summary
public final void setFPS(final int fps) throws GLException
Exceptions
GLException:
if the animator has already been started
startback to summary
public final synchronized boolean start()

Implements com.jogamp.opengl.GLAnimatorControl.start.

Doc from com.jogamp.opengl.GLAnimatorControl.start.

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.

Note that an animator w/o added drawables will be paused automatically.

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

Returns:boolean

true is started due to this call, otherwise false, ie started already or unable to start.

Annotations
@Override
stopback to summary
public final synchronized boolean stop()

Implements com.jogamp.opengl.GLAnimatorControl.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:boolean

Doc from com.jogamp.opengl.GLAnimatorControl.stop.

true is stopped due to this call, otherwise false, ie not started or unable to stop.

Annotations
@Override
com.jogamp.opengl.util back to summary

pack-priv Class FPSAnimator.MainTask

extends TimerTask
Class Inheritance

Field Summary

Modifier and TypeField and Description
private boolean
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean
public void
run()

Implements abstract java.util.TimerTask.run.

Implements java.lang.Runnable.run.

The action to be performed by this timer task.
public void
start(final Timer timer)

public final String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.util.TimerTask:
cancelscheduledExecutionTime

Field Detail

alreadyPausedback to summary
private boolean alreadyPaused
alreadyStoppedback to summary
private boolean alreadyStopped
justStartedback to summary
private boolean justStarted

Constructor Detail

MainTaskback to summary
public MainTask()

Method Detail

isActiveback to summary
public boolean isActive()
runback to summary
public void run()

Implements abstract java.util.TimerTask.run.

Implements java.lang.Runnable.run.

Doc from java.util.TimerTask.run.

The action to be performed by this timer task.

Annotations
@Override
startback to summary
public void start(final Timer timer)
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override