Java Code Examples for javafx.animation.PauseTransition#setOnFinished()

The following examples show how to use javafx.animation.PauseTransition#setOnFinished() . 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: AdminAddUserViewController.java    From Corendon-LostLuggage with MIT License 6 votes vote down vote up
public void startAnimation() {
    errorMessageView.prefHeight(0.0d);
    mainBorderPane.setTop(errorMessageView);
    errorMessageHBox.getChildren().add(errorMessageLbl);
    errorMessageLbl.setVisible(true);

    Timeline timeline = new Timeline();
    timeline.getKeyFrames().addAll(new KeyFrame(Duration.ZERO,
            new KeyValue(errorMessageView.prefHeightProperty(), 0)
    ),
            new KeyFrame(Duration.millis(300.0d),
                    new KeyValue(errorMessageView.prefHeightProperty(), navListPrefHeight)
            )
    );
    addUserBtn.setDisable(true);
    timeline.play();

    PauseTransition wait = new PauseTransition(Duration.seconds(4));
    wait.setOnFinished((e) -> {
        dismissAnimation();
    });
    wait.play();

}
 
Example 2
Source File: NotificationView.java    From Maus with GNU General Public License v3.0 6 votes vote down vote up
public static void openNotification(ClientObject client) {
    Stage stage = new Stage();
    stage.setWidth(300);
    stage.setHeight(125);
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    NotificationView notificationView = new NotificationView();
    stage.setScene(new Scene(notificationView.getNotificationView(), 300, 125));
    stage.setResizable(false);
    stage.setAlwaysOnTop(true);
    stage.setX(primaryScreenBounds.getMinX() + primaryScreenBounds.getWidth() - 300);
    stage.setY(primaryScreenBounds.getMinY() + primaryScreenBounds.getHeight() - 125);
    stage.initStyle(StageStyle.UNDECORATED);
    notificationView.getNotificationText().setWrapText(true);
    notificationView.getNotificationText().setAlignment(Pos.CENTER);
    notificationView.getNotificationText().setPadding(new Insets(0, 5, 0, 20));
    notificationView.getNotificationText().setText("New Connection: " + client.getIP() + " (" + client.getNickName() + ")");
    stage.show();
    PauseTransition delay = new PauseTransition(Duration.seconds(5));
    delay.setOnFinished(event -> stage.close());
    delay.play();
}
 
Example 3
Source File: NotificationView.java    From Maus with GNU General Public License v3.0 6 votes vote down vote up
public static void openNotification(String text) {
    Stage stage = new Stage();
    stage.setWidth(300);
    stage.setHeight(125);
    Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds();
    NotificationView notificationView = new NotificationView();
    stage.setScene(new Scene(notificationView.getNotificationView(), 300, 125));
    stage.setResizable(false);
    stage.setAlwaysOnTop(true);
    stage.setX(primaryScreenBounds.getMinX() + primaryScreenBounds.getWidth() - 300);
    stage.setY(primaryScreenBounds.getMinY() + primaryScreenBounds.getHeight() - 125);
    stage.initStyle(StageStyle.UNDECORATED);
    notificationView.getNotificationText().setWrapText(true);
    notificationView.getNotificationText().setAlignment(Pos.CENTER);
    notificationView.getNotificationText().setPadding(new Insets(0, 5, 0, 20));
    notificationView.getNotificationText().setText(text);
    stage.show();
    PauseTransition delay = new PauseTransition(Duration.seconds(5));
    delay.setOnFinished(event -> stage.close());
    delay.play();
}
 
Example 4
Source File: ParetoInfoPopup.java    From charts with Apache License 2.0 6 votes vote down vote up
private void init() {
    setAutoFix(true);
    rowCount = 2;

    fadeIn = new FadeTransition(Duration.millis(200), hBox);
    fadeIn.setFromValue(0);
    fadeIn.setToValue(0.75);

    fadeOut = new FadeTransition(Duration.millis(200), hBox);
    fadeOut.setFromValue(0.75);
    fadeOut.setToValue(0.0);
    fadeOut.setOnFinished(e -> hide());

    delay = new PauseTransition(Duration.millis(_timeout));
    delay.setOnFinished(e -> animatedHide());
}
 
