gridPane中的JavaFx路径转换

gridPane中的JavaFx路径转换,java,javafx,transition,Java,Javafx,Transition,我无法理解moveTo方法在javafx中是如何工作的。这是我的例子 我有一个由4列和1行组成的网格窗格。所有列h都有一个StackPane,最后一个StackPane也有一个空标签 public class PathTransitionTExample extends Application { StackPane pane; GridPane grid; Label label; Scene scene; @Override public void start(Stage primar

我无法理解moveTo方法在javafx中是如何工作的。这是我的例子 我有一个由4列和1行组成的网格窗格。所有列h都有一个StackPane,最后一个StackPane也有一个空标签

public class PathTransitionTExample extends Application {

StackPane pane;
GridPane grid;
Label label;
 Scene scene;

@Override
public void start(Stage primaryStage) {

    label = new Label();
    label.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE);
    grid = new GridPane();
    grid.getStyleClass().add("gridPane");

    for (int x = 0; x < 4; x++) {
        grid.add(pane = new StackPane(), x, 0);
        pane.setPrefSize(50, 50);
        pane.getStyleClass().add("stackPane");
    }

    pane = (StackPane) grid.getChildren().get(3);
    pane.getChildren().add(label);

     scene = new Scene(grid, 260, 50);


  scene.getStylesheets().add(PathTransitionTest.class.getResource("pathCSS.css").toExternalForm());
     scene.setOnMouseClicked(me ->  pathTransition()); 
    primaryStage.setTitle("Path Transition");
    primaryStage.setScene(scene);
    primaryStage.show();
}

  //pathCSS.css

.gridPane{
-fx-background-color: red;
-fx-hGap: 20;
}
.stackPane{
-fx-background-color: orange;
}
.label {
-fx-background-color: blue;
}
如果我通过以下方式更改MoveTo和LineTo的参数,我可以实现我想要的动画,但我不明白为什么:

    double oldMinX = grid.getChildren().get(3).getLayoutX() -185;
    double oldMinY = grid.getChildren().get(3).getLayoutY()+ grid.getChildren().get(3).getBoundsInLocal().getHeight()/2 ;
    double newMinX = grid.getChildren().get(1).getLayoutX()-255 ;
    double newMinY = grid.getChildren().get(1).getLayoutY() + grid.getChildren().get(0).getBoundsInLocal().getHeight()/2 ;
我想这是因为转换使用的坐标系与场景不同,但我找不到任何解释:(有人能给我一些提示吗?
提前非常感谢。

我意识到我不应该使用GridPane。如果我不使用容器,那么转换就可以正常工作

    double oldMinX = grid.getChildren().get(3).getLayoutX() -185;
    double oldMinY = grid.getChildren().get(3).getLayoutY()+ grid.getChildren().get(3).getBoundsInLocal().getHeight()/2 ;
    double newMinX = grid.getChildren().get(1).getLayoutX()-255 ;
    double newMinY = grid.getChildren().get(1).getLayoutY() + grid.getChildren().get(0).getBoundsInLocal().getHeight()/2 ;