CubicCurveTo_Rotation1
 
 
Code :

package javafxtemplate1;
// rotation along CubicCurveTo
import javafx.animation.Animation;
import javafx.animation.Interpolator;
import javafx.animation.Timeline;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.ArcTo;
import javafx.scene.shape.ClosePath;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.stage.Stage;
import javafx.animation.RotateTransition;
import javafx.scene.control.Label;
import javafx.scene.shape.CubicCurveTo;
import javafx.scene.shape.PathElement;
import javafx.util.Duration;

/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {
//


@Override

public void start(Stage primaryStage)
{
Label label1 = new Label("Click On the screen");
label1.setLayoutX(10);label1.setLayoutY(220);
// PathElement array of mixed getElements
PathElement[] path = squareOrbit();
Path track = new Path();
track.setStroke(Color.BROWN);
track.setStrokeWidth(10);
track.getElements().addAll(path);

Path divider = new Path();
divider.setStroke(Color.WHITE);
divider.setStrokeWidth(1);
divider.getStrokeDashArray().addAll(10.0, 10.0);
divider.getElements().addAll(path);

RotateTransition spin = new RotateTransition();
spin.setNode(divider);
spin.setFromAngle(0);
spin.setToAngle(-360);// anti-clock spin
spin.setInterpolator(Interpolator.LINEAR);
spin.setCycleCount(Timeline.INDEFINITE);
spin.setDuration(new Duration(5000));
//
RotateTransition anim = new RotateTransition();
anim.setNode(track);
anim.setFromAngle(0);
anim.setToAngle(360);// clock spin
anim.setInterpolator(Interpolator.LINEAR);
anim.setCycleCount(Timeline.INDEFINITE);
anim.setDuration(new Duration(5000));
//

Group root = new Group();
root.getChildren().addAll(track,label1,divider);
//root.getChildren().addAll(track, circle1);
//root.getChildren().addAll(divider, circle1);
root.setTranslateX(50);
root.setTranslateY(50);
root.setOnMouseClicked(e ->
{
Animation.Status status1 = anim.getStatus();
Animation.Status status2 = spin.getStatus();

if (status1 == Animation.Status.RUNNING &&
status1 != Animation.Status.PAUSED){
anim.pause();}

else{
anim.play();
}

//
if (status2 == Animation.Status.RUNNING &&
status2 != Animation.Status.PAUSED){
spin.pause();
//track.visibleProperty().set(true);
}
else{
spin.play();
// track.visibleProperty().set(false);
}
});
Scene scene = new Scene(root, 500, 500, Color.DARKGRAY);

primaryStage.setTitle("PathTransition Demo");
primaryStage.setScene(scene);
primaryStage.show();
}
private PathElement[] squareOrbit()
{
// ArcTo.ArcTo(double,double,double,double,double,boolean,boolean)
//x, y, XAxis Rotation
//CubicCurveTo curve = new CubicCurveTo();
//curve= createStartingCurve();
PathElement[] path =
{

new MoveTo(0, 200), // zero to 300 streched
//straight line arcto
//new ArcTo(20,20,100,100,0,false,false),
new CubicCurveTo(0, 0,150,250,150,50),
new ClosePath()

};
return path;
}

public static void main(String[] args) {
launch(args);

}

}
 

Runtime display: