List of usage examples for javafx.animation Interpolator SPLINE
public static Interpolator SPLINE(double x1, double y1, double x2, double y2)
From source file:io.bitsquare.gui.main.overlays.Overlay.java
protected void animateDisplay() { gridPane.setOpacity(0);//from w ww. j a v a 2 s .c o m Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); double duration = getDuration(400); Timeline timeline = new Timeline(); ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames(); if (type.animationType == AnimationType.SlideDownFromCenterTop) { double startY = -gridPane.getHeight(); keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.translateYProperty(), startY, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.translateYProperty(), -10, interpolator))); } else if (type.animationType == AnimationType.ScaleFromCenter) { double startScale = 0.25; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), startScale, interpolator), new KeyValue(gridPane.scaleYProperty(), startScale, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); } else if (type.animationType == AnimationType.ScaleYFromCenter) { double startYScale = 0.25; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleYProperty(), startYScale, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); } else if (type.animationType == AnimationType.ScaleDownToCenter) { double startScale = 1.1; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), startScale, interpolator), new KeyValue(gridPane.scaleYProperty(), startScale, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); } else if (type.animationType == AnimationType.FadeInAtCenter) { keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 0, interpolator) )); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 1, interpolator))); } timeline.play(); }
From source file:io.bitsquare.gui.main.overlays.Overlay.java
protected void animateHide(Runnable onFinishedHandler) { Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); double duration = getDuration(200); Timeline timeline = new Timeline(); ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames(); if (type.animationType == AnimationType.SlideDownFromCenterTop) { double endY = -gridPane.getHeight(); keyFrames// w w w .j a v a 2 s. c o m .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.translateYProperty(), -10, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.translateYProperty(), endY, interpolator))); timeline.setOnFinished(e -> onFinishedHandler.run()); timeline.play(); } else if (type.animationType == AnimationType.ScaleFromCenter) { double endScale = 0.25; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), endScale, interpolator), new KeyValue(gridPane.scaleYProperty(), endScale, interpolator))); } else if (type.animationType == AnimationType.ScaleYFromCenter) { gridPane.setRotationAxis(Rotate.X_AXIS); gridPane.getScene().setCamera(new PerspectiveCamera()); keyFrames.add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.rotateProperty(), 0, interpolator), new KeyValue(gridPane.opacityProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.rotateProperty(), -90, interpolator), new KeyValue(gridPane.opacityProperty(), 0, interpolator))); } else if (type.animationType == AnimationType.ScaleDownToCenter) { double endScale = 0.1; keyFrames .add(new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator), new KeyValue(gridPane.scaleXProperty(), 1, interpolator), new KeyValue(gridPane.scaleYProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator), new KeyValue(gridPane.scaleXProperty(), endScale, interpolator), new KeyValue(gridPane.scaleYProperty(), endScale, interpolator))); } else if (type.animationType == AnimationType.FadeInAtCenter) { keyFrames.add( new KeyFrame(Duration.millis(0), new KeyValue(gridPane.opacityProperty(), 1, interpolator))); keyFrames.add(new KeyFrame(Duration.millis(duration), new KeyValue(gridPane.opacityProperty(), 0, interpolator))); } timeline.setOnFinished(e -> onFinishedHandler.run()); timeline.play(); }