是否可以在调用时分离方法?所以我们不在线调用那些方法吗?我的意思是下面的代码段:

//configure path transition and run it
 PathTransition pathTransition = PathTransitionBuilder.create()
            .duration(Duration.seconds(6))
            .path(path)
            .node(rect)
            .orientation(OrientationType.ORTHOGONAL_TO_TANGENT)
            .cycleCount(Timeline.INDEFINITE)
            .autoReverse(false)
            .build();
    pathTransition.play();

最佳答案

发生的情况是这些方法中的每一个实际上都返回该方法所在的对象,这允许随后进行另一个方法调用。

PathTransition pathTransition = PathTransitionBuilder.create()
        .duration(Duration.seconds(6))
        .path(path)
        .node(rect)
        .orientation(OrientationType.ORTHOGONAL_TO_TANGENT)
        .cycleCount(Timeline.INDEFINITE)
        .autoReverse(false)
        .build();


是相同的:

PathTransitionBuilder pathTransitionBuilder = PathTransitionBuilder.create();
pathTransitionBuilder .duration(Duration.seconds(6));
pathTransitionBuilder .path(path);
pathTransitionBuilder .node(rect);
pathTransitionBuilder .orientation(OrientationType.ORTHOGONAL_TO_TANGENT);
pathTransitionBuilder .cycleCount(Timeline.INDEFINITE);
pathTransitionBuilder .autoReverse(false);
PathTransition pathTransition = pathTransitionBuilder.build();

10-04 18:45