Search in sources :

Example 46 with KeyValue

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

the class JFXSnackbar method close.

public void close() {
    Timeline animation = new Timeline(new KeyFrame(Duration.ZERO, (e) -> popup.toFront(), new KeyValue(popup.opacityProperty(), 1, easeInterpolator), new KeyValue(popup.translateYProperty(), 0, easeInterpolator)), new KeyFrame(Duration.millis(290), new KeyValue(popup.visibleProperty(), true, Interpolator.EASE_BOTH)), new KeyFrame(Duration.millis(300), (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)));
    animation.setCycleCount(1);
    animation.setOnFinished((e) -> processSnackbars());
    animation.play();
}
Also used : EventHandler(javafx.event.EventHandler) ButtonType(com.jfoenix.controls.JFXButton.ButtonType) KeyFrame(javafx.animation.KeyFrame) Label(javafx.scene.control.Label) Control(javafx.scene.control.Control) MouseEvent(javafx.scene.input.MouseEvent) Event(javafx.event.Event) Timeline(javafx.animation.Timeline) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) StackPane(javafx.scene.layout.StackPane) Group(javafx.scene.Group) Bindings(javafx.beans.binding.Bindings) EventType(javafx.event.EventType) Platform(javafx.application.Platform) Duration(javafx.util.Duration) Insets(javafx.geometry.Insets) Interpolator(javafx.animation.Interpolator) BorderPane(javafx.scene.layout.BorderPane) KeyValue(javafx.animation.KeyValue) ChangeListener(javafx.beans.value.ChangeListener) Bounds(javafx.geometry.Bounds) Pane(javafx.scene.layout.Pane) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 47 with KeyValue

use of javafx.animation.KeyValue 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 48 with KeyValue

use of javafx.animation.KeyValue 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 49 with KeyValue

use of javafx.animation.KeyValue 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 50 with KeyValue

use of javafx.animation.KeyValue 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)

Aggregations

KeyValue (javafx.animation.KeyValue)85 KeyFrame (javafx.animation.KeyFrame)83 Timeline (javafx.animation.Timeline)82 Interpolator (javafx.animation.Interpolator)12 Rotate (javafx.scene.transform.Rotate)12 Duration (javafx.util.Duration)12 Insets (javafx.geometry.Insets)11 MouseEvent (javafx.scene.input.MouseEvent)10 PerspectiveCamera (javafx.scene.PerspectiveCamera)9 ArrayList (java.util.ArrayList)8 Scene (javafx.scene.Scene)7 Label (javafx.scene.control.Label)7 Rectangle (javafx.scene.shape.Rectangle)7 ActionEvent (javafx.event.ActionEvent)6 EventHandler (javafx.event.EventHandler)6 Group (javafx.scene.Group)6 Node (javafx.scene.Node)6 KeyCode (javafx.scene.input.KeyCode)6 VBox (javafx.scene.layout.VBox)6 JFXButton (com.jfoenix.controls.JFXButton)5