APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javafx.animation

public abstract Class AnimationTimer

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.javafx.css.TransitionTimer
Imports
com.sun.javafx.tk.Toolkit, com.sun.javafx.util.Utils, com.sun.scenario.animation.AbstractPrimaryTimer, com.sun.scenario.animation.shared.TimerReceiver

The class AnimationTimer allows to create a timer, that is called in each frame while it is active.

An extending class has to override the method handle(long) which will be called in every frame.

The methods AnimationTimer#start() and stop() allow to start and stop the timer.

The animation timer runs on the JavaFX Application Thread.

Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private boolean
private final AbstractPrimaryTimer
private final AnimationTimer.AnimationTimerReceiver

Constructor Summary

AccessConstructor and Description
public
AnimationTimer()

Creates a new timer.

pack-priv

Method Summary

Modifier and TypeMethod and Description
public abstract void
handle(long
The timestamp of the current frame given in nanoseconds. This value will be the same for all AnimationTimers called during one frame.
now
)

This method needs to be overridden by extending classes.

public void
start()

Starts the AnimationTimer.

private void
startImpl()

This method must be run on the JavaFX Application Thread.

public void
stop()

Stops the AnimationTimer.

private void
stopImpl()

This method must be run on the JavaFX Application Thread.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activeback to summary
private boolean active
timerback to summary
private final AbstractPrimaryTimer timer
timerReceiverback to summary
private final AnimationTimer.AnimationTimerReceiver timerReceiver

Constructor Detail

AnimationTimerback to summary
public AnimationTimer()

Creates a new timer.

AnimationTimerback to summary
pack-priv AnimationTimer(AbstractPrimaryTimer timer)

Method Detail

handleback to summary
public abstract void handle(long now)

This method needs to be overridden by extending classes. It is going to be called in every frame while the AnimationTimer is active.

Parameters
now:long

The timestamp of the current frame given in nanoseconds. This value will be the same for all AnimationTimers called during one frame.

startback to summary
public void start()

Starts the AnimationTimer. Once it is started, the handle(long) method of this AnimationTimer will be called in every frame.

The AnimationTimer can be stopped by calling stop().

Note

if this method is not called on the JavaFX Application Thread, it is delegated to it automatically. In this case, the call is asynchronous and may not happen immediately.

startImplback to summary
private void startImpl()

This method must be run on the JavaFX Application Thread.

See Also
start()
stopback to summary
public void stop()

Stops the AnimationTimer. It can be activated again by calling start().

Note

if this method is not called on the JavaFX Application Thread, it is delegated to it automatically. In this case, the call is asynchronous and may not happen immediately.

stopImplback to summary
private void stopImpl()

This method must be run on the JavaFX Application Thread.

See Also
stop()
javafx.animation back to summary

private Class AnimationTimer.AnimationTimerReceiver

extends Object
implements TimerReceiver
Class Inheritance
All Implemented Interfaces
com.sun.scenario.animation.shared.TimerReceiver

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
handle(final long now)

Implements com.sun.scenario.animation.shared.TimerReceiver.handle.

Callback triggered to send a message to the TimerReceiver

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AnimationTimerReceiverback to summary
private AnimationTimerReceiver()

Method Detail

handleback to summary
public void handle(final long now)

Implements com.sun.scenario.animation.shared.TimerReceiver.handle.

Doc from com.sun.scenario.animation.shared.TimerReceiver.handle.

Callback triggered to send a message to the TimerReceiver

Annotations
@Override