Top Description Fields Constructors Methods
javafx.animation

public final Class FadeTransition

extends Transition
Class Inheritance
Imports
javafx.beans.property.DoubleProperty, .ObjectProperty, .ObjectPropertyBase, .SimpleDoubleProperty, .SimpleObjectProperty, javafx.scene.Node, javafx.util.Duration

This Transition creates a fade effect animation that spans its duration. This is done by updating the opacity variable of the node at regular intervals.

It starts from the fromValue if provided else uses the node's opacity value.

It stops at the toValue value if provided else it will use start value plus byValue.

The toValue takes precedence if both toValue and byValue are specified.

Code Segment Example:


import javafx.scene.shape.*;
import javafx.animation.*;

...

    Rectangle rect = new Rectangle (100, 40, 100, 100);
    rect.setArcHeight(50);
    rect.setArcWidth(50);
    rect.setFill(Color.VIOLET);

    FadeTransition ft = new FadeTransition(Duration.millis(3000), rect);
    ft.setFromValue(1.0);
    ft.setToValue(0.3);
    ft.setCycleCount(4);
    ft.setAutoReverse(true);

    ft.play();

...


Since
JavaFX 2.0
See Also
Transition, Animation

Field Summary

Modifier and TypeField and Description
private DoubleProperty
byValue

Specifies the incremented stop opacity value, from the start, of this FadeTransition.

private Node
private static final double
private static final Duration
private static final double
private static final Node
private static final double
private double
private ObjectProperty<Duration>
duration

The duration of this FadeTransition.

private static final double
private DoubleProperty
fromValue

Specifies the start opacity value for this FadeTransition.

private ObjectProperty<Node>
node

The target node of this Transition.

private double
private DoubleProperty
toValue

Specifies the stop opacity value for this FadeTransition.

Constructor Summary

AccessConstructor and Description
public
FadeTransition(Duration
The duration of the FadeTransition
duration
,
Node
The node which opacity will be animated
node
)

The constructor of FadeTransition

public
FadeTransition(Duration
The duration of the FadeTransition
duration
)

The constructor of FadeTransition

public
FadeTransition()

The constructor of FadeTransition

Method Summary

Modifier and TypeMethod and Description
public final DoubleProperty
public final ObjectProperty<Duration>
public final DoubleProperty
public final double
public final Duration
public final double
public final Node
private Node
public final double
protected void
interpolate(double frac)

Implements abstract javafx.animation.Transition.interpolate.

The method interpolate() has to be provided by implementations of Transition.

public final ObjectProperty<Node>
public final void
setByValue(double value)

public final void
public final void
setFromValue(double value)

public final void
setNode(Node value)

public final void
setToValue(double value)

pack-priv boolean
startable(boolean forceSync)

Overrides javafx.animation.Transition.startable.

pack-priv void
sync(boolean forceSync)

Overrides javafx.animation.Transition.sync.

public final DoubleProperty
Inherited from javafx.animation.Transition:
doJumpTodoPlayTogetCachedInterpolatorgetInterpolatorgetParentTargetNodeinterpolatorPropertysetInterpolator

Field Detail

byValueback to summary
private DoubleProperty byValue

Specifies the incremented stop opacity value, from the start, of this FadeTransition.

It is not possible to change byValue of a running FadeTransition. If the value of byValue is changed for a running FadeTransition, the animation has to be stopped and started again to pick up the new value.

cachedNodeback to summary
private Node cachedNode
DEFAULT_BY_VALUEback to summary
private static final double DEFAULT_BY_VALUE
DEFAULT_DURATIONback to summary
private static final Duration DEFAULT_DURATION
DEFAULT_FROM_VALUEback to summary
private static final double DEFAULT_FROM_VALUE
DEFAULT_NODEback to summary
private static final Node DEFAULT_NODE
DEFAULT_TO_VALUEback to summary
private static final double DEFAULT_TO_VALUE
deltaback to summary
private double delta
durationback to summary
private ObjectProperty<Duration> duration

The duration of this FadeTransition.

It is not possible to change the duration of a running FadeTransition. If the value of duration is changed for a running FadeTransition, the animation has to be stopped and started again to pick up the new value.

Note

While the unit of duration is a millisecond, the granularity depends on the underlying operating system and will in general be larger. For example animations on desktop systems usually run with a maximum of 60fps which gives a granularity of ~17 ms. Setting duration to value lower than Duration#ZERO will result in IllegalArgumentException.

Default Value
400ms
EPSILONback to summary
private static final double EPSILON

Hides javafx.animation.Animation.EPSILON.

fromValueback to summary
private DoubleProperty fromValue

Specifies the start opacity value for this FadeTransition.

It is not possible to change fromValue of a running FadeTransition. If the value of fromValue is changed for a running FadeTransition, the animation has to be stopped and started again to pick up the new value.

Default Value
Double.NaN
nodeback to summary
private ObjectProperty<Node> node

The target node of this Transition.

It is not possible to change the target node of a running FadeTransition. If the value of node is changed for a running FadeTransition, the animation has to be stopped and started again to pick up the new value.

startback to summary
private double start
toValueback to summary
private DoubleProperty toValue

Specifies the stop opacity value for this FadeTransition.

It is not possible to change toValue of a running FadeTransition. If the value of toValue is changed for a running FadeTransition, the animation has to be stopped and started again to pick up the new value.

Default Value
Double.NaN

Constructor Detail

FadeTransitionback to summary
public FadeTransition(Duration duration, Node node)

The constructor of FadeTransition

Parameters
duration:Duration

The duration of the FadeTransition

node:Node

The node which opacity will be animated

FadeTransitionback to summary
public FadeTransition(Duration duration)

The constructor of FadeTransition

Parameters
duration:Duration

The duration of the FadeTransition

FadeTransitionback to summary
public FadeTransition()

The constructor of FadeTransition

Method Detail

byValuePropertyback to summary
public final DoubleProperty byValueProperty()
durationPropertyback to summary
public final ObjectProperty<Duration> durationProperty()
fromValuePropertyback to summary
public final DoubleProperty fromValueProperty()
getByValueback to summary
public final double getByValue()
getDurationback to summary
public final Duration getDuration()
getFromValueback to summary
public final double getFromValue()
getNodeback to summary
public final Node getNode()
getTargetNodeback to summary
private Node getTargetNode()
getToValueback to summary
public final double getToValue()
interpolateback to summary
protected void interpolate(double frac)

Implements abstract javafx.animation.Transition.interpolate.

Doc from javafx.animation.Transition.interpolate.

The method interpolate() has to be provided by implementations of Transition. While a Transition is running, this method is called in every frame. The parameter defines the current position with the animation. At the start, the fraction will be 0.0 and at the end it will be 1.0. How the parameter increases, depends on the interpolator, e.g. if the interpolator is Interpolator#LINEAR, the fraction will increase linear. This method must not be called by the user directly.

Annotations
@Override
nodePropertyback to summary
public final ObjectProperty<Node> nodeProperty()
setByValueback to summary
public final void setByValue(double value)
setDurationback to summary
public final void setDuration(Duration value)
setFromValueback to summary
public final void setFromValue(double value)
setNodeback to summary
public final void setNode(Node value)
setToValueback to summary
public final void setToValue(double value)
startableback to summary
pack-priv boolean startable(boolean forceSync)

Overrides javafx.animation.Transition.startable.

Annotations
@Override
syncback to summary
pack-priv void sync(boolean forceSync)

Overrides javafx.animation.Transition.sync.

Annotations
@Override
toValuePropertyback to summary
public final DoubleProperty toValueProperty()