aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/util/Animator.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/util/Animator.java')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/util/Animator.java47
1 files changed, 30 insertions, 17 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/util/Animator.java b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
index 80d980492..27b9427eb 100644
--- a/src/jogl/classes/com/jogamp/opengl/util/Animator.java
+++ b/src/jogl/classes/com/jogamp/opengl/util/Animator.java
@@ -1,22 +1,22 @@
/*
* Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
* Copyright (c) 2010 JogAmp Community. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* - Redistribution of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* - Redistribution in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* Neither the name of Sun Microsystems, Inc. or the names of
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* This software is provided "AS IS," without a warranty of any kind. ALL
* EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
* INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
@@ -29,11 +29,11 @@
* DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
* ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
* SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
- *
+ *
* You acknowledge that this software is not designed or intended for use
* in the design, construction, operation or maintenance of any nuclear
* facility.
- *
+ *
* Sun gratefully acknowledges that this software was originally authored
* and developed by Kenneth Bradley Russell and Christopher John Kline.
*/
@@ -57,7 +57,7 @@ import javax.media.opengl.GLException;
* Call {@link #stop() } to terminate the animation and it's execution thread.
* </p>
*/
-public class Animator extends AnimatorBase {
+public class Animator extends AnimatorBase {
protected ThreadGroup threadGroup;
private Runnable runnable;
private boolean runAsFastAsPossible;
@@ -75,7 +75,7 @@ public class Animator extends AnimatorBase {
}
}
- /**
+ /**
* Creates a new Animator w/ an associated ThreadGroup.
*/
public Animator(ThreadGroup tg) {
@@ -86,7 +86,7 @@ public class Animator extends AnimatorBase {
}
}
- /**
+ /**
* Creates a new Animator for a particular drawable.
*/
public Animator(GLAutoDrawable drawable) {
@@ -97,7 +97,7 @@ public class Animator extends AnimatorBase {
}
}
- /**
+ /**
* Creates a new Animator w/ an associated ThreadGroup for a particular drawable.
*/
public Animator(ThreadGroup tg, GLAutoDrawable drawable) {
@@ -109,6 +109,7 @@ public class Animator extends AnimatorBase {
}
}
+ @Override
protected String getBaseName(String prefix) {
return prefix + "Animator" ;
}
@@ -127,7 +128,7 @@ public class Animator extends AnimatorBase {
stateSync.unlock();
}
}
-
+
private final void setIsAnimatingSynced(boolean v) {
stateSync.lock();
try {
@@ -138,10 +139,12 @@ public class Animator extends AnimatorBase {
}
class MainLoop implements Runnable {
+ @Override
public String toString() {
return "[started "+isStartedImpl()+", animating "+isAnimatingImpl()+", paused "+isPausedImpl()+", drawable "+drawables.size()+", drawablesEmpty "+drawablesEmpty+"]";
}
+ @Override
public void run() {
try {
if(DEBUG) {
@@ -185,7 +188,7 @@ public class Animator extends AnimatorBase {
}
if (!stopIssued && !isAnimating) {
// Wakes up 'waitForStartedCondition' sync
- // - and -
+ // - and -
// Resume from pause or drawablesEmpty,
// implies !pauseIssued and !drawablesEmpty
setIsAnimatingSynced(true); // barrier
@@ -228,6 +231,7 @@ public class Animator extends AnimatorBase {
private final boolean isAnimatingImpl() {
return animThread != null && isAnimating ;
}
+ @Override
public final boolean isAnimating() {
stateSync.lock();
try {
@@ -240,6 +244,7 @@ public class Animator extends AnimatorBase {
private final boolean isPausedImpl() {
return animThread != null && pauseIssued ;
}
+ @Override
public final boolean isPaused() {
stateSync.lock();
try {
@@ -251,7 +256,7 @@ public class Animator extends AnimatorBase {
/**
* Set a {@link ThreadGroup} for the {@link #getThread() animation thread}.
- *
+ *
* @param tg the {@link ThreadGroup}
* @throws GLException if the animator has already been started
*/
@@ -261,7 +266,8 @@ public class Animator extends AnimatorBase {
}
threadGroup = tg;
}
-
+
+ @Override
public synchronized boolean start() {
if ( isStartedImpl() ) {
return false;
@@ -277,7 +283,7 @@ public class Animator extends AnimatorBase {
} else {
thread = new Thread(threadGroup, runnable, threadName);
}
- thread.setDaemon(false); // force to be non daemon, regardless of parent thread
+ thread.setDaemon(false); // force to be non daemon, regardless of parent thread
if(DEBUG) {
final Thread ct = Thread.currentThread();
System.err.println("Animator "+ct.getName()+"[daemon "+ct.isDaemon()+"]: starting "+thread.getName()+"[daemon "+thread.isDaemon()+"]");
@@ -286,10 +292,12 @@ public class Animator extends AnimatorBase {
return finishLifecycleAction(waitForStartedCondition, 0);
}
private final Condition waitForStartedCondition = new Condition() {
+ @Override
public boolean eval() {
return !isStartedImpl() || (!drawablesEmpty && !isAnimating) ;
- } };
+ } };
+ @Override
public synchronized boolean stop() {
if ( !isStartedImpl() ) {
return false;
@@ -298,10 +306,12 @@ public class Animator extends AnimatorBase {
return finishLifecycleAction(waitForStoppedCondition, 0);
}
private final Condition waitForStoppedCondition = new Condition() {
+ @Override
public boolean eval() {
return isStartedImpl();
} };
+ @Override
public synchronized boolean pause() {
if ( !isStartedImpl() || pauseIssued ) {
return false;
@@ -310,11 +320,13 @@ public class Animator extends AnimatorBase {
return finishLifecycleAction(waitForPausedCondition, 0);
}
private final Condition waitForPausedCondition = new Condition() {
+ @Override
public boolean eval() {
// end waiting if stopped as well
return isStartedImpl() && isAnimating;
} };
+ @Override
public synchronized boolean resume() {
if ( !isStartedImpl() || !pauseIssued ) {
return false;
@@ -323,6 +335,7 @@ public class Animator extends AnimatorBase {
return finishLifecycleAction(waitForResumeCondition, 0);
}
private final Condition waitForResumeCondition = new Condition() {
+ @Override
public boolean eval() {
// end waiting if stopped as well
return isStartedImpl() && ( !drawablesEmpty && !isAnimating || drawablesEmpty && !pauseIssued ) ;