围绕枢轴旋转线?场景生成器JavaFx

Rotate Line around a pivot? SceneBuilder JavaFx

使用 SceneBuilder 可以不在中心而是在不同的轴上旋转一条线,如果可能的话,怎么做?感谢您的帮助。

我现在使用此代码,但枢轴位于中心:

@FXML
private Line lancettaQuadroCentrale;

@FXML

private void handleButtonAction(ActionEvent event) {
        System.out.println("You clicked me!");        
        RotateTransition rt = new RotateTransition(Duration.seconds(4),lancettaQuadroCentrale);
        rt.setByAngle(0);
        rt.setToAngle(220);
        rt.setCycleCount(Timeline.INDEFINITE);
            rt.setAutoReverse(true);
        rt.play();
    }

设置轴RotateTransition:

rt.setAxis(new Point3D(10, 0, 0));

您可以使用 Timelinea Rotate transformangle 属性 应用动画 Line:

@FXML
private void handleButtonAction() {
    System.out.println("You clicked me!");

    Rotate rotate = new Rotate(0, pivotX, pivotY);

    lancettaQuadroCentrale.getTransforms().add(rotate);

    Timeline timeline = new Timeline(new KeyFrame(Duration.ZERO, new KeyValue(rotate.angleProperty(), 0d)),
                                     new KeyFrame(Duration.seconds(4), new KeyValue(rotate.angleProperty(), 220d)));      

    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.setAutoReverse(true);

    timeline.play();
}