Java Code Examples for javafx.animation.Interpolator#EASE_OUT

The following examples show how to use javafx.animation.Interpolator#EASE_OUT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameManager.java    From util4j with Apache License 2.0 6 votes vote down vote up
/**
 * Animation that moves the tile from its previous location to a new location 
 * @param tile to be animated
 * @param newLocation new location of the tile
 * @return a timeline 
 */
private Timeline animateExistingTile(Tile tile, Location newLocation) {
    Timeline timeline = new Timeline();
    KeyValue kvX = new KeyValue(tile.layoutXProperty(),
            newLocation.getLayoutX(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);
    KeyValue kvY = new KeyValue(tile.layoutYProperty(),
            newLocation.getLayoutY(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);

    KeyFrame kfX = new KeyFrame(ANIMATION_EXISTING_TILE, kvX);
    KeyFrame kfY = new KeyFrame(ANIMATION_EXISTING_TILE, kvY);

    timeline.getKeyFrames().add(kfX);
    timeline.getKeyFrames().add(kfY);

    return timeline;
}
 
Example 2
Source File: JFXCheckBoxSkin.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
CheckBoxTransition(Node mark) {
    super(null, new Timeline(
            new KeyFrame(
                Duration.ZERO,
                new KeyValue(mark.opacityProperty(), 0, Interpolator.EASE_OUT),
                new KeyValue(mark.scaleXProperty(), 0.5, Interpolator.EASE_OUT),
                new KeyValue(mark.scaleYProperty(), 0.5, Interpolator.EASE_OUT)
            ),
            new KeyFrame(Duration.millis(400),
                new KeyValue(mark.opacityProperty(), 1, Interpolator.EASE_OUT),
                new KeyValue(mark.scaleXProperty(), 0.5, Interpolator.EASE_OUT),
                new KeyValue(mark.scaleYProperty(), 0.5, Interpolator.EASE_OUT)
            ),
            new KeyFrame(
                Duration.millis(1000),
                new KeyValue(mark.scaleXProperty(), 1, Interpolator.EASE_OUT),
                new KeyValue(mark.scaleYProperty(), 1, Interpolator.EASE_OUT)
            )
        )
    );
    // reduce the number to increase the shifting , increase number to reduce shifting
    setCycleDuration(Duration.seconds(0.12));
    setDelay(Duration.seconds(0.05));
    this.mark = mark;
}
 
Example 3
Source File: CenterTransition.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
public CenterTransition(Node contentContainer, Node overlay) {
    super(contentContainer, new Timeline(
        new KeyFrame(Duration.ZERO,
            new KeyValue(contentContainer.scaleXProperty(), 0, Interpolator.LINEAR),
            new KeyValue(contentContainer.scaleYProperty(), 0, Interpolator.LINEAR),
            new KeyValue(overlay.opacityProperty(), 0, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(1000),
            new KeyValue(contentContainer.scaleXProperty(), 1, Interpolator.EASE_OUT),
            new KeyValue(contentContainer.scaleYProperty(), 1, Interpolator.EASE_OUT),
            new KeyValue(overlay.opacityProperty(), 1, Interpolator.EASE_BOTH)
        )));
    // reduce the number to increase the shifting , increase number to reduce shifting
    setCycleDuration(Duration.seconds(0.4));
    setDelay(Duration.seconds(0));
}
 
Example 4
Source File: HorizontalTransition.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
public HorizontalTransition(boolean leftDirection, Node contentContainer, Node overlay) {
    super(contentContainer, new Timeline(
        new KeyFrame(Duration.ZERO,
            new KeyValue(contentContainer.translateXProperty(),
                (contentContainer.getLayoutX() + contentContainer.getLayoutBounds().getMaxX())
                * (leftDirection? -1 : 1), Interpolator.LINEAR),
            new KeyValue(overlay.opacityProperty(), 0, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(1000),
            new KeyValue(overlay.opacityProperty(), 1, Interpolator.EASE_BOTH),
            new KeyValue(contentContainer.translateXProperty(), 0, Interpolator.EASE_OUT)
        )));
    // reduce the number to increase the shifting , increase number to reduce shifting
    setCycleDuration(Duration.seconds(0.4));
    setDelay(Duration.seconds(0));
}
 
Example 5
Source File: VerticalTransition.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
public VerticalTransition(boolean topDirection, Node contentContainer, Node overlay) {
    super(contentContainer, new Timeline(
        new KeyFrame(Duration.ZERO,
            new KeyValue(contentContainer.translateYProperty(),
                (contentContainer.getLayoutY() + contentContainer.getLayoutBounds().getMaxY())
                * (topDirection? -1 : 1), Interpolator.LINEAR),
            new KeyValue(overlay.opacityProperty(), 0, Interpolator.EASE_BOTH)
        ),
        new KeyFrame(Duration.millis(1000),
            new KeyValue(overlay.opacityProperty(), 1, Interpolator.EASE_BOTH),
            new KeyValue(contentContainer.translateYProperty(), 0, Interpolator.EASE_OUT)
        )));
    // reduce the number to increase the shifting , increase number to reduce shifting
    setCycleDuration(Duration.seconds(0.4));
    setDelay(Duration.seconds(0));
}
 
Example 6
Source File: GameManager.java    From Game2048FX with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Animation that moves the tile from its previous location to a new location
 * @param tile to be animated
 * @param newLocation new location of the tile
 * @return a timeline
 */
private Timeline animateExistingTile(Tile tile, Location newLocation) {
    Timeline timeline = new Timeline();
    KeyValue kvX = new KeyValue(tile.layoutXProperty(),
            newLocation.getLayoutX(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);
    KeyValue kvY = new KeyValue(tile.layoutYProperty(),
            newLocation.getLayoutY(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);

    KeyFrame kfX = new KeyFrame(Duration.millis(65*timeFactor), kvX);
    KeyFrame kfY = new KeyFrame(Duration.millis(65*timeFactor), kvY);

    timeline.getKeyFrames().add(kfX);
    timeline.getKeyFrames().add(kfY);

    return timeline;
}
 
Example 7
Source File: DaoLaunchWindow.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
private void createSlideAnimation(Timeline timeline, double imageWidth) {
    Interpolator interpolator = Interpolator.EASE_OUT;
    ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();

    double endX = -imageWidth;
    keyFrames.add(new KeyFrame(Duration.millis(0),
            new KeyValue(sectionScreenshot.opacityProperty(), 1, interpolator),
            new KeyValue(sectionScreenshot.translateXProperty(), 0, interpolator)));
    keyFrames.add(new KeyFrame(Duration.millis(DURATION),
            event -> {
                sectionDescriptionLabel.setText(selectedSection.description);
                sectionScreenshot.setId(selectedSection.imageId);
            },
            new KeyValue(sectionScreenshot.opacityProperty(), 0, interpolator),
            new KeyValue(sectionScreenshot.translateXProperty(), endX, interpolator)));

    double startX = imageWidth;

    keyFrames.add(new KeyFrame(Duration.millis(DURATION),
            new KeyValue(sectionScreenshot.opacityProperty(), 0, interpolator),
            new KeyValue(sectionScreenshot.translateXProperty(), startX, interpolator)));
    keyFrames.add(new KeyFrame(Duration.millis(DURATION * 2),
            new KeyValue(sectionScreenshot.opacityProperty(), 1, interpolator),
            new KeyValue(sectionScreenshot.translateXProperty(), 0, interpolator)));
}
 
Example 8
Source File: GameManager.java    From fx2048 with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Animation that moves the tile from its previous location to a new location
 *
 * @param tile        to be animated
 * @param newLocation new location of the tile
 * @return a timeline
 */
private Timeline animateExistingTile(Tile tile, Location newLocation) {
    var timeline = new Timeline();
    var kvX = new KeyValue(tile.layoutXProperty(),
            newLocation.getLayoutX(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);
    var kvY = new KeyValue(tile.layoutYProperty(),
            newLocation.getLayoutY(Board.CELL_SIZE) - (tile.getMinHeight() / 2), Interpolator.EASE_OUT);

    var kfX = new KeyFrame(ANIMATION_EXISTING_TILE, kvX);
    var kfY = new KeyFrame(ANIMATION_EXISTING_TILE, kvY);

    timeline.getKeyFrames().add(kfX);
    timeline.getKeyFrames().add(kfY);

    return timeline;
}
 
Example 9
Source File: JFXAlertAnimation.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
@Override
public Animation createShowingAnimation(Node contentContainer, Node overlay) {
    return new CachedTransition(contentContainer, new Timeline(
        new KeyFrame(Duration.millis(1000),
            new KeyValue(contentContainer.scaleXProperty(), 1, Interpolator.EASE_OUT),
            new KeyValue(contentContainer.scaleYProperty(), 1, Interpolator.EASE_OUT),
            new KeyValue(overlay.opacityProperty(), 1, Interpolator.EASE_BOTH)
        ))) {
        {
            setCycleDuration(Duration.millis(160));
            setDelay(Duration.seconds(0));
        }
    };
}
 
Example 10
Source File: RadialMenu.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private Timeline createItemOpenTimeLine(final StackPane NODE, final double X, final double Y, final double DELAY) {
    KeyValue kvX1  = new KeyValue(NODE.translateXProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvY1  = new KeyValue(NODE.translateYProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvR1  = new KeyValue(NODE.rotateProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvO1  = new KeyValue(NODE.opacityProperty(), 0.0, Interpolator.EASE_OUT);

    KeyValue kvX2  = new KeyValue(NODE.translateXProperty(), 0.0);
    KeyValue kvY2  = new KeyValue(NODE.translateYProperty(), 0.0);

    KeyValue kvX3  = new KeyValue(NODE.translateXProperty(), 1.1 * X, Interpolator.EASE_IN);
    KeyValue kvY3  = new KeyValue(NODE.translateYProperty(), 1.1 * Y, Interpolator.EASE_IN);

    KeyValue kvX4  = new KeyValue(NODE.translateXProperty(), 0.95 * X, Interpolator.EASE_OUT);
    KeyValue kvY4  = new KeyValue(NODE.translateYProperty(), 0.95 * Y, Interpolator.EASE_OUT);
    KeyValue kvRO4 = new KeyValue(NODE.rotateProperty(), 360);
    KeyValue kvO4  = new KeyValue(NODE.opacityProperty(), 1.0, Interpolator.EASE_OUT);

    KeyValue kvX5  = new KeyValue(NODE.translateXProperty(), X);
    KeyValue kvY5  = new KeyValue(NODE.translateYProperty(), Y);

    KeyFrame kfO1  = new KeyFrame(Duration.millis(0), kvX1, kvY1, kvR1, kvO1);
    KeyFrame kfO2  = new KeyFrame(Duration.millis(50 + DELAY), kvX2, kvY2);
    KeyFrame kfO3  = new KeyFrame(Duration.millis(250 + DELAY), kvX3, kvY3);
    KeyFrame kfO4  = new KeyFrame(Duration.millis(400 + DELAY), kvX4, kvY4, kvRO4, kvO4);
    KeyFrame kfO5  = new KeyFrame(Duration.millis(550 + DELAY), kvX5, kvY5);

    return new Timeline(kfO1, kfO2, kfO3, kfO4, kfO5);
}
 
Example 11
Source File: RadialMenu.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private Timeline createItemCloseTimeLine(final StackPane NODE, final double X, final double Y, final double DELAY) {
    KeyValue kvX1  = new KeyValue(NODE.translateXProperty(), X);
    KeyValue kvY1  = new KeyValue(NODE.translateYProperty(), Y);

    KeyValue kvRC2 = new KeyValue(NODE.rotateProperty(), 720);

    KeyValue kvX3  = new KeyValue(NODE.translateXProperty(), X, Interpolator.EASE_IN);
    KeyValue kvY3  = new KeyValue(NODE.translateYProperty(), Y, Interpolator.EASE_IN);

    KeyValue kvX4  = new KeyValue(NODE.translateXProperty(), 0);
    KeyValue kvY4  = new KeyValue(NODE.translateYProperty(), 0);

    KeyValue kvX5  = new KeyValue(NODE.translateXProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvY5  = new KeyValue(NODE.translateYProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvR5  = new KeyValue(NODE.rotateProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvO5  = new KeyValue(NODE.opacityProperty(), 0.5);

    KeyValue kvO6  = new KeyValue(NODE.opacityProperty(), 0);

    KeyFrame kfC1  = new KeyFrame(Duration.millis(0), kvX1, kvY1);
    KeyFrame kfC2  = new KeyFrame(Duration.millis(50 + DELAY), kvRC2);
    KeyFrame kfC3  = new KeyFrame(Duration.millis(250 + DELAY), kvX3, kvY3);
    KeyFrame kfC4  = new KeyFrame(Duration.millis(400 + DELAY), kvX4, kvY4);
    KeyFrame kfC5  = new KeyFrame(Duration.millis(550 + DELAY), kvX5, kvY5, kvR5, kvO5);
    KeyFrame kfC6  = new KeyFrame(Duration.millis(551 + DELAY), kvO6);

    return new Timeline(kfC1, kfC2, kfC3, kfC4, kfC5, kfC6);
}
 
Example 12
Source File: RadialMenu.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private Timeline createSimpleItemOpenTimeLine(final StackPane NODE, final double X, final double Y, final double DELAY) {
    KeyValue kvX1  = new KeyValue(NODE.translateXProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvY1  = new KeyValue(NODE.translateYProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvR1  = new KeyValue(NODE.rotateProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvO1  = new KeyValue(NODE.opacityProperty(), 0, Interpolator.EASE_OUT);

    KeyValue kvX2  = new KeyValue(NODE.translateXProperty(), 0.0);
    KeyValue kvY2  = new KeyValue(NODE.translateYProperty(), 0.0);

    KeyValue kvX3  = new KeyValue(NODE.translateXProperty(), 1.1 * X, Interpolator.EASE_IN);
    KeyValue kvY3  = new KeyValue(NODE.translateYProperty(), 1.1 * Y, Interpolator.EASE_IN);

    KeyValue kvX4  = new KeyValue(NODE.translateXProperty(), 0.97 * X, Interpolator.EASE_OUT);
    KeyValue kvY4  = new KeyValue(NODE.translateYProperty(), 0.97 * Y, Interpolator.EASE_OUT);
    KeyValue kvRO4 = new KeyValue(NODE.rotateProperty(), 360);
    KeyValue kvO4  = new KeyValue(NODE.opacityProperty(), 1.0, Interpolator.EASE_OUT);

    KeyValue kvX5  = new KeyValue(NODE.translateXProperty(), X);
    KeyValue kvY5  = new KeyValue(NODE.translateYProperty(), Y);

    KeyFrame kfO1  = new KeyFrame(Duration.millis(0), kvX1, kvY1, kvR1, kvO1);
    KeyFrame kfO2  = new KeyFrame(Duration.millis(50 + DELAY), kvX2, kvY2);
    KeyFrame kfO3  = new KeyFrame(Duration.millis(150 + DELAY), kvX3, kvY3);
    KeyFrame kfO4  = new KeyFrame(Duration.millis(300 + DELAY), kvX4, kvY4, kvRO4, kvO4);
    KeyFrame kfO5  = new KeyFrame(Duration.millis(400 + DELAY), kvX5, kvY5);

    return new Timeline(kfO1, kfO2, kfO3, kfO4, kfO5);
}
 
Example 13
Source File: RadialMenu.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private Timeline createSimpleItemCloseTimeLine(final StackPane NODE, final double X, final double Y, final double DELAY) {
    KeyValue kvX1  = new KeyValue(NODE.translateXProperty(), X);
    KeyValue kvY1  = new KeyValue(NODE.translateYProperty(), Y);

    KeyValue kvRC2 = new KeyValue(NODE.rotateProperty(), 360);

    KeyValue kvX3  = new KeyValue(NODE.translateXProperty(), 1.0 * X, Interpolator.EASE_IN);
    KeyValue kvY3  = new KeyValue(NODE.translateYProperty(), 1.0 * Y, Interpolator.EASE_IN);

    KeyValue kvX4  = new KeyValue(NODE.translateXProperty(), 0.0);
    KeyValue kvY4  = new KeyValue(NODE.translateYProperty(), 0.0);

    KeyValue kvX5  = new KeyValue(NODE.translateXProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvY5  = new KeyValue(NODE.translateYProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvR5  = new KeyValue(NODE.rotateProperty(), 0, Interpolator.EASE_OUT);
    KeyValue kvO5  = new KeyValue(NODE.opacityProperty(), 0.5);

    KeyValue kvO6  = new KeyValue(NODE.opacityProperty(), 0);

    KeyFrame kfC1  = new KeyFrame(Duration.millis(0), kvX1, kvY1);
    KeyFrame kfC2  = new KeyFrame(Duration.millis(50 + DELAY), kvRC2);
    KeyFrame kfC3  = new KeyFrame(Duration.millis(250 + DELAY), kvX3, kvY3);
    KeyFrame kfC4  = new KeyFrame(Duration.millis(400 + DELAY), kvX4, kvY4);
    KeyFrame kfC5  = new KeyFrame(Duration.millis(550 + DELAY), kvX5, kvY5, kvR5, kvO5);
    KeyFrame kfC6  = new KeyFrame(Duration.millis(551 + DELAY), kvO6);

    return new Timeline(kfC1, kfC2, kfC3, kfC4, kfC5, kfC6);
}
 
Example 14
Source File: RippleEffect.java    From pmd-designer with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RippleEffect(ReadOnlyDoubleProperty containerWidth,
                    ReadOnlyDoubleProperty containerHeight,
                    Supplier<Background> containerBackground) {
    circleRipple = new Circle(0.1, rippleColor);
    circleRipple.setOpacity(0.0);
    // Optional box blur on ripple - smoother ripple effect
    //circleRipple.setEffect(new BoxBlur(3, 3, 2));
    // Fade effect bit longer to show edges on the end of animation
    final FadeTransition fadeTransition = new FadeTransition(rippleDuration, circleRipple);
    fadeTransition.setInterpolator(Interpolator.EASE_OUT);
    fadeTransition.setFromValue(1.0);
    fadeTransition.setToValue(0.0);
    final Timeline scaleRippleTimeline = new Timeline();
    final SequentialTransition parallelTransition = new SequentialTransition();
    parallelTransition.getChildren().addAll(
        scaleRippleTimeline,
        fadeTransition
    );
    // When ripple transition is finished then reset circleRipple to starting point
    parallelTransition.setOnFinished(event -> {
        circleRipple.setOpacity(0.0);
        circleRipple.setRadius(0.1);
    });
    this.handler = event -> {
        parallelTransition.stop();
        // Manually fire finish event
        parallelTransition.getOnFinished().handle(null);
        circleRipple.setCenterX(event.getX());
        circleRipple.setCenterY(event.getY());
        // Recalculate ripple size if size of button from last time was changed
        if (containerWidth.get() != lastRippleWidth || containerHeight.get() != lastRippleHeight) {
            lastRippleWidth = containerWidth.get();
            lastRippleHeight = containerHeight.get();
            rippleClip.setWidth(lastRippleWidth);
            rippleClip.setHeight(lastRippleHeight);
            try {
                rippleClip.setArcHeight(containerBackground.get().getFills().get(0).getRadii().getTopLeftHorizontalRadius());
                rippleClip.setArcWidth(containerBackground.get().getFills().get(0).getRadii().getTopLeftHorizontalRadius());
                circleRipple.setClip(rippleClip);
            } catch (Exception ignored) {
                // try block because of possible null of Background, fills ...
            }
            // Getting 45% of longest button's length, because we want edge of ripple effect always visible
            double circleRippleRadius = Math.max(containerHeight.get(), containerWidth.get()) * 0.45;
            final KeyValue keyValue = new KeyValue(circleRipple.radiusProperty(), circleRippleRadius, Interpolator.EASE_OUT);
            final KeyFrame keyFrame = new KeyFrame(rippleDuration, keyValue);
            scaleRippleTimeline.getKeyFrames().clear();
            scaleRippleTimeline.getKeyFrames().add(keyFrame);
        }
        parallelTransition.playFromStart();
    };
}