Search in sources :

Example 6 with Interpolator

use of javafx.animation.Interpolator in project bisq-desktop by bisq-network.

the class PeerInfoWithTagEditor method animateHide.

@Override
protected void animateHide(Runnable onFinishedHandler) {
    if (GlobalSettings.getUseAnimations()) {
        double duration = getDuration(300);
        Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
        gridPane.setRotationAxis(Rotate.X_AXIS);
        Camera camera = gridPane.getScene().getCamera();
        gridPane.getScene().setCamera(new PerspectiveCamera());
        Timeline timeline = new Timeline();
        ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
        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)));
        timeline.setOnFinished(event -> {
            gridPane.setRotate(0);
            gridPane.setRotationAxis(Rotate.Z_AXIS);
            gridPane.getScene().setCamera(camera);
            onFinishedHandler.run();
        });
        timeline.play();
    } else {
        onFinishedHandler.run();
    }
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) Interpolator(javafx.animation.Interpolator) PerspectiveCamera(javafx.scene.PerspectiveCamera) Camera(javafx.scene.Camera) PerspectiveCamera(javafx.scene.PerspectiveCamera)

Example 7 with Interpolator

use of javafx.animation.Interpolator in project bisq-desktop by bisq-network.

the class PeerInfoWithTagEditor method animateDisplay.

@Override
protected void animateDisplay() {
    if (GlobalSettings.getUseAnimations()) {
        double startY = -160;
        double duration = getDuration(400);
        Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
        Timeline timeline = new Timeline();
        ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
        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(), 0, interpolator)));
        timeline.play();
    }
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) Interpolator(javafx.animation.Interpolator)

Example 8 with Interpolator

use of javafx.animation.Interpolator in project FXGL by AlmasB.

the class InterpolatorSample method playAnimation.

private void playAnimation(EasingInterpolator interpolator) {
    set("canPlay", false);
    Interpolator ease = getEase(interpolator);
    String animType = ((RadioButton) group2.getSelectedToggle()).getText();
    switch(animType) {
        case "Translate":
            Entities.animationBuilder().interpolator(ease).duration(Duration.seconds(2.3)).onFinished(() -> set("canPlay", true)).translate(player).from(new Point2D(0, -150)).to(new Point2D(0, 300)).buildAndPlay();
            break;
        case "Scale":
            Entities.animationBuilder().interpolator(ease).autoReverse(true).repeat(2).duration(Duration.seconds(1.15)).onFinished(() -> set("canPlay", true)).scale(player).from(new Point2D(1, 1)).to(new Point2D(0, 0)).buildAndPlay();
            break;
        case "Rotate":
            Entities.animationBuilder().interpolator(ease).duration(Duration.seconds(2.3)).onFinished(() -> set("canPlay", true)).rotate(player).rotateFrom(0).rotateTo(360).buildAndPlay();
            break;
    }
}
Also used : Point2D(javafx.geometry.Point2D) EasingInterpolator(com.almasb.fxgl.animation.EasingInterpolator) Interpolator(javafx.animation.Interpolator) RadioButton(javafx.scene.control.RadioButton)

Example 9 with Interpolator

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

the class SplinePanelController method updateAnimation.

public void updateAnimation() {
    if (timeline != null) {
        timeline.stop();
    }
    Interpolator spline = Interpolator.SPLINE(SplineEditor.getControlPoint1x(), SplineEditor.getControlPoint1y(), SplineEditor.getControlPoint2x(), SplineEditor.getControlPoint2y());
    timeline = new Timeline();
    timeline.setCycleCount(Timeline.INDEFINITE);
    timeline.setAutoReverse(true);
    timeline.getKeyFrames().addAll(new KeyFrame(Duration.ZERO, new KeyValue(scaleCircle.scaleXProperty(), 0d, spline), new KeyValue(scaleCircle.scaleYProperty(), 0d, spline), new KeyValue(rotateRectangle.rotateProperty(), 0d, spline), new KeyValue(fadeSquare.opacityProperty(), 0d, spline), new KeyValue(linearCircle.translateXProperty(), 0d, spline)), new KeyFrame(Duration.seconds(5), new KeyValue(scaleCircle.scaleXProperty(), 1d, spline), new KeyValue(scaleCircle.scaleYProperty(), 1d, spline), new KeyValue(rotateRectangle.rotateProperty(), 360d, spline), new KeyValue(rotateRectangle.rotateProperty(), 360d, spline), new KeyValue(fadeSquare.opacityProperty(), 1d, spline), new KeyValue(linearCircle.translateXProperty(), 180d, spline)));
    timeline.play();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) Interpolator(javafx.animation.Interpolator)

Example 10 with Interpolator

use of javafx.animation.Interpolator in project bitsquare by bitsquare.

the class PeerInfoWithTagEditor method animateHide.

@Override
protected void animateHide(Runnable onFinishedHandler) {
    if (Preferences.INSTANCE.getUseAnimations()) {
        double duration = getDuration(300);
        Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
        gridPane.setRotationAxis(Rotate.X_AXIS);
        Camera camera = gridPane.getScene().getCamera();
        gridPane.getScene().setCamera(new PerspectiveCamera());
        Timeline timeline = new Timeline();
        ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
        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)));
        timeline.setOnFinished(event -> {
            gridPane.setRotate(0);
            gridPane.setRotationAxis(Rotate.Z_AXIS);
            gridPane.getScene().setCamera(camera);
            onFinishedHandler.run();
        });
        timeline.play();
    } else {
        onFinishedHandler.run();
    }
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) Interpolator(javafx.animation.Interpolator) PerspectiveCamera(javafx.scene.PerspectiveCamera) Camera(javafx.scene.Camera) PerspectiveCamera(javafx.scene.PerspectiveCamera)

Aggregations

Interpolator (javafx.animation.Interpolator)14 KeyFrame (javafx.animation.KeyFrame)13 KeyValue (javafx.animation.KeyValue)13 Timeline (javafx.animation.Timeline)13 PerspectiveCamera (javafx.scene.PerspectiveCamera)6 Camera (javafx.scene.Camera)4 EasingInterpolator (com.almasb.fxgl.animation.EasingInterpolator)1 Point2D (javafx.geometry.Point2D)1 RadioButton (javafx.scene.control.RadioButton)1