- java.lang.Object
-
- javafx.animation.Animation
-
- javafx.animation.Transition
-
- javafx.animation.PathTransition
-
public final class PathTransition extends Transition
这个Transition创建了一个跨越其duration的路径动画。 沿着路径的翻译是通过更新translateX和translateY变量来node,如果orientation以规则间隔设置为OrientationType.ORTHOGONAL_TO_TANGENT,则rotate变量将被更新。动画路径由形状的轮廓定义。
代码段示例:
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(); ...- 从以下版本开始:
- JavaFX 2.0
- 另请参见:
-
Transition,Animation
-
-
Property Summary
Properties Type Property 描述 ObjectProperty<Duration>duration持续时间Transition。ObjectProperty<Node>node该目标节点为PathTransition。ObjectProperty<PathTransition.OrientationType>orientation指定node沿path的直立方向。ObjectProperty<Shape>path大纲节点应该被动画的形状。-
Properties inherited from class javafx.animation.Animation
autoReverse, currentRate, currentTime, cycleCount, cycleDuration, delay, onFinished, rate, status, totalDuration
-
Properties inherited from class javafx.animation.Transition
interpolator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class 描述 static classPathTransition.OrientationType指定node沿path的直立方向。-
Nested classes/interfaces inherited from class javafx.animation.Animation
Animation.Status
-
-
Field Summary
-
Fields inherited from class javafx.animation.Animation
INDEFINITE
-
-
构造方法摘要
构造方法 Constructor 描述 PathTransition()构造函数为PathTransition。PathTransition(Duration duration, Shape path)构造函数为PathTransition。PathTransition(Duration duration, Shape path, Node node)构造函数为PathTransition。
-
方法摘要
所有方法 接口方法 具体的方法 Modifier and Type 方法 描述 ObjectProperty<Duration>durationProperty()这个Transition的持续时间。DurationgetDuration()获取属性持续时间的值。NodegetNode()获取属性节点的值。PathTransition.OrientationTypegetOrientation()获取属性方向的值。ShapegetPath()获取属性路径的值。voidinterpolate(double frac)该方法interpolate()必须通过的实现来提供Transition。ObjectProperty<Node>nodeProperty()这个PathTransition的目标节点。ObjectProperty<PathTransition.OrientationType>orientationProperty()指定node的直立方向path。ObjectProperty<Shape>pathProperty()大纲节点应该被动画的形状。voidsetDuration(Duration value)设置属性持续时间的值。voidsetNode(Node value)设置属性节点的值。voidsetOrientation(PathTransition.OrientationType value)设置属性方向的值。voidsetPath(Shape value)设置属性路径的值。-
Methods inherited from class javafx.animation.Animation
autoReverseProperty, currentRateProperty, currentTimeProperty, cycleCountProperty, cycleDurationProperty, delayProperty, getCuePoints, getCurrentRate, getCurrentTime, getCycleCount, getCycleDuration, getDelay, getOnFinished, getRate, getStatus, getTargetFramerate, getTotalDuration, isAutoReverse, jumpTo, jumpTo, onFinishedProperty, pause, play, playFrom, playFrom, playFromStart, rateProperty, setAutoReverse, setCycleCount, setCycleDuration, setDelay, setOnFinished, setRate, setStatus, statusProperty, stop, totalDurationProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from class javafx.animation.Transition
getCachedInterpolator, getInterpolator, getParentTargetNode, interpolatorProperty, setInterpolator
-
-
-
-
Property Detail
-
node
public final ObjectProperty<Node> nodeProperty
这个PathTransition的目标节点。无法更改目标
node的一个正在运行的PathTransition。 如果node的值更改为运行中的PathTransition,则动画必须停止并再次启动以接收新值。- 另请参见:
-
getNode(),setNode(Node)
-
duration
public final ObjectProperty<Duration> durationProperty
这个Transition的持续时间。不可能更改
duration的一个正在运行的PathTransition。 如果值duration改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。注意:
duration的单位是毫秒,粒度取决于底层的操作系统,一般会更大。 例如,桌面系统上的动画通常运行时间最多为60fps,粒度为〜17 ms。 将持续时间设置为低于Duration.ZERO将导致IllegalArgumentException。- Default value:
- 400毫秒
- 另请参见:
-
getDuration(),setDuration(Duration)
-
path
public final ObjectProperty<Shape> pathProperty
大纲节点应该被动画的形状。这是不可能改变
path正在运行的PathTransition。 如果值path改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。- Default value:
- 空值
- 另请参见:
-
getPath(),setPath(Shape)
-
orientation
public final ObjectProperty<PathTransition.OrientationType> orientationProperty
指定node沿path的直立方向。 默认方向设置为PathTransition.OrientationType.NONE。这是不可能改变
orientation正在运行的PathTransition。 如果值orientation改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。- Default value:
- 没有
- 另请参见:
-
getOrientation(),setOrientation(PathTransition.OrientationType)
-
-
构造方法详细信息
-
PathTransition
public PathTransition(Duration duration, Shape path, Node node)
构造函数为PathTransition。- 参数
-
duration- 这个 PathTransition的PathTransition -
path- 该path的PathTransition -
node-node的这个PathTransition
-
PathTransition
public PathTransition(Duration duration, Shape path)
构造函数为PathTransition。- 参数
-
duration- 该 PathTransition的PathTransition -
path- 这个 PathTransition的PathTransition
-
PathTransition
public PathTransition()
构造函数为PathTransition。
-
-
方法详细信息
-
setNode
public final void setNode(Node value)
设置属性节点的值。- Property description:
-
这个
PathTransition的目标节点。无法更改目标
node运行的PathTransition。 如果值node改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。
-
getNode
public final Node getNode()
获取属性节点的值。- Property description:
-
这个
PathTransition的目标节点。无法更改目标
node的运行中的PathTransition。 如果值node改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。
-
nodeProperty
public final ObjectProperty<Node> nodeProperty()
这个PathTransition的目标节点。这是不可能改变目标
node正在运行的PathTransition。 如果值node改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。- 另请参见:
-
getNode(),setNode(Node)
-
setDuration
public final void setDuration(Duration value)
设置属性持续时间的值。- Property description:
-
这个
Transition的持续时间。无法更改
duration的一个正在运行的PathTransition。 如果值duration改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。注意:虽然
duration的单位为毫秒,但粒度取决于底层的操作系统,通常会更大。 例如,桌面系统上的动画通常运行时间最多为60fps,粒度为〜17 ms。 将持续时间设置为低于Duration.ZERO将导致IllegalArgumentException。 - Default value:
- 400毫秒
-
getDuration
public final Duration getDuration()
获取属性持续时间的值。- Property description:
-
这个
Transition的持续时间。无法更改
duration的运行中的PathTransition。 如果值duration改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。注意:
duration的单位是毫秒,粒度取决于底层的操作系统,一般来说会更大。 例如,桌面系统上的动画通常运行时间最多为60fps,粒度为〜17 ms。 设定持续时间低于Duration.ZERO将导致IllegalArgumentException。 - Default value:
- 400毫秒
-
durationProperty
public final ObjectProperty<Duration> durationProperty()
这个Transition的持续时间。无法更改
duration的PathTransition。 如果值duration改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。注意:
duration的单位是毫秒,粒度取决于底层的操作系统,一般来说会更大。 例如,桌面系统上的动画通常运行时间最多为60fps,粒度为〜17 ms。 设定持续时间低于Duration.ZERO将导致IllegalArgumentException。- Default value:
- 400毫秒
- 另请参见:
-
getDuration(),setDuration(Duration)
-
setPath
public final void setPath(Shape value)
设置属性路径的值。- Property description:
-
大纲节点应该被动画的形状。
不可能更改
path的PathTransition。 如果值path改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。 - Default value:
- 空值
-
getPath
public final Shape getPath()
获取属性路径的值。- Property description:
-
大纲节点应该被动画的形状。
无法更改
path的PathTransition。 如果值path改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。 - Default value:
- 空值
-
pathProperty
public final ObjectProperty<Shape> pathProperty()
大纲节点应该被动画的形状。不可能更改
path的PathTransition。 如果值path改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。- Default value:
- 空值
- 另请参见:
-
getPath(),setPath(Shape)
-
setOrientation
public final void setOrientation(PathTransition.OrientationType value)
设置属性方向的值。- Property description:
-
指定
node沿path的直立方向。 默认方向设置为PathTransition.OrientationType.NONE。无法更改
orientation的PathTransition。 如果值orientation改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。 - Default value:
- 没有
-
getOrientation
public final PathTransition.OrientationType getOrientation()
获取属性方向的值。- Property description:
-
指定
node沿path的直立方向。 默认方向设置为PathTransition.OrientationType.NONE。无法更改
orientation的PathTransition。 如果值orientation改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。 - Default value:
- 没有
-
orientationProperty
public final ObjectProperty<PathTransition.OrientationType> orientationProperty()
指定node沿path的直立方向。 默认方向设置为PathTransition.OrientationType.NONE。不可能更改
orientation的一个正在运行的PathTransition。 如果值orientation改变正在运行的PathTransition,动画必须停止并重新开始拿起新的价值。- Default value:
- 没有
- 另请参见:
-
getOrientation(),setOrientation(PathTransition.OrientationType)
-
interpolate
public void interpolate(double frac)
方法interpolate()必须由Transition的实现来提供。 当一个Transition正在运行时,这个方法在每个帧中被调用。 该参数用动画定义当前位置。 一开始,分数将为0.0,最终将为1.0。 参数如何增加,取决于interpolator,例如,如果interpolator是Interpolator.LINEAR,则分数会增加线性。 该方法不能直接由用户调用。- Specified by:
-
interpolate在Transition - 参数
-
frac- The relative position
-
-