コード例 #1
0
ファイル: ArcToDemo.java プロジェクト: elbelife/ctl
  private void init(Stage primaryStage) {
    Group root = new Group();
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(root, 600, 460));

    // Ellipse path example
    Rectangle rect = new Rectangle(0, 0, 40, 40);
    rect.setArcHeight(10);
    rect.setArcWidth(10);
    rect.setFill(Color.ORANGE);
    root.getChildren().add(rect);

    Path path = createEllipsePath(200, 200, 50, 100, 45);
    root.getChildren().add(path);

    pathTransitionEllipse =
        PathTransitionBuilder.create()
            .duration(Duration.seconds(4))
            .path(path)
            .node(rect)
            .orientation(OrientationType.NONE)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(false)
            .build();

    rect.setLayoutX(rect.getLayoutX() + rect.getLayoutBounds().getWidth() / 2);
    rect.setLayoutY(rect.getLayoutY() + rect.getLayoutBounds().getHeight() / 2);

    // Circle path example
    Rectangle rect2 = new Rectangle(0, 0, 20, 20);
    rect2.setArcHeight(10);
    rect2.setArcWidth(10);
    rect2.setFill(Color.GREEN);
    root.getChildren().add(rect2);

    Path path2 = createEllipsePath(400, 200, 150, 150, 0);
    root.getChildren().add(path2);

    pathTransitionCircle =
        PathTransitionBuilder.create()
            .duration(Duration.seconds(2))
            .path(path2)
            .node(rect2)
            .orientation(OrientationType.NONE)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(false)
            .build();

    rect2.setLayoutX(rect2.getLayoutX() + rect2.getLayoutBounds().getWidth() / 2);
    rect2.setLayoutY(rect2.getLayoutY() + rect2.getLayoutBounds().getHeight() / 2);
  }