com.sun.opengl.util
Class Animator

java.lang.Object
  extended by com.sun.opengl.util.Animator
Direct Known Subclasses:
FPSAnimator

public class Animator
extends Object

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.


Field Summary
protected  boolean ignoreExceptions
           
protected  boolean printExceptions
           
protected  boolean shouldStop
           
protected  Thread thread
           
 
Constructor Summary
Animator()
          Creates a new, empty Animator.
Animator(GLAutoDrawable drawable)
          Creates a new Animator for a particular drawable.
 
Method Summary
 void add(GLAutoDrawable drawable)
          Adds a drawable to the list managed by this Animator.
protected  void display()
          Called every frame to cause redrawing of all of the GLAutoDrawables this Animator manages.
 Iterator drawableIterator()
          Returns an iterator over the drawables managed by this Animator.
 boolean isAnimating()
          Indicates whether this animator is currently running.
 void remove(GLAutoDrawable drawable)
          Removes a drawable from the list managed by this Animator.
 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.
 void setRunAsFastAsPossible(boolean runFast)
          Sets a flag in this Animator indicating that it is to run as fast as possible.
 void start()
          Starts this animator.
 void stop()
          Stops this animator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

thread

protected Thread thread

shouldStop

protected volatile boolean shouldStop

ignoreExceptions

protected boolean ignoreExceptions

printExceptions

protected boolean printExceptions
Constructor Detail

Animator

public Animator()
Creates a new, empty Animator.


Animator

public Animator(GLAutoDrawable drawable)
Creates a new Animator for a particular drawable.

Method Detail

add

public void add(GLAutoDrawable drawable)
Adds a drawable to the list managed by this Animator.


remove

public void remove(GLAutoDrawable drawable)
Removes a drawable from the list managed by this Animator.


drawableIterator

public Iterator drawableIterator()
Returns an iterator over the drawables managed by this Animator.


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.


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.


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.


start

public void start()
Starts this animator.


isAnimating

public boolean isAnimating()
Indicates whether this animator is currently running. This should only be used as a heuristic to applications because in some circumstances the Animator may be in the process of shutting down and this method will still return true.


stop

public void 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.



Copyright 2005 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.