/** * Check that the camera is added to the parent INode's JavaFX node * correctly. */ @Test public void checkCamera() { // Create a camera, an attachment containing that camera, and the node Camera camera = new PerspectiveCamera(); FXCameraAttachment attachment = new FXCameraAttachment(camera); GNode node = new GNode(); Group fxNode = new Group(); node.setProperty(INode.RENDERER_NODE_PROP, fxNode); // Check that the attachment has the camera assertTrue(attachment.getFxCamera() == camera); // Attach to the node and check that the camera has been added to the // JavaFX node attachment.attach(node); assertTrue(Util.getFxGroup(node).getChildren().contains(camera)); // Detach from the node and check that the camera has been removed from // the JavaFX node. attachment.detach(node); assertFalse(Util.getFxGroup(node).getChildren().contains(camera)); }
/** * @see BasicViewer#updateCamera(ICamera) */ @Override protected void updateCamera(ICamera camera) { if (!(camera instanceof FXCameraAttachment)) { throw new IllegalArgumentException( Messages.FXGeometryViewer_InvalidCamera); } FXCameraAttachment attachment = (FXCameraAttachment) camera; Camera fxCamera = attachment.getFxCamera(); if (fxCamera == null) { throw new NullPointerException( Messages.FXGeometryViewer_NullCamera); } cameraController = new CenteredCameraController(fxCamera, scene, fxCanvas); scene.setCamera(fxCamera); defaultCamera = fxCamera; }
/** * The default constructor. * * @param camera * The camera this controller will manage. * @param scene * The scene the camera is viewing. * @param canvas * The FXCanvas containing the scene. */ public CenteredCameraController(Camera camera, Scene scene, FXCanvas canvas) { super(camera, scene, canvas); // Initialize the data members dragStarted = false; shouldInvertX = false; shouldInvertY = false; // Set the x axis rotation for the affine transformation x = new Rotate(); x.setAxis(Rotate.X_AXIS); // Set the y axis rotation for the affine transformation y = new Rotate(); y.setAxis(Rotate.Y_AXIS); // Set the y axis rotation for the affine transformation z = new Rotate(); z.setAxis(Rotate.Z_AXIS); // Apply the rotations and the affine to the camera xform.getTransforms().setAll(x, y, z, affine); }
@Override protected void updateCamera(ICamera camera) { if (!(camera instanceof FXCameraAttachment)) { throw new IllegalArgumentException( "Invalid camera attached to Mesh Viewer."); } FXCameraAttachment attachment = (FXCameraAttachment) camera; Camera fxCamera = attachment.getFxCamera(); if (fxCamera == null) { throw new NullPointerException( "No camera was attached to Mesh Viewer"); } cameraController = new TopDownCameraController(fxCamera, scene, fxCanvas); // scene.setCamera(fxCamera); scene.setCamera(null); subScene.setCamera(fxCamera); defaultCamera = fxCamera; }
/** * Calculates the angle needed for the given {@link Node} to be edge-on with * the user. * * @param pNode the {@link Node}. * @param pOrientation the {@link Orientation}. * @return the angle needed for the {@link Node} the be viewed edge-on. */ public static double calculateEdgeAngle(Node pNode, Orientation pOrientation) { Scene scene = pNode.getScene(); Camera camera = scene.getCamera(); if (camera instanceof PerspectiveCamera) { PerspectiveCamera perspectiveCamera = (PerspectiveCamera)camera; double distanceFromCenter = getDistanceFromCenter(scene, pNode, pOrientation); double rotationFromCenter = getAngleFromCenter(scene, perspectiveCamera, distanceFromCenter); return 90 - rotationFromCenter; } return 90; }
@Override protected Camera addCamera(Scene scene) { camera = cam = new PerspectiveCamera(true); scene.setCamera(camera); camera.setFarClip(10000); return camera; }
@Override protected Camera addCamera(SubScene scene) { PerspectiveCamera pc = new PerspectiveCamera(true); scene.setCamera(pc); pc.setFarClip(10000); return pc; }
@Override protected void updateCamera(ICamera camera) { // Check the camera attachment for validity if (!(camera instanceof FXCameraAttachment)) { throw new IllegalArgumentException( "Invalid camera attached to Mesh Viewer."); } // Cast the camera attachment and check that it has a camera FXCameraAttachment attachment = (FXCameraAttachment) camera; Camera fxCamera = attachment.getFxCamera(); if (fxCamera == null) { throw new NullPointerException( "No camera was attached to Mesh Viewer"); } // Create a controller cameraController = new CenteredCameraController(fxCamera, scene, fxCanvas); // Set the camera on the scene scene.setCamera(null); subScene.setCamera(fxCamera); defaultCamera = fxCamera; }
@Test public void testGetCameraAdjuster() { Adjuster adjuster = Adjuster.getAdjuster(Camera.class); assertThat(adjuster, is(instanceOf(NodeAdjuster.class))); assertThat(adjuster.getNodeClass(), is(sameInstance(Node.class))); }
@Override protected void animateHide(Runnable onFinishedHandler) { if (autoCloseTimer != null) { autoCloseTimer.stop(); autoCloseTimer = null; } if (NotificationCenter.useAnimations) { double duration = getDuration(400); Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); gridPane.setRotationAxis(Rotate.X_AXIS); Camera camera = gridPane.getScene().getCamera(); gridPane.getScene().setCamera(new PerspectiveCamera()); Timeline timeline = new Timeline(); ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames(); keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.rotateProperty(), 0, interpolator), new KeyValue(gridPane.opacityProperty(), 1, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.rotateProperty(), -90, interpolator), new KeyValue(gridPane.opacityProperty(), 0, interpolator) )); timeline.setOnFinished(event -> { gridPane.setRotate(0); gridPane.setRotationAxis(Rotate.Z_AXIS); gridPane.getScene().setCamera(camera); onFinishedHandler.run(); }); timeline.play(); } else { onFinishedHandler.run(); } }
@Override protected void animateHide(Runnable onFinishedHandler) { if (GlobalSettings.getUseAnimations()) { double duration = getDuration(300); Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); gridPane.setRotationAxis(Rotate.X_AXIS); Camera camera = gridPane.getScene().getCamera(); gridPane.getScene().setCamera(new PerspectiveCamera()); Timeline timeline = new Timeline(); ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames(); keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.rotateProperty(), 0, interpolator), new KeyValue(gridPane.opacityProperty(), 1, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.rotateProperty(), -90, interpolator), new KeyValue(gridPane.opacityProperty(), 0, interpolator) )); timeline.setOnFinished(event -> { gridPane.setRotate(0); gridPane.setRotationAxis(Rotate.Z_AXIS); gridPane.getScene().setCamera(camera); onFinishedHandler.run(); }); timeline.play(); } else { onFinishedHandler.run(); } }
@Override protected Camera buildCamera() { PerspectiveCamera cam = new PerspectiveCamera(true); cam.setFarClip(SCALE * 30); return cam; }
@Override protected Camera buildCamera() { PerspectiveCamera cam = new PerspectiveCamera(true); cam.setFarClip(SCALE * 25); return cam; }
@Override protected Camera buildCamera() { return new PerspectiveCamera(); }
@Override protected Camera buildCamera() { return new ParallelCamera(); }
@Override protected Camera addCamera(Scene scene) { PerspectiveCamera pc = new PerspectiveCamera(false); scene.setCamera(pc); return pc; }
@Override protected Camera addCamera(Scene scene) { ParallelCamera pc = new ParallelCamera(); scene.setCamera(pc); return pc; }
@Override protected Camera addCamera(Scene scene) { camera = cam = new PerspectiveCamera(false); scene.setCamera(camera); return camera; }
@Override protected Camera addCamera(Scene scene) { ParallelCamera parallelCamera = new ParallelCamera(); scene.setCamera(parallelCamera); return parallelCamera; }
@Override public Camera getCamera() { return camera; }
public Camera addCamera(Scene scene) { PerspectiveCamera perspectiveCamera = new PerspectiveCamera(false); scene.setCamera(perspectiveCamera); return perspectiveCamera; }
public Camera addCamera(SubScene scene) { PerspectiveCamera perspectiveCamera = new PerspectiveCamera(false); scene.setCamera(perspectiveCamera); return perspectiveCamera; }
public Camera getCamera() { return camera; }
@Override protected Camera addCamera(SubScene scene) { PerspectiveCamera camera = new PerspectiveCamera(false); scene.setCamera(camera); return camera; }
@Override protected Camera addCamera(SubScene scene) { ParallelCamera parallelCamera = new ParallelCamera(); scene.setCamera(parallelCamera); return parallelCamera; }
@Override protected Camera addCamera(SubScene scene) { ParallelCamera camera = new ParallelCamera(); scene.setCamera(camera); return camera; }
@Override public Camera getCamera() { return bindedCamera; }
private boolean reinitCamera(SubScene ss) { Camera cam = ss.getCamera(); ss.setCamera(new PerspectiveCamera()); return cam != ss.getCamera(); }
private Camera addCamera(Scene scene) { ParallelCamera pc = new ParallelCamera(); scene.setCamera(pc); return pc; }
@Override public Camera getCamera() { throw new UnsupportedOperationException("This method should never be used."); }