APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.javafx.css

public final Class TransitionTimer

extends AnimationTimer
Class Inheritance
Imports
com.sun.javafx.animation.InterpolatorHelper, com.sun.javafx.scene.NodeHelper, com.sun.javafx.util.Utils, javafx.animation.AnimationTimer, .Interpolator, javafx.beans.property.Property, javafx.css.StyleableProperty, .TransitionEvent, javafx.event.EventType, javafx.scene.Node, javafx.util.Duration

TransitionTimer is the base class for timers that compute intermediate values for implicit transitions of a StyleableProperty.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
TransitionTimer.CancellationToken

A token that can be used to cancel a running timer.

Field Summary

Modifier and TypeField and Description
private long
private long
private long
private long
private final Interpolator
private final TransitionMediator
private double
private boolean
private long
private final Node
private final String

Constructor Summary

AccessConstructor and Description
private
TransitionTimer(TransitionMediator mediator, TransitionDefinition definition, String targetPropertyName, long nanoNow)

Method Summary

Modifier and TypeMethod and Description
private void
adjustReversingTimings(TransitionTimer
the timer of the running transition
existingTimer
)

If a running transition is interrupted by a new transition, we adjust the start time and end time of the new transition with the reversing shortening factor of the old transition.

public void
complete()

Skips the rest of a running transition and updates the property to the target value.

private void
fireTransitionEvent(EventType<TransitionEvent>
the event type
eventType
)

Fires a TransitionEvent of the specified type.

public TransitionMediator

Returns:

the TransitionMediator
getMediator
()

Returns the TransitionMediator associated with this timer.

private double

Returns:

the input progress, ranging from 0 to 1
getProgress
()

Gets the progress of this timer along the input progress axis.

public void
handle(long
the timestamp of the current frame, in nanoseconds
now
)

Implements abstract javafx.animation.AnimationTimer.handle.

Called once per frame to update the TransitionTimer.

private void
interrupt()

Stops this timer without invoking TransitionMediator#onStop().

private static long

Returns:

the duration in nanoseconds
millisToNanos
(double
the duration in fractional milliseconds
millis
)

Converts the specified duration in fractional milliseconds to nanoseconds.

private static double

Returns:

the duration in fractional milliseconds
nanosToMillis
(long
the duration in nanoseconds
nanos
)

Converts the specified duration in nanoseconds to fractional milliseconds.

public static TransitionTimer.CancellationToken

Returns:

a CancellationToken if the timer was started, null otherwise
run
(TransitionMediator
the TransitionMediator for the targeted property
mediator
,
TransitionDefinition
the TransitionDefinition used to initialize the timer
definition
,
String
the name of the CSS property targeted by the transition
targetPropertyName
,
long
the current time in nanoseconds
nanoNow
)

Starts the specified transition timer with the specified transition definition.

public void
start()

Overrides javafx.animation.AnimationTimer.start.

Starts this timer, and adds it to the list of running transitions.

public void
stop()

Overrides javafx.animation.AnimationTimer.stop.

Stops this timer without updating the property to the target value.

private void
stopTimer(EventType<TransitionEvent>
the event type that is fired after the timer is stopped
eventType
)

Stops the running timer and fires the specified event.

private void
update(double
the input progress value
progress
)

Updates the transition mediator by mapping the specified input progress to an output progress value using the timer's interpolator, and then calling TransitionMediator#onUpdate(double)} with the output progress value.

Field Detail

currentTimeback to summary
private long currentTime
delayback to summary
private long delay
durationback to summary
private long duration
endTimeback to summary
private long endTime
interpolatorback to summary
private final Interpolator interpolator
mediatorback to summary
private final TransitionMediator mediator
reversingShorteningFactorback to summary
private double reversingShorteningFactor
startedback to summary
private boolean started
startTimeback to summary
private long startTime
targetNodeback to summary
private final Node targetNode
targetPropertyNameback to summary
private final String targetPropertyName

Constructor Detail

TransitionTimerback to summary
private TransitionTimer(TransitionMediator mediator, TransitionDefinition definition, String targetPropertyName, long nanoNow)

Method Detail

adjustReversingTimingsback to summary
private void adjustReversingTimings(TransitionTimer existingTimer)

