Top Description Fields Constructors Methods
javafx.animation

public final Class StrokeTransition

extends Transition
Class Inheritance
Imports
javafx.beans.property.ObjectProperty, .ObjectPropertyBase, .SimpleObjectProperty, javafx.scene.Node, javafx.scene.paint.Color, javafx.scene.shape.Shape, javafx.util.Duration

This 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();

...


Since
JavaFX 2.0
See Also
Transition, Animation

Field Summary

Modifier and TypeField and Description
private Shape
private static final Duration
private static final Color
private static final Shape
private static final Color
private ObjectProperty<Duration>
duration

The duration of this StrokeTransition.

private Color
private ObjectProperty<Color>
fromValue

Specifies the start color value for this StrokeTransition.

private ObjectProperty<Shape>
shape

The target shape of this StrokeTransition.

private Color
private ObjectProperty<Color>
toValue

Specifies the stop color value for this StrokeTransition.

Constructor Summary

AccessConstructor and Description
public
StrokeTransition(Duration
The duration of the StrokeTransition
duration
,
Shape
The shape which filling will be animated
shape
,
Color
The start value of the color-animation
fromValue
,
Color
The end value of the color-animation
toValue
)

The constructor of StrokeTransition

public
StrokeTransition(Duration
The duration of the StrokeTransition
duration
,
Color
The start value of the color-animation
fromValue
,
Color
The end value of the color-animation
toValue
)

The constructor of StrokeTransition

public
StrokeTransition(Duration
The duration of the StrokeTransition
duration
,
Shape
The shape which stroke paint will be animated
shape
)

The constructor of StrokeTransition

public
StrokeTransition(Duration
The duration of the StrokeTransition
duration
)

The constructor of StrokeTransition

public
StrokeTransition()

The constructor of StrokeTransition

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<Duration>
public final ObjectProperty<Color>
public final Duration
public final Color
public final Shape
private Shape
public final Color
protected void
interpolate(double
The relative position
frac
)

Implements abstract javafx.animation.Transition.interpolate.

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

public final void
public final void
public final void
setShape(Shape value)

public final void
public final ObjectProperty<Shape>
pack-priv boolean
startable(boolean forceSync)

Overrides javafx.animation.Transition.startable.

pack-priv void
sync(boolean forceSync)

Overrides javafx.animation.Transition.sync.

public final ObjectProperty<Color>
Inherited from javafx.animation.Transition:
doJumpTodoPlayTogetCachedInterpolatorgetInterpolatorgetParentTargetNodeinterpolatorPropertysetInterpolator

Field Detail

cachedShapeback to summary
private Shape cachedShape
DEFAULT_DURATIONback to summary
private static final Duration DEFAULT_DURATION
DEFAULT_FROM_VALUEback to summary
private static final Color DEFAULT_FROM_VALUE
DEFAULT_SHAPEback to summary
private static final Shape DEFAULT_SHAPE
DEFAULT_TO_VALUEback to summary
private static final Color DEFAULT_TO_VALUE
durationback to summary
private ObjectProperty<Duration> duration

The duration of this 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.

Default Value
400ms
endback to summary
private Color end
fromValueback to summary
private ObjectProperty<Color> fromValue

Specifies the start color value for this 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.

Default Value
null
shapeback to summary
private ObjectProperty<Shape> shape

The target shape of this 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.

startback to summary
private Color start
toValueback to summary
private ObjectProperty<Color> toValue

Specifies the stop color value for this 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.

Default Value
null

Constructor Detail

StrokeTransitionback to summary
public StrokeTransition(Duration duration, Shape shape, Color fromValue, Color toValue)

The constructor of StrokeTransition

Parameters
duration:Duration

The duration of the StrokeTransition

shape:Shape

The shape which filling will be animated

fromValue:Color

The start value of the color-animation

toValue:Color

The end value of the color-animation

StrokeTransitionback to summary
public StrokeTransition(Duration duration, Color fromValue, Color toValue)

The constructor of StrokeTransition

Parameters
duration:Duration

The duration of the StrokeTransition

fromValue:Color

The start value of the color-animation

toValue:Color

The end value of the color-animation

StrokeTransitionback to summary
public StrokeTransition(Duration duration, Shape shape)

The constructor of StrokeTransition

Parameters
duration:Duration

The duration of the StrokeTransition

shape:Shape

The shape which stroke paint will be animated

StrokeTransitionback to summary
public StrokeTransition(Duration duration)

The constructor of StrokeTransition

Parameters
duration:Duration

The duration of the StrokeTransition

StrokeTransitionback to summary
public StrokeTransition()

The constructor of StrokeTransition

Method Detail

durationPropertyback to summary
public final ObjectProperty<Duration> durationProperty()
fromValuePropertyback to summary
public final ObjectProperty<Color> fromValueProperty()
getDurationback to summary
public final Duration getDuration()
getFromValueback to summary
public final Color getFromValue()
getShapeback to summary
public final Shape getShape()
getTargetShapeback to summary
private Shape getTargetShape()
getToValueback to summary
public final Color 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.

Parameters
frac:double

The relative position

Annotations
@Override
setDurationback to summary
public final void setDuration(Duration value)
setFromValueback to summary
public final void setFromValue(Color value)
setShapeback to summary
public final void setShape(Shape value)
setToValueback to summary
public final void setToValue(Color value)
shapePropertyback to summary
public final ObjectProperty<Shape> shapeProperty()
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 ObjectProperty<Color> toValueProperty()