javafx.scene.Camera Java Examples

The following examples show how to use javafx.scene.Camera. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Notification.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@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();
    }
}
 
Example #2
Source File: PeerInfoWithTagEditor.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
@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();
    }
}
 
Example #3
Source File: JavaFX3D.java    From JavaFX-Tutorial-Codes with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    Box box = new Box(100, 20, 50);

    SmartGroup group = new SmartGroup();
    group.getChildren().add(box);

    Camera camera = new PerspectiveCamera();
    Scene scene = new Scene(group, WIDTH, HEIGHT);
    scene.setFill(Color.SILVER);
    scene.setCamera(camera);

    group.translateXProperty().set(WIDTH / 2);
    group.translateYProperty().set(HEIGHT / 2);
    group.translateZProperty().set(-1500);

    initMouseControl(group, scene);

    primaryStage.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
        switch (event.getCode()) {
            case W:
                group.translateZProperty().set(group.getTranslateZ() + 100);
                break;
            case S:
                group.translateZProperty().set(group.getTranslateZ() - 100);
                break;
            case Q:
                group.rotateByX(10);
                break;
            case E:
                group.rotateByX(-10);
                break;
            case NUMPAD6:
                group.rotateByY(10);
                break;
            case NUMPAD4:
                group.rotateByY(-10);
                break;
        }
    });

    primaryStage.setTitle("Genuine Coder");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example #4
Source File: MqttListener.java    From diozero with MIT License 4 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
	primaryStage.setResizable(false);
	Scene scene = new Scene(root, 1024, 800, true);
	
	// Create and position camera
	Camera camera = new PerspectiveCamera();
	camera.getTransforms().addAll(
			new Rotate(0, Rotate.Y_AXIS),
			new Rotate(0, Rotate.X_AXIS),
			new Translate(-500, -425, 1200));
	scene.setCamera(camera);
	scene.setFill(Paint.valueOf(Color.BLACK.toString()));
	
	// Box
	testObject = new Cylinder(10, 50);
	testObject.setMaterial(new PhongMaterial(Color.RED));
	testObject.getTransforms().addAll(new Translate(50, 0, 0));
	
	TdsModelImporter model_importer = new TdsModelImporter();
	model_importer.read(getClass().getResource("/models/SpaceLaunchSystem.3DS"));
	Node[] nodes = model_importer.getImport();
	model_importer.close();
	Group rocket = new Group(nodes);
	rocket.getTransforms().addAll(new Translate(0, 25, 0));

	// Build the Scene Graph
	root.getChildren().addAll(testObject, rocket);

	primaryStage.setScene(scene);
	primaryStage.show();
	
	primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
		@Override
		public void handle(WindowEvent event) {
			System.out.println(event);
			if (event.getEventType().equals(WindowEvent.WINDOW_CLOSE_REQUEST)) {
				System.exit(0);
			}
		}
	});
	
	mqttClient.subscribe(MQTT_TOPIC_IMU + "/#");
}