Search in sources :

Example 61 with KeyFrame

use of javafx.animation.KeyFrame in project JFoenix by jfoenixadmin.

the class JFXSnackbar method getTimeline.

private Timeline getTimeline(long timeout) {
    Timeline animation;
    if (timeout <= 0) {
        animation = new Timeline(new KeyFrame(Duration.ZERO, (e) -> popup.toBack(), new KeyValue(popup.visibleProperty(), false, Interpolator.EASE_BOTH), new KeyValue(popup.translateYProperty(), popup.getLayoutBounds().getHeight(), easeInterpolator), new KeyValue(popup.opacityProperty(), 0, easeInterpolator)), new KeyFrame(Duration.millis(10), (e) -> popup.toFront(), new KeyValue(popup.visibleProperty(), true, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(300), new KeyValue(popup.opacityProperty(), 1, easeInterpolator), new KeyValue(popup.translateYProperty(), 0, easeInterpolator)));
        animation.setCycleCount(1);
    } else {
        animation = new Timeline(new KeyFrame(Duration.ZERO, (e) -> popup.toBack(), new KeyValue(popup.visibleProperty(), false, Interpolator.EASE_BOTH), new KeyValue(popup.translateYProperty(), popup.getLayoutBounds().getHeight(), easeInterpolator), new KeyValue(popup.opacityProperty(), 0, easeInterpolator)), new KeyFrame(Duration.millis(10), (e) -> popup.toFront(), new KeyValue(popup.visibleProperty(), true, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(300), new KeyValue(popup.opacityProperty(), 1, easeInterpolator), new KeyValue(popup.translateYProperty(), 0, easeInterpolator)), new KeyFrame(Duration.millis(timeout / 2)));
        animation.setAutoReverse(true);
        animation.setCycleCount(2);
        animation.setOnFinished((e) -> processSnackbars());
    }
    return animation;
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 62 with KeyFrame

use of javafx.animation.KeyFrame in project JFoenix by jfoenixadmin.

the class JFXSpinner method getKeyFrames.

private KeyFrame[] getKeyFrames(double angle, double duration, Color color) {
    KeyFrame[] frames = new KeyFrame[4];
    frames[0] = new KeyFrame(Duration.seconds(duration), new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR), new KeyValue(arc.startAngleProperty(), angle + 45 + getStartingAngle(), Interpolator.LINEAR));
    frames[1] = new KeyFrame(Duration.seconds(duration + 0.4), new KeyValue(arc.lengthProperty(), 250, Interpolator.LINEAR), new KeyValue(arc.startAngleProperty(), angle + 90 + getStartingAngle(), Interpolator.LINEAR));
    frames[2] = new KeyFrame(Duration.seconds(duration + 0.7), new KeyValue(arc.lengthProperty(), 250, Interpolator.LINEAR), new KeyValue(arc.startAngleProperty(), angle + 135 + getStartingAngle(), Interpolator.LINEAR));
    frames[3] = new KeyFrame(Duration.seconds(duration + 1.1), new KeyValue(arc.lengthProperty(), 5, Interpolator.LINEAR), new KeyValue(arc.startAngleProperty(), angle + 435 + getStartingAngle(), Interpolator.LINEAR), new KeyValue(arc.strokeProperty(), color, Interpolator.EASE_BOTH));
    return frames;
}
Also used : KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 63 with KeyFrame

use of javafx.animation.KeyFrame in project JFoenix by jfoenixadmin.

the class JFXTogglePane method updateToggleAnimation.

private void updateToggleAnimation() {
    if (getContentNode() == null)
        return;
    double rateX = this.getWidth() / getClip().getLayoutBounds().getWidth();
    double rateY = this.getHeight() / getClip().getLayoutBounds().getHeight();
    double newRate = Math.max(rateX, rateY) * getScalingFactor();
    double animationRate = toggleAnimation == null ? -1 : toggleAnimation.getRate();
    toggleAnimation = new Timeline(new KeyFrame(Duration.millis(0), new KeyValue(getClip().scaleXProperty(), 1, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(0), new KeyValue(getClip().scaleYProperty(), 1, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(0), new KeyValue(getContentNode().opacityProperty(), 0, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(350), new KeyValue(getClip().scaleXProperty(), newRate, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(350), new KeyValue(getClip().scaleYProperty(), newRate, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(370), new KeyValue(getContentNode().opacityProperty(), 0, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(510), new KeyValue(getContentNode().opacityProperty(), 1, Interpolator.EASE_BOTH)));
    toggleAnimation.setOnFinished((finish) -> {
        if (toggleAnimation.getRate() == 1) {
            this.getClip().scaleXProperty().bind(Bindings.createDoubleBinding(() -> {
                double X = this.getWidth() / getClip().getLayoutBounds().getWidth();
                double Y = this.getHeight() / getClip().getLayoutBounds().getHeight();
                double scale = Math.max(X, Y) * getScalingFactor();
                return scale;
            }, this.widthProperty(), this.heightProperty()));
            this.getClip().scaleYProperty().bind(Bindings.createDoubleBinding(() -> {
                double X = this.getWidth() / getClip().getLayoutBounds().getWidth();
                double Y = this.getHeight() / getClip().getLayoutBounds().getHeight();
                double scale = Math.max(X, Y) * getScalingFactor();
                return scale;
            }, this.widthProperty(), this.heightProperty()));
        }
    });
    toggleAnimation.setRate(animationRate);
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 64 with KeyFrame

use of javafx.animation.KeyFrame in project JFoenix by jfoenixadmin.

the class JFXTreeCell method createSibAnimation.

private Timeline createSibAnimation(TreeCell<?> cell, int index) {
    cell.setTranslateY(((JFXTreeView<T>) getTreeView()).height);
    Timeline f2 = new Timeline(new KeyFrame(Duration.millis(120), new KeyValue(cell.translateYProperty(), 0, Interpolator.EASE_BOTH)));
    return f2;
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 65 with KeyFrame

use of javafx.animation.KeyFrame in project JFoenix by jfoenixadmin.

the class JFXTreeCell method createChildAnimation.

private Timeline createChildAnimation(TreeCell<?> cell, int delay) {
    cell.setOpacity(0);
    cell.setTranslateY(-1);
    Timeline f1 = new Timeline(new KeyFrame(Duration.millis(120), new KeyValue(cell.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(cell.translateYProperty(), 0, Interpolator.EASE_BOTH)));
    f1.setDelay(Duration.millis(20 + delay * 10));
    return f1;
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Aggregations

KeyFrame (javafx.animation.KeyFrame)108 Timeline (javafx.animation.Timeline)107 KeyValue (javafx.animation.KeyValue)82 Duration (javafx.util.Duration)32 ActionEvent (javafx.event.ActionEvent)21 JFXButton (com.jfoenix.controls.JFXButton)20 IOException (java.io.IOException)19 URL (java.net.URL)19 ResourceBundle (java.util.ResourceBundle)19 FXML (javafx.fxml.FXML)19 Initializable (javafx.fxml.Initializable)18 FXMLLoader (javafx.fxml.FXMLLoader)17 AnchorPane (javafx.scene.layout.AnchorPane)16 Pane (javafx.scene.layout.Pane)16 Level (java.util.logging.Level)15 Logger (java.util.logging.Logger)15 MouseEvent (javafx.scene.input.MouseEvent)13 Rotate (javafx.scene.transform.Rotate)13 JFXTextField (com.jfoenix.controls.JFXTextField)12 Interpolator (javafx.animation.Interpolator)12