ArcTo_as_line1
 
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.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.event.EventType;
import javafx.scene.control.ProgressBar;
import javafx.scene.control.Slider;
import javafx.scene.control.TextField;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.PathElement;
import javafx.util.Duration;
import javafx.util.converter.NumberStringConverter;
/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {
//

final TextField curve = new TextField();
ProgressBar p2 = new ProgressBar();
Slider slider1 = new Slider(0,10,1);
double d1= 50;
@Override

public void start(Stage primaryStage)
{
/*
ImageView car = new ImageView();
car.setImage(new Image("file:res/car.gif"));
car.setX(-car.getImage().getWidth() / 2);
car.setY(300 - car.getImage().getHeight());
car.setRotate(90);
//
*/
//final Circle circle1 = new Circle(10,10,10);
final Circle circle1 = new Circle();
circle1.setCenterX(-5);circle1.setCenterY(5);
circle1.setRadius(10.0f); circle1.setFill(Color.WHITE);

slider1.valueProperty().addListener(new ChangeListener<Number>() {
public void changed(ObservableValue<? extends Number> ov,
Number old_val, Number new_val) {
d1=(new_val.doubleValue());
curve.setText(String.format("%.2f", new_val));
}
});
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);

PathTransition anim = new PathTransition();
anim.setNode(circle1);// circle object
anim.setPath(track);// 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(divider, circle1);
//root.getChildren().addAll(track, circle1);
//root.getChildren().addAll(divider, circle1);
root.setTranslateX(50);
root.setTranslateY(50);
root.setOnMouseClicked(e ->
{
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.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
PathElement[] path =
{
new MoveTo(0, 200), // zero to 300 streched
// new ArcTo(100,100, 50,slider1.getValue(),50,false,false),
new ArcTo(10, 0, 0, 0,0,false,false),
//new ArcTo(200, 200, 10, 10,200,false,false),
new ClosePath()
};
return path;
}
public static void main(String[] args) {
launch(args);

}

}

 

 
Runtime displays