Example 5
Source File: InfoPopup.java    From charts with Apache License 2.0 6 votes vote down vote up
private void init() {
    setAutoFix(true);
    rowCount = 2;

    fadeIn = new FadeTransition(Duration.millis(200), hBox);
    fadeIn.setFromValue(0);
    fadeIn.setToValue(0.75);

    fadeOut = new FadeTransition(Duration.millis(200), hBox);
    fadeOut.setFromValue(0.75);
    fadeOut.setToValue(0.0);
    fadeOut.setOnFinished(e -> hide());

    delay = new PauseTransition(Duration.millis(_timeout));
    delay.setOnFinished(e -> animatedHide());
}
 
Example 6
Source File: DisplayEditorApplication.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public DisplayEditorInstance create()
{
    if (!AuthorizationService.hasAuthorization("edit_display"))
    {
        // User does not have a permission to start editor
        final Alert alert = new Alert(Alert.AlertType.WARNING);
        DialogHelper.positionDialog(alert, DockPane.getActiveDockPane(), -200, -100);
        alert.initOwner(DockPane.getActiveDockPane().getScene().getWindow());
        alert.setResizable(true);
        alert.setTitle(DISPLAY_NAME);
        alert.setHeaderText(Messages.DisplayApplicationMissingRight);
        // Autohide in some seconds, also to handle the situation after
        // startup without edit_display rights but opening editor from memento
        PauseTransition wait = new PauseTransition(Duration.seconds(7));
        wait.setOnFinished((e) -> {
            Button btn = (Button)alert.getDialogPane().lookupButton(ButtonType.OK);
            btn.fire();
        });
        wait.play();
        
        alert.showAndWait();
        return null;
    }
    return new DisplayEditorInstance(this);
}
 
Example 7
Source File: LiveDataFetcher.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void regionOrProductChanged() {
    cancel();
    boolean regionChanged = updateRegionAndProductSelection();
    if (regionChanged) {
        // pause the data updating to wait for animation to finish
        PauseTransition delay = new PauseTransition(Duration.millis(1500));
        delay.setOnFinished(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent t) {
                restart();
            }
        });
        delay.play();
    } else {
        restart();
    }
}
 
Example 8
Source File: LiveDataFetcher.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void regionOrProductChanged() {
    cancel();
    boolean regionChanged = updateRegionAndProductSelection();
    if (regionChanged) {
        // pause the data updating to wait for animation to finish
        PauseTransition delay = new PauseTransition(Duration.millis(1500));
        delay.setOnFinished(new EventHandler<ActionEvent>() {
            @Override public void handle(ActionEvent t) {
                restart();
            }
        });
        delay.play();
    } else {
        restart();
    }
}
 
Example 9
Source File: SpaceFXView.java    From SpaceFX with Apache License 2.0 6 votes vote down vote up
public void storePlayer() {
    hallOfFame.add(new Player((digit1.getCharacter() + digit2.getCharacter()), score));
    Collections.sort(hallOfFame);
    hallOfFame = hallOfFame.stream().limit(3).collect(Collectors.toList());

    // Store hall of fame in properties
    properties.setProperty("hallOfFame1", hallOfFame.get(0).toPropertyString());
    properties.setProperty("hallOfFame2", hallOfFame.get(1).toPropertyString());
    properties.setProperty("hallOfFame3", hallOfFame.get(2).toPropertyString());
    PropertyManager.INSTANCE.storeProperties();

    HBox p1Entry = createHallOfFameEntry(new Player(properties.getProperty("hallOfFame1")));
    HBox p2Entry = createHallOfFameEntry(new Player(properties.getProperty("hallOfFame2")));
    HBox p3Entry = createHallOfFameEntry(new Player(properties.getProperty("hallOfFame3")));
    hallOfFameBox.getChildren().setAll(p1Entry, p2Entry, p3Entry);
    hallOfFameBox.relocate((WIDTH - hallOfFameBox.getPrefWidth()) * 0.5, (HEIGHT - hallOfFameBox.getPrefHeight()) * 0.5);

    Helper.enableNode(playerInitialsLabel, false);
    Helper.enableNode(playerInitialsDigits, false);
    Helper.enableNode(saveInitialsButton, false);

    PauseTransition waitForHallOfFame = new PauseTransition(Duration.millis(3000));
    waitForHallOfFame.setOnFinished(a -> reInitGame());
    waitForHallOfFame.play();
}
 
