Java Reference
In-Depth Information
100,
100,
20,
false,
CycleMethod.NO_CYCLE,
new Stop(0, Color.RED),
new Stop(1, Color.BLACK));
// create a sphere
final Circle sphere = new Circle();
sphere.setCenterX(100);
sphere.setCenterY(100);
sphere.setRadius(20);
sphere.setFill(gradient1);
// add sphere
root.getChildren().add(sphere);
// animate sphere by following the path.
final PathTransition pathTransition = new
PathTransition();
pathTransition.setDuration(Duration.millis(4000));
pathTransition.setCycleCount(1);
pathTransition.setNode(sphere);
pathTransition.setPath(onePath);
pathTransition.setOrientation(PathTransition.OrientationType.ORTHOGONAL_TO_TANGENT);
// once finished clear path
pathTransition.onFinishedProperty().set((EventHandler<ActionEvent>)
(ActionEvent event) -> {
onePath.getElements().clear();
});
// starting initial path
scene.onMousePressedProperty().set((EventHandler<MouseEvent>)
(MouseEvent event) -> {
onePath.getElements().clear();
// start point in path
anchorPt = new Point2D(event.getX(),
Search WWH ::




Custom Search