Search in sources :

Example 6 with KeyFrame

use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.

the class MainController method setTool.

// Displays a new tool and applies the slide transitions
public void setTool(Integer id) {
    // check if existing animation running
    if (timeline != null) {
        nextTool = screens.get(id);
        timeline.setRate(4);
        return;
    } else {
        nextTool = null;
    }
    // load new content
    sparePane.getChildren().setAll(screens.get(id));
    sparePane.setCache(true);
    currentPane.setCache(true);
    // wait one pulse then animate
    Platform.runLater(() -> {
        // animate switch
        if (id > currentToolIndex) {
            // animate from bottom
            currentToolIndex = id;
            sparePane.setTranslateY(rootContainer.getHeight());
            sparePane.setVisible(true);
            timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(currentPane.translateYProperty(), 0, INTERPOLATOR), new KeyValue(sparePane.translateYProperty(), rootContainer.getHeight(), INTERPOLATOR)), new KeyFrame(Duration.millis(800), animationEndEventHandler, new KeyValue(currentPane.translateYProperty(), -rootContainer.getHeight(), INTERPOLATOR), new KeyValue(sparePane.translateYProperty(), 0, INTERPOLATOR)));
            timeline.play();
        } else {
            // from top
            currentToolIndex = id;
            sparePane.setTranslateY(-rootContainer.getHeight());
            sparePane.setVisible(true);
            timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(currentPane.translateYProperty(), 0, INTERPOLATOR), new KeyValue(sparePane.translateYProperty(), -rootContainer.getHeight(), INTERPOLATOR)), new KeyFrame(Duration.millis(800), animationEndEventHandler, new KeyValue(currentPane.translateYProperty(), rootContainer.getHeight(), INTERPOLATOR), new KeyValue(sparePane.translateYProperty(), 0, INTERPOLATOR)));
            timeline.play();
        }
    });
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 7 with KeyFrame

use of javafx.animation.KeyFrame in project Smartcity-Smarthouse by TechnionYP5777.

the class StoveAppController method turnOn.

public void turnOn() {
    if (isOn)
        return;
    isOn = !isOn;
    timeline = new Timeline(new KeyFrame(Duration.millis(100), ¢ -> {
        time = time.add(((KeyFrame) ¢.getSource()).getTime());
        timeSeconds.set(time.toSeconds());
        timeLabel.setText("The stove is running for: " + timeSeconds.get() + " (Secs)");
        if (timeSeconds.get() <= StoveAppController.this.get_alert_seconds())
            alertTime = false;
        if (timeSeconds.get() > StoveAppController.this.get_alert_seconds() && !alertTime) {
            alert("Stove is running too long");
            timeLabel.setTextFill(Color.RED);
            alertTime = true;
        }
    }));
    timeline.setCycleCount(Animation.INDEFINITE);
    timeline.play();
}
Also used : Timeline(javafx.animation.Timeline) KeyFrame(javafx.animation.KeyFrame)

Example 8 with KeyFrame

use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.

the class RotateOutUpRightTransition method starting.

@Override
protected void starting() {
    super.starting();
    rotate = new Rotate(0, node.getBoundsInLocal().getWidth(), node.getBoundsInLocal().getHeight());
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(rotate.angleProperty(), 0, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(rotate.angleProperty(), 90, WEB_EASE)));
    node.getTransforms().add(rotate);
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) Rotate(javafx.scene.transform.Rotate) KeyFrame(javafx.animation.KeyFrame)

Example 9 with KeyFrame

use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.

the class HingeTransition method starting.

@Override
protected void starting() {
    super.starting();
    double endY = node.getScene().getHeight() - node.localToScene(0, 0).getY();
    rotate = new Rotate(0, 0, 0);
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(rotate.angleProperty(), 0, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(200), new KeyValue(rotate.angleProperty(), 80, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(400), new KeyValue(rotate.angleProperty(), 60, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(600), new KeyValue(rotate.angleProperty(), 80, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(800), new KeyValue(node.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(node.translateYProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(rotate.angleProperty(), 60, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(node.translateYProperty(), endY, Interpolator.EASE_BOTH), new KeyValue(rotate.angleProperty(), 60, Interpolator.EASE_BOTH)));
    node.getTransforms().add(rotate);
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) Rotate(javafx.scene.transform.Rotate) KeyFrame(javafx.animation.KeyFrame)

Example 10 with KeyFrame

use of javafx.animation.KeyFrame in project fxexperience2 by EricCanull.

the class RollInTransition method starting.

@Override
protected void starting() {
    super.starting();
    timeline = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, WEB_EASE), new KeyValue(node.translateXProperty(), -node.getBoundsInLocal().getWidth(), WEB_EASE), new KeyValue(node.rotateProperty(), -120, WEB_EASE)), new KeyFrame(Duration.millis(1000), new KeyValue(node.opacityProperty(), 1, WEB_EASE), new KeyValue(node.translateXProperty(), 0, WEB_EASE), new KeyValue(node.rotateProperty(), 0, WEB_EASE)));
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Aggregations

KeyFrame (javafx.animation.KeyFrame)232 Timeline (javafx.animation.Timeline)197 KeyValue (javafx.animation.KeyValue)150 ActionEvent (javafx.event.ActionEvent)66 FXML (javafx.fxml.FXML)54 Duration (javafx.util.Duration)48 EventHandler (javafx.event.EventHandler)43 Stage (javafx.stage.Stage)40 Alert (javafx.scene.control.Alert)35 Rotate (javafx.scene.transform.Rotate)26 IOException (java.io.IOException)25 URL (java.net.URL)24 ResourceBundle (java.util.ResourceBundle)24 Initializable (javafx.fxml.Initializable)23 Interpolator (javafx.animation.Interpolator)22 JFXButton (com.jfoenix.controls.JFXButton)21 FXMLLoader (javafx.fxml.FXMLLoader)21 MouseEvent (javafx.scene.input.MouseEvent)18 Pane (javafx.scene.layout.Pane)18 Node (javafx.scene.Node)17