Example 10
Source File: InfoPopup.java    From charts with Apache License 2.0 5 votes vote down vote up
private void init() {
    setAutoFix(true);

    fadeIn = new FadeTransition(Duration.millis(200), hBox);
    fadeIn.setFromValue(0);
    fadeIn.setToValue(0.75);

    fadeOut = new FadeTransition(Duration.millis(200), hBox);
    fadeOut.setFromValue(0.75);
    fadeOut.setToValue(0.0);
    fadeOut.setOnFinished(e -> hide());

    delay = new PauseTransition(Duration.millis(_timeout));
    delay.setOnFinished(e -> animatedHide());
}
 
Example 11
Source File: ScrollGesture.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 *
 * @param viewer
 *            The {@link IViewer}
 * @return A {@link PauseTransition}
 */
protected PauseTransition createFinishDelayTransition(
		final IViewer viewer) {
	PauseTransition pauseTransition = new PauseTransition(
			Duration.millis(getFinishDelayMillis()));
	pauseTransition.setOnFinished((ae) -> {
		scrollFinished(viewer);
		inScroll.remove(viewer);
	});
	return pauseTransition;
}
 
Example 12
Source File: MnistImageView.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void zoomIn() {
    PauseTransition p = new PauseTransition(Duration.millis(30));
    p.setOnFinished(e -> {
        double factor = Math.max(INNER_WIDTH / this.getViewport().getWidth(), 
                             INNER_HEIGHT / this.getViewport().getHeight());
        zoom(factor, this.getFitWidth()/2, this.getFitHeight()/2);
        translateViewport(-(IMAGE_WIDTH - this.getViewport().getWidth()) / 2, 
                          -(IMAGE_HEIGHT - this.getViewport().getHeight()) / 2);
    });
    p.play();
}
 
Example 13
Source File: MapPresenter.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void addPoint(MapPoint p, Node icon) {
    points.add(new Pair(p, icon));
    icon.setVisible(false);
    this.getChildren().add(icon);
    // required to layout first the node and be able to find its 
    // bounds
    PauseTransition pause = new PauseTransition(Duration.millis(100));
    pause.setOnFinished(f -> {
        markDirty();
        icon.setVisible(true);
    });
    pause.play();
}
 
Example 14
Source File: JFXNodeUtils.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
public static void addPressAndHoldHandler(Node node, Duration holdTime,
                                          EventHandler<MouseEvent> handler) {
    Wrapper<MouseEvent> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(holdTime);
    holdTimer.setOnFinished(event -> handler.handle(eventWrapper.content));
    node.addEventHandler(MouseEvent.MOUSE_PRESSED, event -> {
        eventWrapper.content = event;
        holdTimer.playFromStart();
    });
    node.addEventHandler(MouseEvent.MOUSE_RELEASED, event -> holdTimer.stop());
    node.addEventHandler(MouseEvent.DRAG_DETECTED, event -> holdTimer.stop());
}
 
Example 15
Source File: JFXNodeUtils.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
public static void addPressAndHoldFilter(Node node, Duration holdTime,
                                         EventHandler<MouseEvent> handler) {
    Wrapper<MouseEvent> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(holdTime);
    holdTimer.setOnFinished(event -> handler.handle(eventWrapper.content));
    node.addEventFilter(MouseEvent.MOUSE_PRESSED, event -> {
        eventWrapper.content = event;
        holdTimer.playFromStart();
    });
    node.addEventFilter(MouseEvent.MOUSE_RELEASED, event -> holdTimer.stop());
    node.addEventFilter(MouseEvent.DRAG_DETECTED, event -> holdTimer.stop());
}
 
