com.jogamp.opengl.util
Class AnimatorBase

java.lang.Object
  extended by com.jogamp.opengl.util.AnimatorBase
All Implemented Interfaces:
GLAnimatorControl
Direct Known Subclasses:
Animator, FPSAnimator

public abstract class AnimatorBase
extends Object
implements GLAnimatorControl

Base implementation of GLAnimatorControl

The change synchronization is done via synchronized blocks on the AnimatorBase instance.
Status get / set activity is synced with a RecursiveLock, used as a memory barrier.
This is suitable, since all change requests are allowed to be expensive as they are not expected to be called at every frame.


Nested Class Summary
static interface AnimatorBase.AnimatorImpl
           
 
Field Summary
protected  Thread animThread
           
protected  String baseName
           
protected  long curTime
           
protected static boolean DEBUG
           
protected  ArrayList drawables
           
protected  boolean drawablesEmpty
           
protected  boolean ignoreExceptions
           
protected  AnimatorBase.AnimatorImpl impl
           
protected  boolean printExceptions
           
protected  long startTime
           
protected  RecursiveLock stateSync
           
protected  int totalFrames
           
 
Constructor Summary
AnimatorBase()
          Creates a new, empty Animator.
 
Method Summary
 void add(GLAutoDrawable drawable)
           
protected  void display()
          Called every frame to cause redrawing of all of the GLAutoDrawables this Animator manages.
protected abstract  String getBaseName(String prefix)
           
 long getCurrentTime()
           
 long getDuration()
           
 long getStartTime()
           
 Thread getThread()
           
 int getTotalFrames()
           
 void remove(GLAutoDrawable drawable)
          Removes a drawable from the animator's list of rendering drawables.
This method should get called in case a drawable becomes invalid, and will not be recovered.
This allows the animator thread to become idle in case the last drawable has reached it's end of life.
 void resetCounter()
          Reset all performance counter (startTime, currentTime, frame number)
 void setIgnoreExceptions(boolean ignoreExceptions)
          Sets a flag causing this Animator to ignore exceptions produced while redrawing the drawables.
 void setPrintExceptions(boolean printExceptions)
          Sets a flag indicating that when exceptions are being ignored by this Animator (see setIgnoreExceptions(boolean)), to print the exceptions' stack traces for diagnostic information.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.media.opengl.GLAnimatorControl
isAnimating, isPaused, isStarted, pause, resume, start, stop
 

Field Detail

DEBUG

protected static final boolean DEBUG

drawables

protected ArrayList drawables

drawablesEmpty

protected boolean drawablesEmpty

impl

protected AnimatorBase.AnimatorImpl impl

baseName

protected String baseName

animThread

protected Thread animThread

ignoreExceptions

protected boolean ignoreExceptions

printExceptions

protected boolean printExceptions

startTime

protected long startTime

curTime

protected long curTime

totalFrames

protected int totalFrames

stateSync

protected RecursiveLock stateSync
Constructor Detail

AnimatorBase

public AnimatorBase()
Creates a new, empty Animator.

Method Detail

getBaseName

protected abstract String getBaseName(String prefix)

add

public void add(GLAutoDrawable drawable)

remove

public void remove(GLAutoDrawable drawable)
Description copied from interface: GLAnimatorControl
Removes a drawable from the animator's list of rendering drawables.
This method should get called in case a drawable becomes invalid, and will not be recovered.
This allows the animator thread to become idle in case the last drawable has reached it's end of life.

Specified by:
remove in interface GLAnimatorControl
Parameters:
drawable - the to be removed drawable

display

protected void display()
Called every frame to cause redrawing of all of the GLAutoDrawables this Animator manages. Subclasses should call this to get the most optimized painting behavior for the set of components this Animator manages, in particular when multiple lightweight widgets are continually being redrawn.


getCurrentTime

public long getCurrentTime()
Specified by:
getCurrentTime in interface GLAnimatorControl
Returns:
Time of the last display call in milliseconds. This value is reset if started or resumed.
See Also:
GLAnimatorControl.start(), GLAnimatorControl.resume()

getDuration

public long getDuration()
Specified by:
getDuration in interface GLAnimatorControl
Returns:
Duration getCurrentTime() - getStartTime().
See Also:
GLAnimatorControl.getStartTime(), GLAnimatorControl.getCurrentTime()

getStartTime

public long getStartTime()
Specified by:
getStartTime in interface GLAnimatorControl
Returns:
Time of the first display call in milliseconds. This value is reset if started or resumed.
See Also:
GLAnimatorControl.start(), GLAnimatorControl.resume()

getTotalFrames

public int getTotalFrames()
Specified by:
getTotalFrames in interface GLAnimatorControl
Returns:
Number of frame cycles displayed since the first display call, ie getStartTime(). This value is reset if started or resumed.
See Also:
GLAnimatorControl.start(), GLAnimatorControl.resume()

getThread

public final Thread getThread()
Specified by:
getThread in interface GLAnimatorControl
Returns:
The animation thread if running, otherwise null.
See Also:
GLAnimatorControl.start(), GLAnimatorControl.stop()

resetCounter

public void resetCounter()
Description copied from interface: GLAnimatorControl
Reset all performance counter (startTime, currentTime, frame number)

Specified by:
resetCounter in interface GLAnimatorControl

setIgnoreExceptions

public void setIgnoreExceptions(boolean ignoreExceptions)
Sets a flag causing this Animator to ignore exceptions produced while redrawing the drawables. By default this flag is set to false, causing any exception thrown to halt the Animator.


setPrintExceptions

public void setPrintExceptions(boolean printExceptions)
Sets a flag indicating that when exceptions are being ignored by this Animator (see setIgnoreExceptions(boolean)), to print the exceptions' stack traces for diagnostic information. Defaults to false.


toString

public String toString()
Overrides:
toString in class Object


Copyright 2010 JogAmp Community.