/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import javafx.animation.Interpolator; import javafx.animation.RotateTransitionBuilder; import javafx.animation.Transition; import javafx.application.Application; import javafx.event.Event; import javafx.event.EventHandler; import javafx.event.EventType; import javafx.geometry.BoundingBox; import javafx.geometry.Point3D; import javafx.scene.Group; import javafx.scene.PerspectiveCamera; import javafx.scene.Scene; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; import javafx.scene.shape.Ellipse; import javafx.scene.transform.Rotate; import javafx.stage.Stage; import javafx.util.Duration; /** * * @author cyang */ public class Bug extends Application{ @Override public void start(Stage primaryStage) { final Ellipse ellipse = new Ellipse(250, 250, 500, 250); ellipse.setScaleX(0.1); ellipse.setScaleY(0.1); // ellipse.getTransforms().add(new Rotate(45, 0, 20, 20, Rotate.Y_AXIS)); // ellipse.setRotate(45); // ellipse.setRotationAxis(Rotate.Y_AXIS); Group root = new Group(ellipse); root.setTranslateX(2.0); Scene scene = new Scene(root, 500, 500); scene.setCamera(new PerspectiveCamera()); primaryStage.setScene(scene); primaryStage.show(); RotateTransitionBuilder.create() .node(root) .byAngle(360) .duration(Duration.seconds(5)) .axis(new Point3D(1, 0, 0)) // .axis(new Point3D(1, 1, -1)) .interpolator(Interpolator.LINEAR) .cycleCount(Transition.INDEFINITE) .build().play(); scene.addEventFilter(MouseEvent.MOUSE_CLICKED, new EventHandler() { @Override public void handle(MouseEvent t) { System.out.println("Zero Volume bounds: " + ellipse.localToScene(new BoundingBox(0, 0, 0, 0, 0, 0))); System.out.println("Unit Volume bounds: " + ellipse.localToScene(new BoundingBox(0, 0, 0, 0, 0, 1))); System.out.println("Zero Volume bounds: " + ellipse.sceneToLocal(new BoundingBox(0, 0, 0, 0, 0, 0))); System.out.println("Unit Volume bounds: " + ellipse.sceneToLocal(new BoundingBox(0, 0, 0, 0, 0, 1))); t.consume(); } }); } public static void main(String[] args) { launch(args); } }