private void createAnimation(boolean expanded, Timeline animation) { final ObservableList<Node> children = getChildren(); double duration = 160 / (double) children.size(); // show child nodes if (expanded) { for (Node child : children) { child.setVisible(true); } } // add child nodes animation for (int i = 1; i < children.size(); i++) { Node child = children.get(i); Collection<KeyFrame> frames = animationsMap.get(child).apply(expanded, Duration.millis(i * duration)); animation.getKeyFrames().addAll(frames); } // add 1st element animation Collection<KeyFrame> frames = animationsMap.get(children.get(0)).apply(expanded, Duration.millis(160)); animation.getKeyFrames().addAll(frames); // hide child nodes to allow mouse events on the nodes behind them if (!expanded) { animation.setOnFinished((finish) -> { for (int i = 1; i < children.size(); i++) { children.get(i).setVisible(false); } }); } else { animation.setOnFinished(null); } }
public void show() { dialog.setOpacity(0); // pickerDecorator.setOpacity(0); if (dialog.getOwner() != null) { dialog.widthProperty().addListener(positionAdjuster); dialog.heightProperty().addListener(positionAdjuster); positionAdjuster.invalidated(null); } if (dialog.getScene() == null) { dialog.setScene(customScene); } curvedColorPicker.preAnimate(); dialog.show(); if (initOnce) { initRun.run(); initOnce = false; } Timeline timeline = new Timeline(new KeyFrame(Duration.millis(120), new KeyValue(dialog.opacityProperty(), 1, Interpolator.EASE_BOTH))); timeline.setOnFinished((finish) -> curvedColorPicker.animate()); timeline.play(); }
if (!control.isDisableAnimation()) { if (newVal != null) { errorHideTransition.setOnFinished(finish -> { showError(newVal); final double w = control.getWidth(); scaleLess1.setOnFinished(event -> { updateErrorContainerSize(w, errorContainerHeight); errorClipScale.setY(1); errorHideTransition.play(); } else { errorHideTransition.setOnFinished(null); if (errorLabel.isWrapText()) { scaleLess1.setOnFinished(event -> { hideError(); errorClipScale.setY(0);
)); gapAnimation.play(); gapAnimation.setOnFinished((finish) -> { requestLayout(); Platform.runLater(() -> getListView().requestLayout());
errorAnimation.play(); errorAnimation.setOnFinished(finish -> new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(errorContainer.opacityProperty(), 1, 0, Interpolator.EASE_BOTH))); hideErrorAnimation.setOnFinished(finish -> { JFXUtilities.runInFX(() -> showError(newVal)); });
private void updateColor() { final ColorPicker colorPicker = (ColorPicker) getSkinnable(); Color color = colorPicker.getValue(); // update picker box color Color circleColor = color == null ? Color.WHITE : color; Circle colorCircle = new Circle(); colorCircle.setFill(circleColor); colorCircle.setLayoutX(colorBox.getWidth() / 4); colorCircle.setLayoutY(colorBox.getHeight() / 2); colorBox.getChildren().add(colorCircle); Timeline animateColor = new Timeline(new KeyFrame(Duration.millis(240), new KeyValue(colorCircle.radiusProperty(), 200, Interpolator.EASE_BOTH))); animateColor.setOnFinished((finish) -> { JFXNodeUtils.updateBackground(colorBox.getBackground(), colorBox, colorCircle.getFill()); colorBox.getChildren().remove(colorCircle); }); animateColor.play(); // update label color displayNode.setTextFill(circleColor.grayscale().getRed() < 0.5 ? Color.valueOf( "rgba(255, 255, 255, 0.87)") : Color.valueOf("rgba(0, 0, 0, 0.87)")); if (colorLabelVisible.get()) { displayNode.setText(JFXNodeUtils.colorToHex(circleColor)); } else { displayNode.setText(""); } }
-buttonsContainer.getHeight(), Interpolator.EASE_BOTH))); windowDecoratorAnimation.setOnFinished((finish) -> { this.getChildren().remove(buttonsContainer); this.setTranslateY(0); 0, Interpolator.EASE_BOTH))); windowDecoratorAnimation.setOnFinished((finish) -> { contentPlaceHolder.setBorder(new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID,
); timeline.setOnFinished(finish -> { if (rotate.getAngle() != 0) { rotate.setAngle(0);
showTransition = new Timeline(new KeyFrame(Duration.millis(120), new KeyValue(scale.yProperty(), 1, Interpolator.EASE_BOTH))); showTransition.setOnFinished((finish) -> { Group vf = (Group) suggestionList.lookup(".sheet"); ParallelTransition trans = new ParallelTransition();
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(() -> {
closeAnimation.setOnFinished(e -> { resetPseudoClass(); processSnackbar();
pauseTransition = Duration.INDEFINITE.equals(timeout) ? null : new PauseTransition(timeout); if (pauseTransition != null) { animation.setOnFinished(finish -> { pauseTransition.setOnFinished(done -> { pauseTransition = null;
expandAnimation.setOnFinished((finish) -> { updateClipHeight(newHeight); getListView().setPrefHeight(getListView().getHeight() + newAnimatedHeight);
private ErrorTooltipManager(String message) { require(isNotBlank(message), "Tooltip message cannot be blank"); this.tooltip = new Tooltip(message); this.tooltip.getStyleClass().add(ERROR_TOOLTIP_CLASS); hideTimer.getKeyFrames().add(new KeyFrame(new Duration(5000))); hideTimer.setOnFinished(e -> { tooltip.hide(); ErrorTooltipManager.this.active = false; }); activationTimer.getKeyFrames().add(new KeyFrame(new Duration(250))); activationTimer.setOnFinished(e -> { if (!ErrorTooltipManager.this.active) { Scene scene = getScene(); if (scene != null) { Window owner = scene.getWindow(); if (owner != null && owner.isShowing() && ValidableTextField.this.isVisible()) { Point2D where = getDisplayCoordiantes(owner, scene); tooltip.show(ValidableTextField.this, where.getX(), where.getY()); ErrorTooltipManager.this.active = true; hideTimer.playFromStart(); } } } }); }
slideIn.setOnFinished(e -> content.setVisible(true));
public void play() { KeyFrame kf = new KeyFrame(Duration.millis(20), e -> spin()); Timeline tl = new Timeline(kf); tl.setCycleCount(randomize(10,50)); tl.play(); tl.setOnFinished(e -> { int x = this.queue.peek().getKey(); // do whatever you need to do with x here.... }); }
final void hide(EventHandler<ActionEvent> nextAction){ final Timeline timeline = new Timeline(); timeline.setCycleCount(1); timeline.setAutoReverse(true); final KeyValue[] kvArray = new KeyValue[2]; kvArray[0] = new KeyValue(this.getNode().scaleXProperty(), 0); kvArray[1] = new KeyValue(this.getNode().scaleYProperty(), 0); final KeyFrame kf = new KeyFrame(Duration.millis(500), kvArray); timeline.getKeyFrames().add(kf); // here we call function from parameter timeline.setOnFinished(nextAction); timeline.play(); }
public class Audio { public static void crossfade(MediaPlayer mp1, MediaPlayer mp2) { final double currentVolume = mp1.getVolume(); mp2.setVolume(0); mp2.play(); Timeline crossfade = new Timeline(new KeyFrame(Duration.seconds(2), new KeyValue(mp1.volumeProperty(), 0), new KeyValue(mp2.volumeProperty(), currentVolume))); crossfade.setOnFinished(event -> mp1.stop()); crossfade.play(); } }
private void restartStopwatch(Button button) { Timeline timeline = new Timeline(); for (int i = 0; i <= 5; i++) { final int timeRemaining = 5 - i ; KeyFrame frame = new KeyFrame(Duration.seconds(i), e -> button.setText("Updated. Restarting in: " + timeRemaining + " Seconds...")); timeline.getKeyFrames().add(frame); } timeline.setOnFinished(e -> new UpdateChecker().restartApplication()); timeline.play(); }
private Timeline createHideTimeline(final Popup popup, NotificationBar bar, final Pos p, Duration startDelay) { KeyValue fadeOutBegin = new KeyValue(bar.opacityProperty(), 1.0); KeyValue fadeOutEnd = new KeyValue(bar.opacityProperty(), 0.0); KeyFrame kfBegin = new KeyFrame(Duration.ZERO, fadeOutBegin); KeyFrame kfEnd = new KeyFrame(Duration.millis(500), fadeOutEnd); Timeline timeline = new Timeline(kfBegin, kfEnd); timeline.setDelay(startDelay); timeline.setOnFinished(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { hide(popup, p); } }); return timeline; }