If a running transition is interrupted by a new transition, we adjust the start time and end time of the new transition with the reversing shortening factor of the old transition. Note that the reversing shortening factor is computed in output progress space (value), not in input progress space (time).

This algorithm fixes transition asymmetries that can happen when a transition is interrupted by a reverse transition. Consider a linear transition that animates a value over 4s, but is interrupted after 1s. When the transition is interrupted, the value has progressed one quarter of the value space in one quarter of the duration. However, the reverse transition now takes the entire duration (4s) to progress just one quarter of the original value space, which means that the transition speed is much slower than what would be expected.

Parameters
existingTimer:TransitionTimer

the timer of the running transition

See Also
Faster reversing of interrupted transitions
completeback to summary
public void complete()

Skips the rest of a running transition and updates the property to the target value. This happens when the targeted node is removed from the scene graph or becomes invisible.

fireTransitionEventback to summary
private void fireTransitionEvent(EventType<TransitionEvent> eventType)

Fires a TransitionEvent of the specified type. The elapsed time is computed according to the CSS Transitions specification.

Parameters
eventType:EventType<TransitionEvent>

the event type

getMediatorback to summary
public TransitionMediator getMediator()

Returns the TransitionMediator associated with this timer.

Returns:TransitionMediator

the TransitionMediator

getProgressback to summary
private double getProgress()

Gets the progress of this timer along the input progress axis.

Returns:double

the input progress, ranging from 0 to 1

handleback to summary
public void handle(long now)

Implements abstract javafx.animation.AnimationTimer.handle.

Called once per frame to update the TransitionTimer.

This method fires TransitionEvent#START when the timer enters its active interval, and TransitionEvent#END event when the timer has reached the end of its active interval.

Parameters
now:long

the timestamp of the current frame, in nanoseconds

Annotations
@Override
interruptback to summary
private void interrupt()

Stops this timer without invoking TransitionMediator#onStop(). This form of completion only happens when a timer is interrupted by a reversing timer.

millisToNanosback to summary
private static long millisToNanos(double millis)

Converts the specified duration in fractional milliseconds to nanoseconds.

Parameters
millis:double

the duration in fractional milliseconds

Returns:long

the duration in nanoseconds

nanosToMillisback to summary
private static double nanosToMillis(long nanos)

Converts the specified duration in nanoseconds to fractional milliseconds.

Parameters
nanos:long

the duration in nanoseconds

Returns:double

the duration in fractional milliseconds

runback to summary
public static TransitionTimer.CancellationToken run(TransitionMediator mediator, TransitionDefinition definition, String targetPropertyName, long nanoNow)

Starts the specified transition timer with the specified transition definition. If the combined duration of the transition is zero or if the targeted node is not showing, no transition timer is started, no events are dispatched, and this method returns null.

Parameters
mediator:TransitionMediator

the TransitionMediator for the targeted property

definition:TransitionDefinition

the TransitionDefinition used to initialize the timer

targetPropertyName:String

the name of the CSS property targeted by the transition

nanoNow:long

the current time in nanoseconds

Returns:TransitionTimer.CancellationToken

a CancellationToken if the timer was started, null otherwise

startback to summary
public void start()

Overrides javafx.animation.AnimationTimer.start.

Starts this timer, and adds it to the list of running transitions.

Annotations
@Override
stopback to summary
public void stop()

Overrides javafx.animation.AnimationTimer.stop.

Stops this timer without updating the property to the target value. This happens when the value of the styleable property is changed by the user, or when a running timer is cancelled by a transition with zero duration.

Annotations
@Override
stopTimerback to summary
private void stopTimer(EventType<TransitionEvent> eventType)

Stops the running timer and fires the specified event.

Parameters
eventType:EventType<TransitionEvent>

the event type that is fired after the timer is stopped

updateback to summary
private void update(double progress)

Updates the transition mediator by mapping the specified input progress to an output progress value using the timer's interpolator, and then calling TransitionMediator#onUpdate(double)} with the output progress value.

Parameters
progress:double

the input progress value

com.sun.javafx.css back to summary

public Interface TransitionTimer.CancellationToken


A token that can be used to cancel a running timer.

Method Summary

Modifier and TypeMethod and Description
public void

Method Detail

cancelback to summary
public void cancel()