ArcToLineT_Mixed1
 
path Hidden:

Code:

package javafxtemplate1;
// without a divider
import javafx.animation.Animation;
import javafx.animation.Interpolator;
import javafx.animation.PathTransition.OrientationType;
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.Circle;
import javafx.scene.shape.ClosePath;
import javafx.scene.shape.MoveTo;
import javafx.scene.shape.Path;
import javafx.stage.Stage;
import javafx.animation.PathTransition;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.PathElement;
import javafx.util.Duration;
/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {
//


@Override

public void start(Stage primaryStage)
{
//final Circle circle1 = new Circle(10,10,10);
final Circle circle1 = new Circle();
circle1.setCenterX(10);circle1.setCenterY(10);
circle1.setRadius(10.0f); circle1.setFill(Color.RED);
PathElement[] path = squareOrbit();
Path road = new Path();
road.setStroke(Color.BROWN);
road.setStrokeWidth(75);
road.getElements().addAll(path);
//
PathTransition anim = new PathTransition();
anim.setNode(circle1);// circle obkject
anim.setPath(road);// track
anim.setOrientation(OrientationType.ORTHOGONAL_TO_TANGENT);
anim.setInterpolator(Interpolator.LINEAR);
anim.setDuration(new Duration(6000));
anim.setCycleCount(Timeline.INDEFINITE);

Group root = new Group();
//root.getChildren().addAll(road, divider, circle1);
root.getChildren().addAll(road, circle1);
root.setTranslateX(50);
root.setTranslateY(50);
root.setOnMouseClicked(me ->
{
Animation.Status status = anim.getStatus();
if (status == Animation.Status.RUNNING &&
status != Animation.Status.PAUSED)
anim.pause();
else
anim.play();
});
Scene scene = new Scene(root, 500, 500, Color.WHITE);

primaryStage.setTitle("PathTransition Demo");
primaryStage.setScene(scene);
primaryStage.show();
}
private PathElement[] squareOrbit()
{
PathElement[] path =
{
new MoveTo(0, 250),
new ArcTo(100, 100, 0, 100, 400, false, false),
new LineTo(300, 400),
new ArcTo(100, 100, 0, 100, 300, false, false),
new LineTo(400, 100),
//new ArcTo(100, 100, 0, 300, 0, false, false),
// new LineTo(100, 0),
//new ArcTo(100, 100, 0, 0, 100, false, false),
//new LineTo(0, 300),
new ClosePath()
};
return path;
}
public static void main(String[] args) {
launch(args);

}

}