public final class FadeTransition extends Transition
Transition
creates a fade effect animation that spans its
duration
. This is done by updating the opacity
variable of
the node
at regular interval.
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();
...
Transition
,
Animation
Type | Property and Description |
---|---|
DoubleProperty |
byValue
Specifies the incremented stop opacity value, from the start, of this
FadeTransition . |
<any> |
duration
The duration of this
FadeTransition . |
DoubleProperty |
fromValue
Specifies the start opacity value for this
FadeTransition . |
<any> |
node
The target node of this
Transition . |
DoubleProperty |
toValue
Specifies the stop opacity value for this
FadeTransition . |
interpolatorProperty
autoReverseProperty, currentRateProperty, currentTimeProperty, cycleCountProperty, cycleDurationProperty, delayProperty, onFinishedProperty, rateProperty, statusProperty, totalDurationProperty
Animation.Status
Modifier and Type | Field and Description |
---|---|
private DoubleProperty |
byValue
Specifies the incremented stop opacity value, from the start, of this
FadeTransition . |
private Node |
cachedNode |
private static double |
DEFAULT_BY_VALUE |
private static Duration |
DEFAULT_DURATION |
private static double |
DEFAULT_FROM_VALUE |
private static Node |
DEFAULT_NODE |
private static double |
DEFAULT_TO_VALUE |
private double |
delta |
private <any> |
duration
The duration of this
FadeTransition . |
private static double |
EPSILON |
private DoubleProperty |
fromValue
Specifies the start opacity value for this
FadeTransition . |
private <any> |
node
The target node of this
Transition . |
private double |
start |
private DoubleProperty |
toValue
Specifies the stop opacity value for this
FadeTransition . |
clipEnvelope, INDEFINITE, parent, pulseReceiver
Constructor and Description |
---|
FadeTransition()
The constructor of
FadeTransition |
FadeTransition(Duration duration)
The constructor of
FadeTransition |
FadeTransition(Duration duration,
Node node)
The constructor of
FadeTransition |
Modifier and Type | Method and Description |
---|---|
DoubleProperty |
byValueProperty()
Specifies the incremented stop opacity value, from the start, of this
FadeTransition . |
<any> |
durationProperty()
The duration of this
FadeTransition . |
DoubleProperty |
fromValueProperty()
Specifies the start opacity value for this
FadeTransition . |
double |
getByValue()
Gets the value of the property byValue.
|
Duration |
getDuration()
Gets the value of the property duration.
|
double |
getFromValue()
Gets the value of the property fromValue.
|
Node |
getNode()
Gets the value of the property node.
|
private Node |
getTargetNode() |
double |
getToValue()
Gets the value of the property toValue.
|
protected void |
interpolate(double frac)
The method
interpolate() has to be provided by implementations of
Transition . |
<any> |
nodeProperty()
The target node of this
Transition . |
void |
setByValue(double value)
Sets the value of the property byValue.
|
void |
setDuration(Duration value)
Sets the value of the property duration.
|
void |
setFromValue(double value)
Sets the value of the property fromValue.
|
void |
setNode(Node value)
Sets the value of the property node.
|
void |
setToValue(double value)
Sets the value of the property toValue.
|
(package private) boolean |
startable(boolean forceSync) |
(package private) void |
sync(boolean forceSync) |
DoubleProperty |
toValueProperty()
Specifies the stop opacity value for this
FadeTransition . |
doJumpTo, doPlayTo, getCachedInterpolator, getInterpolator, getParentTargetNode, interpolatorProperty, setInterpolator
autoReverseProperty, currentRateProperty, currentTimeProperty, cycleCountProperty, cycleDurationProperty, delayProperty, doPause, doResume, doStart, doStop, doTimePulse, finished, getCuePoints, getCurrentRate, getCurrentTime, getCycleCount, getCycleDuration, getDelay, getOnFinished, getRate, getStatus, getTargetFramerate, getTotalDuration, isAutoReverse, jumpTo, onFinishedProperty, pause, pauseReceiver, play, playFrom, playFrom, playFromStart, rateProperty, resumeReceiver, setAutoReverse, setCurrentRate, setCurrentTicks, setCycleCount, setCycleDuration, setDelay, setOnFinished, setRate, setStatus, startReceiver, statusProperty, stop, totalDurationProperty
public final <any> nodeProperty
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.
getNode()
,
setNode(Node)
public final <any> durationProperty
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
.
getDuration()
,
setDuration(Duration)
public final DoubleProperty fromValueProperty
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.
getFromValue()
,
setFromValue(double)
public final DoubleProperty toValueProperty
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.
getToValue()
,
setToValue(double)
public final DoubleProperty byValueProperty
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.
getByValue()
,
setByValue(double)
private static final double EPSILON
private double start
private double delta
private <any> node
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.
private static final Node DEFAULT_NODE
private Node cachedNode
private <any> duration
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
.
private static final Duration DEFAULT_DURATION
private DoubleProperty fromValue
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.
private static final double DEFAULT_FROM_VALUE
private DoubleProperty toValue
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.
private static final double DEFAULT_TO_VALUE
private DoubleProperty byValue
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.
private static final double DEFAULT_BY_VALUE
public FadeTransition(Duration duration, Node node)
FadeTransition
duration
- The duration of the FadeTransition
node
- The node
which opacity will be animatedpublic FadeTransition(Duration duration)
FadeTransition
duration
- The duration of the FadeTransition
public FadeTransition()
FadeTransition
public final void setNode(Node value)
public final Node getNode()
public final <any> nodeProperty()
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.
getNode()
,
setNode(Node)
public final void setDuration(Duration value)
public final Duration getDuration()
public final <any> durationProperty()
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
.
getDuration()
,
setDuration(Duration)
public final void setFromValue(double value)
public final double getFromValue()
public final DoubleProperty fromValueProperty()
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.
getFromValue()
,
setFromValue(double)
public final void setToValue(double value)
public final double getToValue()
public final DoubleProperty toValueProperty()
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.
getToValue()
,
setToValue(double)
public final void setByValue(double value)
public final double getByValue()
public final DoubleProperty byValueProperty()
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.
getByValue()
,
setByValue(double)
protected void interpolate(double frac)
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.interpolate
in class Transition
frac
- The relative positionprivate Node getTargetNode()
boolean startable(boolean forceSync)
startable
in class Transition
void sync(boolean forceSync)
sync
in class Transition