2017-04-20 15 views
0

SceneBuilderで中心にないラインを回転させることは可能です(可能な場合)手伝ってくれてありがとう。 RotateTransitionピボット周りに線を回転させますか? SceneBuilder JavaFx

@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(); 
    } 
+0

この[回転変換デモアプリケーション](https://gist.github.com/jewelsea/1475424)を参照してください。そこに例示されているコンセプトが役に立ちます。 – jewelsea

答えて

0

は、あなたがのangleプロパティをアニメーション化するTimelineを使用することができ

今のところ、このコードを使用してイムが、ピボットは、中心にありますa Rotate transformは、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(); 
} 
+0

こんにちは、netbeansは、タイムラインの行に "KeyValueは抽象的な、インスタンス化できません"というこのエラーを報告します –

+0

javafx.animation.KeyValueのインポートで解決されました。 P –

+0

@FrancescoValla期待される結果との違いを説明できますか?階層はどのように見えますか(たとえば、グループとして親を使用していますか?) – fabian

0

セット軸:

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

関連する問題