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.transition.*;
...
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
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 ObjectProperty<Duration> |
duration
The duration of this
Transition . |
private ObjectProperty<Node> |
node
The target node of this
PathTransition . |
private ObjectProperty<PathTransition.OrientationType> |
orientation
Specifies the upright orientation of
node along the path . |
private ObjectProperty<Shape> |
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 |
---|---|
ObjectProperty<Duration> |
durationProperty() |
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() |
Node |
getNode() |
PathTransition.OrientationType |
getOrientation() |
Shape |
getPath() |
private Node |
getTargetNode() |
(package private) boolean |
impl_startable(boolean forceSync) |
(package private) void |
impl_sync(boolean forceSync) |
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
|
ObjectProperty<Node> |
nodeProperty() |
private static double |
normalize(double angle)
Converts angle to range 0-360
|
ObjectProperty<PathTransition.OrientationType> |
orientationProperty() |
ObjectProperty<Shape> |
pathProperty() |
private void |
recomputeSegments() |
void |
setDuration(Duration value) |
void |
setNode(Node value) |
void |
setOrientation(PathTransition.OrientationType value) |
void |
setPath(Shape value) |
getCachedInterpolator, getInterpolator, getParentTargetNode, impl_jumpTo, impl_playTo, interpolatorProperty, setInterpolator
autoReverseProperty, currentRateProperty, currentTimeProperty, cycleCountProperty, cycleDurationProperty, delayProperty, getCuePoints, getCurrentRate, getCurrentTime, getCycleCount, getCycleDuration, getDelay, getOnFinished, getRate, getStatus, getTargetFramerate, getTotalDuration, impl_finished, impl_pause, impl_resume, impl_setCurrentRate, impl_setCurrentTicks, impl_start, impl_stop, impl_timePulse, isAutoReverse, jumpTo, jumpTo, onFinishedProperty, pause, pauseReceiver, play, playFrom, playFrom, playFromStart, rateProperty, resumeReceiver, setAutoReverse, setCycleCount, setCycleDuration, setDelay, setOnFinished, setRate, setStatus, startReceiver, statusProperty, stop, totalDurationProperty
private ObjectProperty<Node> 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 ObjectProperty<Duration> 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 ObjectProperty<Shape> 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 ObjectProperty<PathTransition.OrientationType> 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 ObjectProperty<Node> nodeProperty()
public final void setDuration(Duration value)
public final Duration getDuration()
public final ObjectProperty<Duration> durationProperty()
public final void setPath(Shape value)
public final Shape getPath()
public final ObjectProperty<Shape> pathProperty()
public final void setOrientation(PathTransition.OrientationType value)
public final PathTransition.OrientationType getOrientation()
public final ObjectProperty<PathTransition.OrientationType> orientationProperty()
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 impl_startable(boolean forceSync)
impl_startable
in class Transition
void impl_sync(boolean forceSync)
impl_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)