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

public Class Animator

extends AnimatorBase
Class Inheritance
Imports
com.jogamp.common.ExceptionUtils, com.jogamp.common.util.InterruptSource, .SourcedInterruptedException, com.jogamp.opengl.GLAutoDrawable, .GLException

An Animator can be attached to one or more GLAutoDrawables to drive their display() methods in a loop.

The Animator class creates a background thread in which the calls to display() are performed. After each drawable has been redrawn, a brief pause is performed to avoid swamping the CPU, unless setRunAsFastAsPossible has been called.

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
pack-priv boolean
pack-priv volatile boolean
private boolean
private Runnable
pack-priv volatile boolean
private ThreadGroup
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
Animator()

Creates a new, empty Animator.

public
Animator(final ThreadGroup tg)

Creates a new Animator w/ an associated ThreadGroup.

public
Animator(final GLAutoDrawable drawable)

Creates a new Animator for a particular drawable.

public
Animator(final ThreadGroup tg, final GLAutoDrawable drawable)

Creates a new Animator w/ an associated ThreadGroup for a particular drawable.

Method Summary

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

Implements com.jogamp.opengl.GLAnimatorControl.isAnimating.

Indicates whether this animator is started and is not paused.
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 synchronized void
setRunAsFastAsPossible(final boolean runFast)

Sets a flag in this Animator indicating that it is to run as fast as possible.

public final synchronized void
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 animator.
Inherited from com.jogamp.opengl.util.AnimatorBase:
adddisplayfinishLifecycleActionflushGLRunnablesgetExclusiveContextThreadgetFPSStartTimegetLastFPSgetLastFPSPeriodgetLastFPSUpdateTimegetModeBitsgetThreadgetThreadNamegetTotalFPSgetTotalFPSDurationgetTotalFPSFramesgetUncaughtExceptionHandlergetUpdateFPSFrameshandleUncaughtExceptioninitImplisExclusiveContextEnabledisStartedremoveresetFPSCountersetDrawablesExclCtxStatesetExclusiveContextsetExclusiveContextsetIgnoreExceptionssetModeBitssetPrintExceptionssetUncaughtExceptionHandlersetUpdateFPSFramestoStringvalidateDrawablesExclCtxState

Field Detail

isAnimatingback to summary
pack-priv boolean isAnimating
pauseIssuedback to summary
pack-priv volatile boolean pauseIssued
runAsFastAsPossibleback to summary
private boolean runAsFastAsPossible
runnableback to summary
private Runnable runnable
stopIssuedback to summary
pack-priv volatile boolean stopIssued
threadGroupback to summary
private ThreadGroup threadGroup
waitForPausedConditionback to summary
private final AnimatorBase.Condition waitForPausedCondition
waitForResumeConditionback to summary
private final AnimatorBase.Condition waitForResumeCondition
waitForStartedConditionback to summary
private final AnimatorBase.Condition waitForStartedCondition
waitForStoppedConditionback to summary
private final AnimatorBase.Condition waitForStoppedCondition

Constructor Detail

Animatorback to summary
public Animator()

Creates a new, empty Animator.

Animatorback to summary
public Animator(final ThreadGroup tg)

Creates a new Animator w/ an associated ThreadGroup.

Animatorback to summary
public Animator(final GLAutoDrawable drawable)

Creates a new Animator for a particular drawable.

Animatorback to summary
public Animator(final ThreadGroup tg, final GLAutoDrawable drawable)

Creates a new Animator w/ an associated ThreadGroup for a particular drawable.

Method Detail

getBaseNameback to summary
protected final String getBaseName(final String prefix)

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

Annotations
@Override
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
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
setRunAsFastAsPossibleback to summary
public final synchronized void setRunAsFastAsPossible(final boolean runFast)

Sets a flag in this Animator indicating that it is to run as fast as possible. By default there is a brief pause in the animation loop which prevents the CPU from getting swamped. This method may not have an effect on subclasses.

setThreadGroupback to summary
public final synchronized void setThreadGroup(final ThreadGroup tg) throws GLException

Set a ThreadGroup for the animation thread.

Parameters
tg:ThreadGroup

the ThreadGroup

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.

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

Stops 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

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 Animator.MainLoop

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Constructor Detail

MainLoopback to summary
pack-priv MainLoop()

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
toStringback to summary
public 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