public void applyTransition(Node node) { PathTransition pathTransition = new PathTransition(); timeline = pathTransition; path = (Path) drawPath(140.0, 140.0, 0); path.setStrokeWidth(2); path.setStroke(Color.RED); path.setFill(Color.TRANSPARENT); pathTransition.setDuration(Duration.millis(motionDuration)); pathTransition.setNode(node); //pathTransition.setPath(AnimationPath.createFromPath(path)); pathTransition.setPath(path); pathTransition.setOrientation(OrientationType.ORTHOGONAL_TO_TANGENT); }
@Override public Node drawNode() { currentTestNode = this; PathTransition pathTransition = new PathTransition(); Pane p = pre(pathTransition); SVGPath path = new SVGPath(); path.setContent("M40,60 C42,148 144,30 25,32"); path.setStrokeWidth(2); path.setStroke(Color.RED); p.getChildren().add(path); path.setFill(Color.TRANSPARENT); // pathTransition.setDuration(Duration.valueOf(typicalDuration)); pathTransition.setDuration(new Duration(typicalDuration)); pathTransition.setNode(circle); circle.setRotate(30); //pathTransition.setPath(AnimationPath.createFromPath(path)); pathTransition.setPath(path); pathTransition.setOrientation(OrientationType.NONE); timeline.setCycleCount(3); timeline.setAutoReverse(true); return p; }
@Override public Node drawNode() { currentTestNode = this; PathTransition pathTransition = new PathTransition(); Pane p = pre(pathTransition); Path path = createPath(); path.setStrokeWidth(2); path.setStroke(Color.RED); p.getChildren().add(path); path.setFill(Color.TRANSPARENT); pathTransition.setDuration(Duration.millis(typicalDuration)); pathTransition.setNode(circle); //pathTransition.setPath(AnimationPath.createFromPath(path)); pathTransition.setPath(path); pathTransition.setOrientation(OrientationType.ORTHOGONAL_TO_TANGENT); timeline.setCycleCount(3); timeline.setAutoReverse(true); return p; }
/** * Generate the path transition. * * @param shape Shape to travel along path. * @param path Path to be traveled upon. * @param duration Duration of single animation. * @param delay Delay before beginning first animation. * @param orientation Orientation of shape during animation. * @return PathTransition. */ private PathTransition generatePathTransition( final Shape shape, final Path path, final Duration duration, final Duration delay, final OrientationType orientation) { final PathTransition pathTransition = new PathTransition(); pathTransition.setDuration(duration); pathTransition.setDelay(delay); pathTransition.setPath(path); pathTransition.setNode(shape); pathTransition.setOrientation(orientation); pathTransition.setCycleCount(Timeline.INDEFINITE); pathTransition.setAutoReverse(true); return pathTransition; }
private void init(Stage primaryStage) { Group root = new Group(); primaryStage.setResizable(false); primaryStage.setScene(new Scene(root, 400,260)); Rectangle rect = new Rectangle (0, 0, 40, 40); rect.setArcHeight(10); rect.setArcWidth(10); rect.setFill(Color.ORANGE); root.getChildren().add(rect); Path path = PathBuilder.create() .elements( new MoveTo(20,20), new CubicCurveTo(380, 0, 380, 120, 200, 120), new CubicCurveTo(0, 120, 0, 240, 380, 240) ) .build(); path.setStroke(Color.DODGERBLUE); path.getStrokeDashArray().setAll(5d,5d); root.getChildren().add(path); pathTransition = PathTransitionBuilder.create() .duration(Duration.seconds(4)) .path(path) .node(rect) .orientation(OrientationType.ORTHOGONAL_TO_TANGENT) .cycleCount(Timeline.INDEFINITE) .autoReverse(true) .build(); }
public PathTransitionSample() { super(400,260); Rectangle rect = new Rectangle (0, 0, 40, 40); rect.setArcHeight(10); rect.setArcWidth(10); rect.setFill(Color.ORANGE); getChildren().add(rect); Path path = PathBuilder.create() .elements( new MoveTo(20,20), new CubicCurveTo(380, 0, 380, 120, 200, 120), new CubicCurveTo(0, 120, 0, 240, 380, 240) ) .build(); path.setStroke(Color.DODGERBLUE); path.getStrokeDashArray().setAll(5d,5d); getChildren().add(path); pathTransition = PathTransitionBuilder.create() .duration(Duration.seconds(4)) .path(path) .node(rect) .orientation(OrientationType.ORTHOGONAL_TO_TANGENT) .cycleCount(Timeline.INDEFINITE) .autoReverse(true) .build(); }
/** * Apply animation. * * @param group Group to which animation is to be applied. */ private void applyAnimation(final Group group) { final Path path = generateCurvyPath(); group.getChildren().add(path); final Shape rmoug = generateTitleText(); group.getChildren().add(rmoug); final Shape td = generateDaysText(); group.getChildren().add(td); final Shape denver = generateLocationText(); group.getChildren().add(denver); final PathTransition rmougTransition = generatePathTransition( rmoug, path, Duration.seconds(8.0), Duration.seconds(0.5), OrientationType.NONE); final PathTransition tdTransition = generatePathTransition( td, path, Duration.seconds(5.5), Duration.seconds(0.1), OrientationType.NONE); final PathTransition denverTransition = generatePathTransition( denver, path, Duration.seconds(30), Duration.seconds(3), OrientationType.ORTHOGONAL_TO_TANGENT); final ParallelTransition parallelTransition = new ParallelTransition(rmougTransition, tdTransition, denverTransition); parallelTransition.play(); }