Java 类javafx.scene.Camera 实例源码

项目:eavp    文件:FXCameraAttachmentTester.java   
/**
 * 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));
}
项目:eavp    文件:FXViewer.java   
/**
 * @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;
}
项目:eavp    文件:CenteredCameraController.java   
/**
 * 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);

}
项目:eavp    文件:FXMeshViewer.java   
@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;
}
项目:JVx.javafx    文件:FXAnimator.java   
/**
 * 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;
}
项目:openjfx-8u-dev-tests    文件:PerspectiveCameraFixedEyeAsChildTestApp.java   
@Override
protected Camera addCamera(Scene scene) {
    camera = cam = new PerspectiveCamera(true);
    scene.setCamera(camera);
    camera.setFarClip(10000);
    return camera;
}
项目:openjfx-8u-dev-tests    文件:PerspectiveCameraFixedEyeIsolateTestApp.java   
@Override
protected Camera addCamera(Scene scene) {
    camera = cam = new PerspectiveCamera(true);
    scene.setCamera(camera);
    camera.setFarClip(10000);
    return camera;
}
项目:openjfx-8u-dev-tests    文件:SubScenePerspectiveCameraFixedEyeIsolateTestApp.java   
@Override
protected Camera addCamera(SubScene scene) {
    PerspectiveCamera pc = new PerspectiveCamera(true);
    scene.setCamera(pc);
    pc.setFarClip(10000);
    return pc;
}
项目:openjfx-8u-dev-tests    文件:SubScenePerspectiveCameraFixedEyeAsChildTestApp.java   
@Override
protected Camera addCamera(SubScene scene) {
    PerspectiveCamera pc = new PerspectiveCamera(true);
    scene.setCamera(pc);
    pc.setFarClip(10000);
    return pc;
}
项目:eavp    文件:FXGeometryViewer.java   
@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;

}
项目:javafx-dpi-scaling    文件:AdjusterTest.java   
@Test
public void testGetCameraAdjuster() {
    Adjuster adjuster = Adjuster.getAdjuster(Camera.class);

    assertThat(adjuster, is(instanceOf(NodeAdjuster.class)));
    assertThat(adjuster.getNodeClass(), is(sameInstance(Node.class)));
}
项目:exchange    文件:Notification.java   
@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();
    }
}
项目:exchange    文件:PeerInfoWithTagEditor.java   
@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();
    }
}
项目:openjfx-8u-dev-tests    文件:MeshFixedEyePickingTestApp.java   
@Override
protected Camera buildCamera() {
    PerspectiveCamera cam = new PerspectiveCamera(true);
    cam.setFarClip(SCALE * 30);
    return cam;
}
项目:openjfx-8u-dev-tests    文件:ShapesFixedEyePickingTestApp.java   
@Override
protected Camera buildCamera() {
    PerspectiveCamera cam = new PerspectiveCamera(true);
    cam.setFarClip(SCALE * 25);
    return cam;
}
项目:openjfx-8u-dev-tests    文件:MeshPerspectivePickingTestApp.java   
@Override
protected Camera buildCamera() {
    return new PerspectiveCamera();
}
项目:openjfx-8u-dev-tests    文件:ShapesPerspectivePickingTestApp.java   
@Override
protected Camera buildCamera() {
    return new PerspectiveCamera();
}
项目:openjfx-8u-dev-tests    文件:ShapesParallelPickingTestApp.java   
@Override
protected Camera buildCamera() {
    return new ParallelCamera();
}
项目:openjfx-8u-dev-tests    文件:MeshParallelPickingTestApp.java   
@Override
protected Camera buildCamera() {
    return new ParallelCamera();
}
项目:openjfx-8u-dev-tests    文件:PerspectiveLodGroupTestApp.java   
@Override
protected Camera addCamera(Scene scene) {
    PerspectiveCamera pc = new PerspectiveCamera(false);
    scene.setCamera(pc);
    return pc;
}
项目:openjfx-8u-dev-tests    文件:PerspectiveLodCameraTestApp.java   
@Override
protected Camera addCamera(Scene scene) {
    PerspectiveCamera pc = new PerspectiveCamera(false);
    scene.setCamera(pc);
    return pc;
}
项目:openjfx-8u-dev-tests    文件:ParallelLodGroupTestApp.java   
@Override
protected Camera addCamera(Scene scene) {
    ParallelCamera pc = new ParallelCamera();
    scene.setCamera(pc);
    return pc;
}
项目:openjfx-8u-dev-tests    文件:ParallelLodCameraTestApp.java   
@Override
protected Camera addCamera(Scene scene) {
    ParallelCamera pc = new ParallelCamera();
    scene.setCamera(pc);
    return pc;
}
项目:openjfx-8u-dev-tests    文件:PerspectiveCameraAsChildTestApp.java   
@Override
protected Camera addCamera(Scene scene) {
    camera = cam = new PerspectiveCamera(false);
    scene.setCamera(camera);
    return camera;
}
项目:openjfx-8u-dev-tests    文件:PerspectiveCameraIsolateTestApp.java   
@Override
protected Camera addCamera(Scene scene) {
    camera  = cam = new PerspectiveCamera(false);
    scene.setCamera(camera);
    return camera;
}
项目:openjfx-8u-dev-tests    文件:ParallelCameraAsChildTestApp.java   
@Override
protected Camera addCamera(Scene scene) {
    ParallelCamera parallelCamera = new ParallelCamera();
    scene.setCamera(parallelCamera);
    return parallelCamera;
}
项目:openjfx-8u-dev-tests    文件:ParallelCameraIsolateTestApp.java   
@Override
protected Camera addCamera(Scene scene) {
    ParallelCamera parallelCamera = new ParallelCamera();
    scene.setCamera(parallelCamera);
    return parallelCamera;
}
项目:openjfx-8u-dev-tests    文件:CameraIsolateAbstractApp.java   
@Override
public Camera getCamera() {
    return camera;
}
项目:openjfx-8u-dev-tests    文件:ShapesTestCase.java   
public Camera addCamera(Scene scene) {
    PerspectiveCamera perspectiveCamera = new PerspectiveCamera(false);
    scene.setCamera(perspectiveCamera);
    return perspectiveCamera;
}
项目:openjfx-8u-dev-tests    文件:ShapesTestCase.java   
public Camera addCamera(SubScene scene) {
    PerspectiveCamera perspectiveCamera = new PerspectiveCamera(false);
    scene.setCamera(perspectiveCamera);
    return perspectiveCamera;
}
项目:openjfx-8u-dev-tests    文件:PickingTestCase.java   
public Camera getCamera() {
    return camera;
}
项目:openjfx-8u-dev-tests    文件:SubScenePerspectiveCameraAsChildTestApp.java   
@Override
protected Camera addCamera(SubScene scene) {
    PerspectiveCamera camera = new PerspectiveCamera(false);
    scene.setCamera(camera);
    return camera;
}
项目:openjfx-8u-dev-tests    文件:SubScenePerspectiveCameraIsolateTestApp.java   
@Override
protected Camera addCamera(SubScene scene) {
    PerspectiveCamera camera = new PerspectiveCamera(false);
    scene.setCamera(camera);
    return camera;
}
项目:openjfx-8u-dev-tests    文件:SubSceneParallelCameraAsChildTestApp.java   
@Override
protected Camera addCamera(SubScene scene) {
    ParallelCamera parallelCamera = new ParallelCamera();
    scene.setCamera(parallelCamera);
    return parallelCamera;
}
项目:openjfx-8u-dev-tests    文件:SubSceneParallelCameraIsolateTestApp.java   
@Override
protected Camera addCamera(SubScene scene) {
    ParallelCamera camera = new ParallelCamera();
    scene.setCamera(camera);
    return camera;
}
项目:openjfx-8u-dev-tests    文件:SubSceneCameraIsolateAbstractApp.java   
@Override
public Camera getCamera() {
    return bindedCamera;
}
项目:openjfx-8u-dev-tests    文件:SubSceneBasicPropsTestApp.java   
private boolean reinitCamera(SubScene ss) {
    Camera cam = ss.getCamera();
    ss.setCamera(new PerspectiveCamera());
    return cam != ss.getCamera();
}
项目:openjfx-8u-dev-tests    文件:MultipleLightingTestApp.java   
private Camera addCamera(Scene scene) {
    ParallelCamera pc = new ParallelCamera();
    scene.setCamera(pc);
    return pc;
}
项目:openjfx-8u-dev-tests    文件:SingleLightingTestApp.java   
private Camera addCamera(Scene scene) {
    ParallelCamera pc = new ParallelCamera();
    scene.setCamera(pc);
    return pc;
}
项目:openjfx-8u-dev-tests    文件:CameraIsolateTests.java   
@Override
public Camera getCamera() {
    throw new UnsupportedOperationException("This method should never be used.");
}