Circle_Path_Line1
  • Displaying
    • Element
    • Path
    • No Animation ::
  • MoveTo: has only two public variables,
    x and y, both of type Number that set the starting point for the next element in the path.
    • starting point of current path
    • moveTo(double x0, double y0)
    • Creates an addition to the path by moving to the specified coordinates.
  • Works along with Path, Path Transtion, and Path Element
 
Code :

package javafxtemplate1;
// Circle_Path_Line1
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.CubicCurveTo;
import javafx.scene.shape.LineTo;
import javafx.scene.shape.PathElement;
import javafx.util.Duration;
/**
*
* @author Manas9
*/
public class JavaFXTemplate1 extends Application {
//

final PathTransition pathTransition = new PathTransition();
@Override

public void start(Stage primaryStage)
{

final Circle circle1 = new Circle();
circle1.setCenterX(10);circle1.setCenterY(10);
circle1.setRadius(10.0f); circle1.setFill(Color.WHITE);
//PathElement[] path = squareOrbit();
Path path = new Path();
path.getElements().add (new MoveTo (0f, 50f));
path.setStroke(Color.WHITE);
path.setStrokeWidth(4);
path.getElements().add(new LineTo(100.0f, 100.0f));

//

Group root = new Group();
root.getChildren().addAll(path, circle1);
// root.getChildren().addAll(track, circle1);
root.setTranslateX(50);
root.setTranslateY(50);

Scene scene = new Scene(root, 500, 500, Color.DARKGRAY);

primaryStage.setTitle("Moveto-Path demo");
primaryStage.setScene(scene);
primaryStage.show();
}

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

}

}
 

Runtime displays: