public final class StrokeTransition extends Transition
Transition
creates an animation, that changes the stroke color
of a shape over a duration
. This is done by updating the
stroke
variable of the shape
at regular intervals.
It starts from the fromValue
if provided else uses the shape
's stroke
value. (The stroke
value has to be a
javafx.scene.paint.Color
in this case).
It stops at the toValue
value.
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(null);
StrokeTransition st = new StrokeTransition(Duration.millis(3000), rect, Color.RED, Color.BLUE);
st.setCycleCount(4);
st.setAutoReverse(true);
st.play();
...
Transition
,
Animation
Type | Property and Description |
---|---|
<any> |
duration
The duration of this
StrokeTransition . |
<any> |
fromValue
Specifies the start color value for this
StrokeTransition . |
<any> |
shape
The target shape of this
StrokeTransition . |
<any> |
toValue
Specifies the stop color value for this
StrokeTransition . |
interpolatorProperty
autoReverseProperty, currentRateProperty, currentTimeProperty, cycleCountProperty, cycleDurationProperty, delayProperty, onFinishedProperty, rateProperty, statusProperty, totalDurationProperty
Animation.Status
Modifier and Type | Field and Description |
---|---|
private Shape |
cachedShape |
private static Duration |
DEFAULT_DURATION |
private static Color |
DEFAULT_FROM_VALUE |
private static Shape |
DEFAULT_SHAPE |
private static Color |
DEFAULT_TO_VALUE |
private <any> |
duration
The duration of this
StrokeTransition . |
private Color |
end |
private <any> |
fromValue
Specifies the start color value for this
StrokeTransition . |
private <any> |
shape
The target shape of this
StrokeTransition . |
private Color |
start |
private <any> |
toValue
Specifies the stop color value for this
StrokeTransition . |
clipEnvelope, INDEFINITE, parent, pulseReceiver
Constructor and Description |
---|
StrokeTransition()
The constructor of
StrokeTransition |
StrokeTransition(Duration duration)
The constructor of
StrokeTransition |
StrokeTransition(Duration duration,
Color fromValue,
Color toValue)
The constructor of
StrokeTransition |
StrokeTransition(Duration duration,
Shape shape)
The constructor of
StrokeTransition |
StrokeTransition(Duration duration,
Shape shape,
Color fromValue,
Color toValue)
The constructor of
StrokeTransition |
Modifier and Type | Method and Description |
---|---|
<any> |
durationProperty()
The duration of this
StrokeTransition . |
<any> |
fromValueProperty()
Specifies the start color value for this
StrokeTransition . |
Duration |
getDuration()
Gets the value of the property duration.
|
Color |
getFromValue()
Gets the value of the property fromValue.
|
Shape |
getShape()
Gets the value of the property shape.
|
private Shape |
getTargetShape() |
Color |
getToValue()
Gets the value of the property toValue.
|
protected void |
interpolate(double frac)
The method
interpolate() has to be provided by implementations of
Transition . |
void |
setDuration(Duration value)
Sets the value of the property duration.
|
void |
setFromValue(Color value)
Sets the value of the property fromValue.
|
void |
setShape(Shape value)
Sets the value of the property shape.
|
void |
setToValue(Color value)
Sets the value of the property toValue.
|
<any> |
shapeProperty()
The target shape of this
StrokeTransition . |
(package private) boolean |
startable(boolean forceSync) |
(package private) void |
sync(boolean forceSync) |
<any> |
toValueProperty()
Specifies the stop color value for this
StrokeTransition . |
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> shapeProperty
StrokeTransition
.
It is not possible to change the target shape
of a running
StrokeTransition
. If the value of shape
is changed for a
running StrokeTransition
, the animation has to be stopped and
started again to pick up the new value.
getShape()
,
setShape(Shape)
public final <any> durationProperty
StrokeTransition
.
It is not possible to change the duration
of a running
StrokeTransition
. If the value of duration
is changed for
a running StrokeTransition
, 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 <any> fromValueProperty
StrokeTransition
.
It is not possible to change fromValue
of a running
StrokeTransition
. If the value of fromValue
is changed
for a running StrokeTransition
, the animation has to be stopped
and started again to pick up the new value.
getFromValue()
,
setFromValue(Color)
public final <any> toValueProperty
StrokeTransition
.
It is not possible to change toValue
of a running
StrokeTransition
. If the value of toValue
is changed for
a running StrokeTransition
, the animation has to be stopped and
started again to pick up the new value.
getToValue()
,
setToValue(Color)
private Color start
private Color end
private <any> shape
StrokeTransition
.
It is not possible to change the target shape
of a running
StrokeTransition
. If the value of shape
is changed for a
running StrokeTransition
, the animation has to be stopped and
started again to pick up the new value.
private static final Shape DEFAULT_SHAPE
private Shape cachedShape
private <any> duration
StrokeTransition
.
It is not possible to change the duration
of a running
StrokeTransition
. If the value of duration
is changed for
a running StrokeTransition
, 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 <any> fromValue
StrokeTransition
.
It is not possible to change fromValue
of a running
StrokeTransition
. If the value of fromValue
is changed
for a running StrokeTransition
, the animation has to be stopped
and started again to pick up the new value.
private static final Color DEFAULT_FROM_VALUE
private <any> toValue
StrokeTransition
.
It is not possible to change toValue
of a running
StrokeTransition
. If the value of toValue
is changed for
a running StrokeTransition
, the animation has to be stopped and
started again to pick up the new value.
private static final Color DEFAULT_TO_VALUE
public StrokeTransition(Duration duration, Shape shape, Color fromValue, Color toValue)
StrokeTransition
duration
- The duration of the StrokeTransition
shape
- The shape
which filling will be animatedfromValue
- The start value of the color-animationtoValue
- The end value of the color-animationpublic StrokeTransition(Duration duration, Color fromValue, Color toValue)
StrokeTransition
duration
- The duration of the StrokeTransition
fromValue
- The start value of the color-animationtoValue
- The end value of the color-animationpublic StrokeTransition(Duration duration, Shape shape)
StrokeTransition
duration
- The duration of the StrokeTransition
shape
- The shape
which stroke paint will be animatedpublic StrokeTransition(Duration duration)
StrokeTransition
duration
- The duration of the StrokeTransition
public StrokeTransition()
StrokeTransition
public final void setShape(Shape value)
public final Shape getShape()
public final <any> shapeProperty()
StrokeTransition
.
It is not possible to change the target shape
of a running
StrokeTransition
. If the value of shape
is changed for a
running StrokeTransition
, the animation has to be stopped and
started again to pick up the new value.
getShape()
,
setShape(Shape)
public final void setDuration(Duration value)
public final Duration getDuration()
public final <any> durationProperty()
StrokeTransition
.
It is not possible to change the duration
of a running
StrokeTransition
. If the value of duration
is changed for
a running StrokeTransition
, 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(Color value)
public final Color getFromValue()
public final <any> fromValueProperty()
StrokeTransition
.
It is not possible to change fromValue
of a running
StrokeTransition
. If the value of fromValue
is changed
for a running StrokeTransition
, the animation has to be stopped
and started again to pick up the new value.
getFromValue()
,
setFromValue(Color)
public final void setToValue(Color value)
public final Color getToValue()
public final <any> toValueProperty()
StrokeTransition
.
It is not possible to change toValue
of a running
StrokeTransition
. If the value of toValue
is changed for
a running StrokeTransition
, the animation has to be stopped and
started again to pick up the new value.
getToValue()
,
setToValue(Color)
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 Shape getTargetShape()
boolean startable(boolean forceSync)
startable
in class Transition
void sync(boolean forceSync)
sync
in class Transition