Class Animator
- All Implemented Interfaces:
FPSCounter,GLAnimatorControl
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(boolean) 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 Class Summary
Nested classes/interfaces inherited from class com.jogamp.opengl.util.AnimatorBase
AnimatorBase.AnimatorImpl, AnimatorBase.UncaughtAnimatorExceptionNested classes/interfaces inherited from interface com.jogamp.opengl.GLAnimatorControl
GLAnimatorControl.UncaughtExceptionHandler -
Field Summary
Fields inherited from class com.jogamp.opengl.util.AnimatorBase
MODE_EXPECT_AWT_RENDERING_THREADFields inherited from interface com.jogamp.opengl.FPSCounter
DEFAULT_FRAMES_PER_INTERVAL -
Constructor Summary
ConstructorsConstructorDescriptionAnimator()Creates a new, empty Animator.Animator(GLAutoDrawable drawable) Creates a new Animator for a particular drawable.Animator(ThreadGroup tg) Creates a new Animator w/ an associated ThreadGroup.Animator(ThreadGroup tg, GLAutoDrawable drawable) Creates a new Animator w/ an associated ThreadGroup for a particular drawable. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether this animatoris startedandis not paused.final booleanisPaused()Indicates whether this animatoris startedand eithermanually pausedor paused automatically due to noaddedGLAutoDrawables.final booleanpause()Pauses this animator.final booleanresume()Resumes animation if paused.final voidsetRunAsFastAsPossible(boolean runFast) Sets a flag in this Animator indicating that it is to run as fast as possible.final voidSet aThreadGroupfor theanimation thread.final booleanstart()Starts this animator, if not running.final booleanstop()Stops this animator.Methods inherited from class com.jogamp.opengl.util.AnimatorBase
add, getExclusiveContextThread, getFPSStartTime, getLastFPS, getLastFPSPeriod, getLastFPSUpdateTime, getModeBits, getThread, getTotalFPS, getTotalFPSDuration, getTotalFPSFrames, getUncaughtExceptionHandler, getUpdateFPSFrames, isExclusiveContextEnabled, isStarted, remove, resetFPSCounter, setExclusiveContext, setExclusiveContext, setIgnoreExceptions, setModeBits, setPrintExceptions, setUncaughtExceptionHandler, setUpdateFPSFrames, toString
-
Constructor Details
-
Animator
public Animator()Creates a new, empty Animator. -
Animator
Creates a new Animator w/ an associated ThreadGroup. -
Animator
Creates a new Animator for a particular drawable. -
Animator
Creates a new Animator w/ an associated ThreadGroup for a particular drawable.
-
-
Method Details
-
setRunAsFastAsPossible
public final void setRunAsFastAsPossible(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. -
isAnimating
public final boolean isAnimating()Description copied from interface:GLAnimatorControlIndicates whether this animatoris startedandis not paused. -
isPaused
public final boolean isPaused()Description copied from interface:GLAnimatorControlIndicates whether this animatoris startedand eithermanually pausedor paused automatically due to noaddedGLAutoDrawables. -
setThreadGroup
Set aThreadGroupfor theanimation thread.- Parameters:
tg- theThreadGroup- Throws:
GLException- if the animator has already been started
-
start
public final boolean start()Description copied from interface:GLAnimatorControlStarts 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 drawableswill be paused automatically.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:
-
stop
public final boolean stop()Description copied from interface:GLAnimatorControlStops 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:
- true is stopped due to this call, otherwise false, ie not started or unable to stop.
- See Also:
-
pause
public final boolean pause()Description copied from interface:GLAnimatorControlPauses 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 not started, already paused or failed to pause, otherwise true
- See Also:
-
resume
public final boolean resume()Description copied from interface:GLAnimatorControlResumes 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 not started, not paused or unable to resume, otherwise true
- See Also:
-