Java Code Examples for javafx.scene.Parent#setTranslateY()

The following examples show how to use javafx.scene.Parent#setTranslateY() . 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: DesktopApp.java    From FXTutorials with MIT License 6 votes vote down vote up
DesktopWindow(Parent root) {
    setBackground(new Background(new BackgroundFill(Color.BLUE, null, null)));

    root.setTranslateY(15);

    setOnMousePressed(e -> {
        offsetX = e.getX();
        offsetY = e.getY();
    });

    setOnMouseDragged(e -> {
        if (e.getButton() != MouseButton.PRIMARY)
            return;

        setTranslateX(e.getSceneX() - offsetX);
        setTranslateY(e.getSceneY() - offsetY);
    });

    getChildren().add(root);
}
 
Example 2
Source File: RadialMenu.java    From Enzo with Apache License 2.0 6 votes vote down vote up
public void show() {
    if (options.isButtonHideOnSelect() && mainMenuButton.getOpacity() > 0) {
        return;
    }

    if (options.isButtonHideOnSelect() || mainMenuButton.getOpacity() == 0) {
        mainMenuButton.setScaleX(1.0);
        mainMenuButton.setScaleY(1.0);
        cross.setRotate(0);
        mainMenuButton.setRotate(0);

        FadeTransition buttonFadeIn = new FadeTransition();
        buttonFadeIn.setNode(mainMenuButton);
        buttonFadeIn.setDuration(Duration.millis(200));
        buttonFadeIn.setToValue(options.getButtonAlpha());
        buttonFadeIn.play();
    }
    for (Parent node : items.keySet()) {
        node.setScaleX(1.0);
        node.setScaleY(1.0);
        node.setTranslateX(0);
        node.setTranslateY(0);
        node.setRotate(0);
    }
}
 
Example 3
Source File: DataAppPreloader.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override public void handleApplicationNotification(PreloaderNotification info) {
    if (info instanceof PreloaderHandoverEvent) {
        // handover from preloader to application
        final PreloaderHandoverEvent event = (PreloaderHandoverEvent)info;
        final Parent appRoot = event.getRoot();
        // remove race track
        root.getChildren().remove(raceTrack);
        // stop simulating progress
        simulatorTimeline.stop();
        // apply application stylsheet to scene
        preloaderScene.getStylesheets().setAll(event.getCssUrl());
        // enable caching for smooth fade
        appRoot.setCache(true);
        // make hide appRoot then add it to scene
        appRoot.setTranslateY(preloaderScene.getHeight());
        root.getChildren().add(1,appRoot);
        // animate fade in app content
        Timeline fadeOut = new Timeline();
        fadeOut.getKeyFrames().addAll(
            new KeyFrame(
                Duration.millis(1000), 
                new KeyValue(appRoot.translateYProperty(), 0, Interpolator.EASE_OUT)
            ),
            new KeyFrame(
                Duration.millis(1500), 
                new EventHandler<ActionEvent>() {
                    @Override public void handle(ActionEvent t) {
                        // turn off cache as not need any more
                        appRoot.setCache(false);
                        // done animation so start loading data
                        for (Runnable task: event.getDataLoadingTasks()) {
                            Platform.runLater(task);
                        }
                    }
                }
            )
        );
        fadeOut.play();
    }
}
 
Example 4
Source File: DataAppPreloader.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override public void handleApplicationNotification(PreloaderNotification info) {
    if (info instanceof PreloaderHandoverEvent) {
        // handover from preloader to application
        final PreloaderHandoverEvent event = (PreloaderHandoverEvent)info;
        final Parent appRoot = event.getRoot();
        // remove race track
        root.getChildren().remove(raceTrack);
        // stop simulating progress
        simulatorTimeline.stop();
        // apply application stylsheet to scene
        preloaderScene.getStylesheets().setAll(event.getCssUrl());
        // enable caching for smooth fade
        appRoot.setCache(true);
        // make hide appRoot then add it to scene
        appRoot.setTranslateY(preloaderScene.getHeight());
        root.getChildren().add(1,appRoot);
        // animate fade in app content
        Timeline fadeOut = new Timeline();
        fadeOut.getKeyFrames().addAll(
            new KeyFrame(
                Duration.millis(1000), 
                new KeyValue(appRoot.translateYProperty(), 0, Interpolator.EASE_OUT)
            ),
            new KeyFrame(
                Duration.millis(1500), 
                new EventHandler<ActionEvent>() {
                    @Override public void handle(ActionEvent t) {
                        // turn off cache as not need any more
                        appRoot.setCache(false);
                        // done animation so start loading data
                        for (Runnable task: event.getDataLoadingTasks()) {
                            Platform.runLater(task);
                        }
                    }
                }
            )
        );
        fadeOut.play();
    }
}
 
Example 5
Source File: Curbstone3D.java    From SmartCity-ParkingManagement with Apache License 2.0 5 votes vote down vote up
@Override
public void start(final Stage s) throws Exception {
	s.setTitle("Curbstone 3D");
	final Curbstone c = new Curbstone(50, Color.web("#DC143C"), 1);
	c.setTranslateX(0);
	c.rx.setAngle(25);
	c.ry.setAngle(45);

	final Timeline animation = new Timeline();
	animation.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, new KeyValue(c.ry.angleProperty(), 0d)),
			new KeyFrame(Duration.valueOf("20000ms"), new KeyValue(c.ry.angleProperty(), 360d)));
	animation.setCycleCount(Animation.INDEFINITE);
	// create root group
	final Parent root = c;
	// translate and rotate group so that origin is center and +Y is up
	root.setTranslateX(200);
	root.setTranslateY(75);
	final Line line = new Line(200, 200, 200, 200);
	final Rotate rotation = new Rotate(1, Rotate.Y_AXIS);
	rotation.pivotXProperty().bind(line.startXProperty());
	rotation.pivotYProperty().bind(line.startYProperty());
	root.getTransforms().add(rotation);
	// create scene
	final Scene scene = new Scene(root, 400, 150);
	scene.setCamera(new PerspectiveCamera());
	s.setScene(scene);
	s.show();
	// start spining animation
	animation.play();
}