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

The following examples show how to use javafx.animation.PauseTransition#play() . 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: 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 2
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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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();
}