Package org.apache.batik.bridge
Class SVGAnimationEngine.AnimationTickRunnable
- java.lang.Object
-
- org.apache.batik.bridge.SVGAnimationEngine.AnimationTickRunnable
-
- All Implemented Interfaces:
java.lang.Runnable,RunnableQueue.IdleRunnable
- Direct Known Subclasses:
SVGAnimationEngine.DebugAnimationTickRunnable
- Enclosing class:
- SVGAnimationEngine
protected static class SVGAnimationEngine.AnimationTickRunnable extends java.lang.Object implements RunnableQueue.IdleRunnable
Idle runnable to tick the animation.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.ref.WeakReferenceengRefA weak reference to the SVGAnimationEngine this AnimationTickRunnable is for.protected intexceptionCountThe number of consecutive exceptions that have been thrown.protected static intMAX_EXCEPTION_COUNTThe maximum number of consecutive exceptions to allow before stopping the report of them.private static intNUM_TIMESThe number of past tick times to keep, for computing the average time per tick.protected RunnableQueueqThe RunnableQueue in which this is theRunnableQueue.IdleRunnable.protected longsumTimeThe sum of the times intimes.protected java.util.CalendartimeCalendar instance used for passing current time values to the animation timing system.protected inttimeIndexThe current index intotimes.protected long[]timesThe past tick times.protected longwaitTimeThe number of milliseconds to wait until the next animation tick.
-
Constructor Summary
Constructors Constructor Description AnimationTickRunnable(RunnableQueue q, SVGAnimationEngine eng)Creates a new AnimationTickRunnable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SVGAnimationEnginegetAnimationEngine()Returns the SVGAnimationEngine this AnimationTickRunnable is for.longgetWaitTime()Returns the system time that can be safely waited until before thisRunnableis run again.voidresume()Forces an animation update, if theRunnableQueueis currently waiting.voidrun()Performs one tick of the animation.
-
-
-
Field Detail
-
time
protected java.util.Calendar time
Calendar instance used for passing current time values to the animation timing system.
-
waitTime
protected long waitTime
The number of milliseconds to wait until the next animation tick. This is returned bygetWaitTime().
-
q
protected RunnableQueue q
The RunnableQueue in which this is theRunnableQueue.IdleRunnable.
-
NUM_TIMES
private static final int NUM_TIMES
The number of past tick times to keep, for computing the average time per tick.- See Also:
- Constant Field Values
-
times
protected long[] times
The past tick times.
-
sumTime
protected long sumTime
The sum of the times intimes.
-
timeIndex
protected int timeIndex
The current index intotimes.
-
engRef
protected java.lang.ref.WeakReference engRef
A weak reference to the SVGAnimationEngine this AnimationTickRunnable is for. We make this a WeakReference so that a ticking animation engine does not prevent from being GCed.
-
MAX_EXCEPTION_COUNT
protected static final int MAX_EXCEPTION_COUNT
The maximum number of consecutive exceptions to allow before stopping the report of them.- See Also:
- Constant Field Values
-
exceptionCount
protected int exceptionCount
The number of consecutive exceptions that have been thrown. This is used to detect when exceptions are occurring every tick, and to stop reporting them when this happens.
-
-
Constructor Detail
-
AnimationTickRunnable
public AnimationTickRunnable(RunnableQueue q, SVGAnimationEngine eng)
Creates a new AnimationTickRunnable.
-
-
Method Detail
-
resume
public void resume()
Forces an animation update, if theRunnableQueueis currently waiting.
-
getWaitTime
public long getWaitTime()
Returns the system time that can be safely waited until before thisRunnableis run again.- Specified by:
getWaitTimein interfaceRunnableQueue.IdleRunnable- Returns:
- time to wait until,
0if no waiting can be done, orLong.MAX_VALUEif theRunnableshould not be run again at this time
-
run
public void run()
Performs one tick of the animation.- Specified by:
runin interfacejava.lang.Runnable
-
getAnimationEngine
protected SVGAnimationEngine getAnimationEngine()
Returns the SVGAnimationEngine this AnimationTickRunnable is for.
-
-