Search in sources :

Example 1 with Timeline

use of javafx.animation.Timeline in project TrayNotification by PlusHaze.

the class FadeAnimation method setupDismissAnimation.

/**
     *
     * @return a constructed instance of a dismiss fade animation
     */
private Timeline setupDismissAnimation() {
    Timeline tl = new Timeline();
    //At this stage the opacity is already at 1.0
    //Lowers the opacity to 0.0 within 2000 milliseconds
    KeyValue kv1 = new KeyValue(stage.opacityProperty(), 0.0);
    KeyFrame kf1 = new KeyFrame(Duration.millis(2000), kv1);
    tl.getKeyFrames().addAll(kf1);
    //Action to be performed when the animation has finished
    tl.setOnFinished(e -> {
        trayIsShowing = false;
        stage.close();
        stage.setLocation(stage.getBottomRight());
    });
    return tl;
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 2 with Timeline

use of javafx.animation.Timeline in project TrayNotification by PlusHaze.

the class FadeAnimation method setupShowAnimation.

/**
     *
     * @return a constructed instance of a show fade animation
     */
private Timeline setupShowAnimation() {
    Timeline tl = new Timeline();
    //Sets opacity to 0.0 instantly which is pretty much invisible
    KeyValue kvOpacity = new KeyValue(stage.opacityProperty(), 0.0);
    KeyFrame frame1 = new KeyFrame(Duration.ZERO, kvOpacity);
    //Sets opacity to 1.0 (fully visible) over the time of 3000 milliseconds.
    KeyValue kvOpacity2 = new KeyValue(stage.opacityProperty(), 1.0);
    KeyFrame frame2 = new KeyFrame(Duration.millis(3000), kvOpacity2);
    tl.getKeyFrames().addAll(frame1, frame2);
    tl.setOnFinished(e -> trayIsShowing = true);
    return tl;
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 3 with Timeline

use of javafx.animation.Timeline in project TrayNotification by PlusHaze.

the class FadeAnimation method setupDismissAnimation.

@Override
protected Timeline setupDismissAnimation() {
    Timeline tl = new Timeline();
    // At this stage the opacity is already at 1.0
    // Lowers the opacity to 0.0 within 2000 milliseconds
    KeyValue kv1 = new KeyValue(stage.opacityProperty(), 0.0);
    KeyFrame kf1 = new KeyFrame(Duration.millis(2000), kv1);
    tl.getKeyFrames().addAll(kf1);
    // Action to be performed when the animation has finished
    tl.setOnFinished(e -> {
        trayIsShowing = false;
        stage.close();
        stage.setLocation(stage.getBottomRight());
    });
    return tl;
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 4 with Timeline

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

the class ValidationFacade method hideError.

private void hideError() {
    if (heightChanged) {
        new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(translateYProperty(), 0, Interpolator.EASE_BOTH))).play();
        // reset the height of text field
        new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(minHeightProperty(), initHeight, Interpolator.EASE_BOTH))).play();
        heightChanged = false;
    }
    // clear error label text
    errorLabel.setText(null);
    oldErrorLabelHeight = errorLabelInitHeight;
    // clear error icon
    errorIcon.getChildren().clear();
    // reset the height of the text field
    currentFieldHeight = initHeight;
    // hide error container
    errorContainer.setVisible(false);
    errorShown = false;
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Example 5 with Timeline

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

the class JFXListCell method initListeners.

/**
	 * init listeners to update the vertical gap / selection animation
	 */
private void initListeners() {
    listViewProperty().addListener((listObj, oldList, newList) -> {
        if (newList != null) {
            if (getListView() instanceof JFXListView) {
                ((JFXListView<?>) newList).currentVerticalGapProperty().addListener((o, oldVal, newVal) -> {
                    cellRippler.rippler.setClip(null);
                    if (newVal.doubleValue() != 0) {
                        playExpandAnimation = true;
                        getListView().requestLayout();
                    } else {
                        // fake expand state
                        double gap = clip.getY() * 2;
                        gapAnimation = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(this.translateYProperty(), -gap / 2 - (gap * (getIndex())), Interpolator.EASE_BOTH)));
                        gapAnimation.play();
                        gapAnimation.setOnFinished((finish) -> {
                            requestLayout();
                            Platform.runLater(() -> getListView().requestLayout());
                        });
                    }
                });
                selectedProperty().addListener((o, oldVal, newVal) -> {
                    if (newVal)
                        selectionChanged = true;
                });
            }
        }
    });
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame)

Aggregations

Timeline (javafx.animation.Timeline)91 KeyFrame (javafx.animation.KeyFrame)87 KeyValue (javafx.animation.KeyValue)77 Rotate (javafx.scene.transform.Rotate)14 MouseEvent (javafx.scene.input.MouseEvent)13 Duration (javafx.util.Duration)13 Interpolator (javafx.animation.Interpolator)12 Insets (javafx.geometry.Insets)9 PerspectiveCamera (javafx.scene.PerspectiveCamera)9 Scene (javafx.scene.Scene)8 ActionEvent (javafx.event.ActionEvent)7 Group (javafx.scene.Group)7 Node (javafx.scene.Node)7 KeyCode (javafx.scene.input.KeyCode)7 Color (javafx.scene.paint.Color)7 AnimationTimer (javafx.animation.AnimationTimer)6 EventHandler (javafx.event.EventHandler)6 Label (javafx.scene.control.Label)6 Rectangle (javafx.scene.shape.Rectangle)6 ArrayList (java.util.ArrayList)5