public final class PathTransition extends Transition
Transition
creates a path animation that spans its
duration
. The translation along the path is done by updating the
translateX
and translateY
variables of the node
, and
the rotate
variable will get updated if orientation
is set to
OrientationType.ORTHOGONAL_TO_TANGENT
, at regular interval.
The animated path is defined by the outline of a shape.
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);
Path path = new Path();
path.getElements().add (new MoveTo (0f, 50f));
path.getElements().add (new CubicCurveTo (40f, 10f, 390f, 240f, 1904, 50f));
pathTransition.setDuration(Duration.millis(10000));
pathTransition.setNode(rect);
pathTransition.setPath(path);
pathTransition.setOrientation(OrientationType.ORTHOGONAL_TO_TANGENT);
pathTransition.setCycleCount(4f);
pathTransition.setAutoReverse(true);
pathTransition.play();
...
Transition
,
Animation
Type | Property and Description |
---|---|
<any> |
duration
The duration of this
Transition . |
<any> |
node
The target node of this
PathTransition . |
<any> |
orientation
Specifies the upright orientation of
node along the path . |
<any> |
path
The shape on which outline the node should be animated.
|
interpolatorProperty
autoReverseProperty, currentRateProperty, currentTimeProperty, cycleCountProperty, cycleDurationProperty, delayProperty, onFinishedProperty, rateProperty, statusProperty, totalDurationProperty
Modifier and Type | Class and Description |
---|---|
static class |
PathTransition.OrientationType
Specifies the upright orientation of
node along the path . |
private static class |
PathTransition.Segment |
Animation.Status
Modifier and Type | Field and Description |
---|---|
private boolean |
cachedIsNormalRequired |
private Node |
cachedNode |
private static Duration |
DEFAULT_DURATION |
private static Node |
DEFAULT_NODE |
private static PathTransition.OrientationType |
DEFAULT_ORIENTATION |
private static Shape |
DEFAULT_PATH |
private <any> |
duration
The duration of this
Transition . |
private <any> |
node
The target node of this
PathTransition . |
private <any> |
orientation
Specifies the upright orientation of
node along the path . |
private <any> |
path
The shape on which outline the node should be animated.
|
private java.util.ArrayList<PathTransition.Segment> |
segments |
private static int |
SMOOTH_ZONE |
private double |
totalLength |
clipEnvelope, INDEFINITE, parent, pulseReceiver
Constructor and Description |
---|
PathTransition()
The constructor of
PathTransition . |
PathTransition(Duration duration,
Shape path)
The constructor of
PathTransition . |
PathTransition(Duration duration,
Shape path,
Node node)
The constructor of
PathTransition . |
Modifier and Type | Method and Description |
---|---|
<any> |
durationProperty()
The duration of this
Transition . |
private int |
findSegment(int begin,
int end,
double length)
Returns the index of the first segment having accumulated length
from the path beginning, greater than
length |
Duration |
getDuration()
Gets the value of the property duration.
|
Node |
getNode()
Gets the value of the property node.
|
PathTransition.OrientationType |
getOrientation()
Gets the value of the property orientation.
|
Shape |
getPath()
Gets the value of the property path.
|
private Node |
getTargetNode() |
void |
interpolate(double frac)
The method
interpolate() has to be provided by implementations of
Transition . |
private static double |
interpolate(double fromAngle,
double toAngle,
double ratio)
Interpolates angle according to rate,
with correct 0->360 and 360->0 transitions
|
<any> |
nodeProperty()
The target node of this
PathTransition . |
private static double |
normalize(double angle)
Converts angle to range 0-360
|
<any> |
orientationProperty()
Specifies the upright orientation of
node along the path . |
<any> |
pathProperty()
The shape on which outline the node should be animated.
|
private void |
recomputeSegments() |
void |
setDuration(Duration value)
Sets the value of the property duration.
|
void |
setNode(Node value)
Sets the value of the property node.
|
void |
setOrientation(PathTransition.OrientationType value)
Sets the value of the property orientation.
|
void |
setPath(Shape value)
Sets the value of the property path.
|
(package private) boolean |
startable(boolean forceSync) |
(package private) void |
sync(boolean forceSync) |
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
PathTransition
.
It is not possible to change the target node
of a running
PathTransition
. If the value of node
is changed for a
running PathTransition
, the animation has to be stopped and
started again to pick up the new value.
getNode()
,
setNode(Node)
public final <any> durationProperty
Transition
.
It is not possible to change the duration
of a running
PathTransition
. If the value of duration
is changed for a
running PathTransition
, 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> pathProperty
It is not possible to change the path
of a running
PathTransition
. If the value of path
is changed for a
running PathTransition
, the animation has to be stopped and
started again to pick up the new value.
getPath()
,
setPath(Shape)
public final <any> orientationProperty
node
along the path
.
The default orientation is set to PathTransition.OrientationType.NONE
.
It is not possible to change the orientation
of a running
PathTransition
. If the value of orientation
is changed
for a running PathTransition
, the animation has to be stopped and
started again to pick up the new value.
getOrientation()
,
setOrientation(OrientationType)
private <any> node
PathTransition
.
It is not possible to change the target node
of a running
PathTransition
. If the value of node
is changed for a
running PathTransition
, the animation has to be stopped and
started again to pick up the new value.
private double totalLength
private final java.util.ArrayList<PathTransition.Segment> segments
private static final Node DEFAULT_NODE
private static final int SMOOTH_ZONE
private Node cachedNode
private <any> duration
Transition
.
It is not possible to change the duration
of a running
PathTransition
. If the value of duration
is changed for a
running PathTransition
, 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> path
It is not possible to change the path
of a running
PathTransition
. If the value of path
is changed for a
running PathTransition
, the animation has to be stopped and
started again to pick up the new value.
private static final Shape DEFAULT_PATH
private <any> orientation
node
along the path
.
The default orientation is set to PathTransition.OrientationType.NONE
.
It is not possible to change the orientation
of a running
PathTransition
. If the value of orientation
is changed
for a running PathTransition
, the animation has to be stopped and
started again to pick up the new value.
private static final PathTransition.OrientationType DEFAULT_ORIENTATION
private boolean cachedIsNormalRequired
public PathTransition(Duration duration, Shape path, Node node)
PathTransition
.public PathTransition(Duration duration, Shape path)
PathTransition
.public PathTransition()
PathTransition
.public final void setNode(Node value)
public final Node getNode()
public final <any> nodeProperty()
PathTransition
.
It is not possible to change the target node
of a running
PathTransition
. If the value of node
is changed for a
running PathTransition
, 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()
Transition
.
It is not possible to change the duration
of a running
PathTransition
. If the value of duration
is changed for a
running PathTransition
, 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 setPath(Shape value)
public final Shape getPath()
public final <any> pathProperty()
It is not possible to change the path
of a running
PathTransition
. If the value of path
is changed for a
running PathTransition
, the animation has to be stopped and
started again to pick up the new value.
getPath()
,
setPath(Shape)
public final void setOrientation(PathTransition.OrientationType value)
public final PathTransition.OrientationType getOrientation()
public final <any> orientationProperty()
node
along the path
.
The default orientation is set to PathTransition.OrientationType.NONE
.
It is not possible to change the orientation
of a running
PathTransition
. If the value of orientation
is changed
for a running PathTransition
, the animation has to be stopped and
started again to pick up the new value.
getOrientation()
,
setOrientation(OrientationType)
public 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
private void recomputeSegments()
private int findSegment(int begin, int end, double length)
length
private static double interpolate(double fromAngle, double toAngle, double ratio)
private static double normalize(double angle)