Example 16
Source File: JFXNodeUtils.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
public static <T> InvalidationListener addDelayedPropertyInvalidationListener(ObservableValue<T> property,
                                                                              Duration delayTime,
                                                                              Consumer<T> consumer) {
    Wrapper<T> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(delayTime);
    holdTimer.setOnFinished(event -> consumer.accept(eventWrapper.content));
    final InvalidationListener invalidationListener = observable -> {
        eventWrapper.content = property.getValue();
        holdTimer.playFromStart();
    };
    property.addListener(invalidationListener);
    return invalidationListener;
}
 
Example 17
Source File: JFXNodeUtils.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
public static <T> InvalidationListener addDelayedPropertyInvalidationListener(ObservableValue<T> property,
                                                                              Duration delayTime,
                                                                              BiConsumer<T, InvalidationListener> consumer) {
    Wrapper<T> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(delayTime);
    final InvalidationListener invalidationListener = observable -> {
        eventWrapper.content = property.getValue();
        holdTimer.playFromStart();
    };
    holdTimer.setOnFinished(event -> consumer.accept(eventWrapper.content, invalidationListener));
    property.addListener(invalidationListener);
    return invalidationListener;
}
 
Example 18
Source File: JFXNodeUtils.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
public static <T> InvalidationListener addDelayedPropertyInvalidationListener(ObservableValue<T> property,
                                                                              Duration delayTime,
                                                                              Consumer<T> justInTimeConsumer,
                                                                              Consumer<T> delayedConsumer) {
    Wrapper<T> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(delayTime);
    holdTimer.setOnFinished(event -> delayedConsumer.accept(eventWrapper.content));
    final InvalidationListener invalidationListener = observable -> {
        eventWrapper.content = property.getValue();
        justInTimeConsumer.accept(eventWrapper.content);
        holdTimer.playFromStart();
    };
    property.addListener(invalidationListener);
    return invalidationListener;
}
 
Example 19
Source File: JFXNodeUtils.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
public static <T extends Event> EventHandler<? super T> addDelayedEventHandler(Node control, Duration delayTime,
                                                                               final EventType<T> eventType,
                                                                               final EventHandler<? super T> eventHandler) {
    Wrapper<T> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(delayTime);
    holdTimer.setOnFinished(finish -> eventHandler.handle(eventWrapper.content));
    final EventHandler<? super T> eventEventHandler = event -> {
        eventWrapper.content = event;
        holdTimer.playFromStart();
    };
    control.addEventHandler(eventType, eventEventHandler);
    return eventEventHandler;
}
 
Example 20
Source File: DamageNumber.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
public DamageNumber(String text, GameToken parent, int successiveHits) {
	this.parent = parent;
	this.setAlignment(Pos.CENTER);

	ImageView image = new ImageView(IconFactory.getImageUrl("common/splash.png"));
	image.setFitWidth(96);
	image.setFitHeight(96);
	
	if (successiveHits > 0) {
		double xOffset = -48 * successiveHits;
		setTranslateX(xOffset);
	}

	Text textShape = new Text(text);
	textShape.setFill(Color.WHITE);
	textShape.setStyle("-fx-font-size: 22pt; -fx-font-family: \"System\";-fx-font-weight: 900;-fx-stroke: black;-fx-stroke-width: 2;");

	setCache(true);
	setCacheHint(CacheHint.SPEED);

	getChildren().add(image);
	getChildren().add(textShape);
	parent.getAnchor().getChildren().add(this);

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);

	PauseTransition animation = new PauseTransition(Duration.seconds(1.2));
	animation.setOnFinished(this::onComplete);
	animation.play();
}