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

The following examples show how to use javafx.animation.TranslateTransition#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: HealingNumber.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
public HealingNumber(String text, GameToken parent) {
	this.parent = parent;

	setText(text);
	setFill(Color.GREEN);
	setStyle("-fx-font-size: 28pt; -fx-font-family: \"System\";-fx-font-weight: bolder;-fx-stroke: black;-fx-stroke-width: 2;");

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

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

	NotificationProxy.sendNotification(GameNotification.ANIMATION_STARTED);
	TranslateTransition animation = new TranslateTransition(Duration.seconds(0.5), this);
	animation.setToY(-30);
	animation.setOnFinished(this::onComplete);
	animation.play();
}
 
Example 2
Source File: Workbench.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private TranslateTransition slideOut(Region overlay) {
  TranslateTransition close = new TranslateTransition(
      new Duration(ANIMATION_DURATION_DRAWER_CLOSE), overlay);
  close.setOnFinished(event -> {
    overlay.setVisible(false);
    LOGGER.trace(
        "Overlay LayoutX: " + overlay.getLayoutX() + " TranslateX: " + overlay.getTranslateX());
  });
  return close;
}
 
Example 3
Source File: SlideShowController.java    From FXMaterialDesign with MIT License 5 votes vote down vote up
private void nextSlide(byte indexOfSlide) {
    lblPageNumber.setText(indexOfSlide + lblPageNumber.getText().substring(1));
    switch (indexOfSlide) {
        case 2:
            slide2.setVisible(true);
            TranslateTransition tt1 = new TranslateTransition(Duration.millis(800));
            tt1.setNode(slide1);
            tt1.setFromX(0.0);
            tt1.setToX(-384.0);
            tt1.setAutoReverse(false);
            tt1.play();
            
            tt1.setOnFinished(e -> {
                slide1.setVisible(false);
            });
            btnPrevious.setId("btn2");
            btnNext.setId("btn2");
            break;
        case 3:
            slide3.setVisible(true);
            TranslateTransition tt2 = new TranslateTransition(Duration.millis(800));
            tt2.setNode(slide2);
            tt2.setFromX(0.0);
            tt2.setToX(-384.0);
            tt2.setAutoReverse(false);
            tt2.play();
            
            tt2.setOnFinished(e -> {
                slide2.setVisible(false);
            });
            btnPrevious.setId("btn3");
            btnNext.setId("btn3");
            break;
            
    }
}
 
Example 4
Source File: SlideShowController.java    From FXMaterialDesign with MIT License 5 votes vote down vote up
private void previousSlide(byte indexOfSlide) {
    lblPageNumber.setText(indexOfSlide + lblPageNumber.getText().substring(1));
    switch (indexOfSlide) {
        case 1:
            slide1.setVisible(true);
            TranslateTransition tt1 = new TranslateTransition(Duration.millis(800));
            tt1.setNode(slide1);
            tt1.setFromX(-384.0);
            tt1.setToX(0.0);
            tt1.setAutoReverse(false);
            tt1.play();
            
            tt1.setOnFinished(e -> {
                slide2.setVisible(false);
                btnPrevious.setId("btn1");
                btnNext.setId("btn1");
            });
            break;
        case 2:
            slide2.setVisible(true);
            TranslateTransition tt2 = new TranslateTransition(Duration.millis(800));
            tt2.setNode(slide2);
            tt2.setFromX(-384.0);
            tt2.setToX(0.0);
            tt2.setAutoReverse(false);
            tt2.play();
            
            tt2.setOnFinished(e -> {
                slide3.setVisible(false);
                btnPrevious.setId("btn2");
                btnNext.setId("btn2");
            });
            break;
    }
}
 
Example 5
Source File: StepperTouchController.java    From FXMaterialDesign with MIT License 5 votes vote down vote up
@FXML
private void onAdd() {
    if(Integer.parseInt(txtCounter.getText()) == 9)
        return;

    TranslateTransition tt = new TranslateTransition(Duration.millis(500), paneCounter);
    tt.setToX(115);
    tt.play();
    tt.setOnFinished(e -> {
        txtCounter.setText(String.valueOf(Integer.parseInt(txtCounter.getText()) + 1));
        TranslateTransition tt2 = new TranslateTransition(Duration.millis(500), paneCounter);
        tt2.setToX(0);
        tt2.play();
    });
}
 
Example 6
Source File: StepperTouchController.java    From FXMaterialDesign with MIT License 5 votes vote down vote up
@FXML
private void onSub() {
    if(Integer.parseInt(txtCounter.getText()) == 0)
        return;

    TranslateTransition tt = new TranslateTransition(Duration.millis(500), paneCounter);
    tt.setToX(-115);
    tt.play();
    tt.setOnFinished(e -> {
        txtCounter.setText(String.valueOf(Integer.parseInt(txtCounter.getText()) - 1));
        TranslateTransition tt2 = new TranslateTransition(Duration.millis(500), paneCounter);
        tt2.setToX(0);
        tt2.play();
    });
}
 
Example 7
Source File: AnimatedTableRow.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private TranslateTransition createAndConfigureAnimation(
		final TableView<Person> sourceTable,
		final TableView<Person> destinationTable,
		final Pane commonTableAncestor, final TableRow<Person> row,
		final ImageView imageView, final Point2D animationStartPoint,
		Point2D animationEndPoint) {
	final TranslateTransition transition = new TranslateTransition(ANIMATION_DURATION, imageView);
	// At end of animation, actually move data, and remove animated image
	transition.setOnFinished(createAnimationFinishedHandler(sourceTable, destinationTable, commonTableAncestor, row.getItem(), imageView));
	// configure transition
	transition.setByX(animationEndPoint.getX() - animationStartPoint.getX()); // absolute translation, computed from coords relative to Scene
	transition.setByY(animationEndPoint.getY() - animationStartPoint.getY()); // absolute translation, computed from coords relative to Scene
	return transition;
}
 
Example 8
Source File: Connect4App.java    From FXTutorials with MIT License 5 votes vote down vote up
private void placeDisc(Disc disc, int column) {
    int row = ROWS - 1;
    do {
        if (!getDisc(column, row).isPresent())
            break;

        row--;
    } while (row >= 0);

    if (row < 0)
        return;

    grid[column][row] = disc;
    discRoot.getChildren().add(disc);
    disc.setTranslateX(column * (TILE_SIZE + 5) + TILE_SIZE / 4);

    final int currentRow = row;

    TranslateTransition animation = new TranslateTransition(Duration.seconds(0.5), disc);
    animation.setToY(row * (TILE_SIZE + 5) + TILE_SIZE / 4);
    animation.setOnFinished(e -> {
        if (gameEnded(column, currentRow)) {
            gameOver();
        }

        redMove = !redMove;
    });
    animation.play();
}
 
Example 9
Source File: Main.java    From FXTutorials with MIT License 4 votes vote down vote up
public void hide() {
    TranslateTransition tt = new TranslateTransition(Duration.seconds(0.5), this);
    tt.setToX(-300);
    tt.setOnFinished(event -> setVisible(false));
    tt.play();
}