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

The following examples show how to use javafx.animation.TranslateTransition#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: 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: MKXMenuApp.java    From FXTutorials with MIT License 6 votes vote down vote up
private Node createMiddleContent() {
    String title = "MKX Menu App";
    HBox letters = new HBox(0);
    letters.setAlignment(Pos.CENTER);
    for (int i = 0; i < title.length(); i++) {
        Text letter = new Text(title.charAt(i) + "");
        letter.setFont(FONT);
        letter.setFill(Color.WHITE);
        letters.getChildren().add(letter);

        TranslateTransition tt = new TranslateTransition(Duration.seconds(2), letter);
        tt.setDelay(Duration.millis(i * 50));
        tt.setToY(-25);
        tt.setAutoReverse(true);
        tt.setCycleCount(TranslateTransition.INDEFINITE);
        tt.play();
    }

    return letters;
}
 
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: 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 8
Source File: MainController.java    From green_android with GNU General Public License v3.0 4 votes vote down vote up
public void restoreFromSeedAnimation() {
    // Buttons slide out ...
    TranslateTransition leave = new TranslateTransition(Duration.millis(1200), controlsBox);
    leave.setByY(80.0);
    leave.play();
}
 
Example 9
Source File: MainController.java    From thunder with GNU Affero General Public License v3.0 4 votes vote down vote up
public void restoreFromSeedAnimation () {
    // Buttons slide out ...
    TranslateTransition leave = new TranslateTransition(Duration.millis(1200), controlsBox);
    leave.setByY(80.0);
    leave.play();
}
 
Example 10
Source File: MainController.java    From GreenBits with GNU General Public License v3.0 4 votes vote down vote up
public void restoreFromSeedAnimation() {
    // Buttons slide out ...
    TranslateTransition leave = new TranslateTransition(Duration.millis(1200), controlsBox);
    leave.setByY(80.0);
    leave.play();
}
 
Example 11
Source File: MainController.java    From thundernetwork with GNU Affero General Public License v3.0 4 votes vote down vote up
public void restoreFromSeedAnimation () {
    // Buttons slide out ...
    TranslateTransition leave = new TranslateTransition(Duration.millis(1200), controlsBox);
    leave.setByY(80.0);
    leave.play();
}
 
Example 12
Source File: Main.java    From FXTutorials with MIT License 4 votes vote down vote up
public void show() {
    setVisible(true);
    TranslateTransition tt = new TranslateTransition(Duration.seconds(0.5), this);
    tt.setToX(0);
    tt.play();
}
 
Example 13
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();
}
 
Example 14
Source File: Tutorial.java    From FXTutorials with MIT License 4 votes vote down vote up
private Parent createContent() {
    Cube c = new Cube(1, Color.GREEN);
    c.setTranslateX(-1);
    c.setRotationAxis(Rotate.Y_AXIS);
    c.setRotate(45);

    Cube c2 = new Cube(1, Color.BLUE);
    c2.setTranslateX(1);
    c2.setRotationAxis(Rotate.Y_AXIS);
    c2.setRotate(45);

    Cube c3 = new Cube(1, Color.RED);
    c3.setRotationAxis(Rotate.Y_AXIS);
    c3.setRotate(45);

    camera = new PerspectiveCamera(true);
    translate = new Translate(0, 0, -10);
    rotate = new Rotate(0, new Point3D(0, 1, 0));
    camera.getTransforms().addAll(translate, rotate);

    PointLight light = new PointLight(Color.WHITE);
    light.setTranslateX(3);
    light.setTranslateZ(-5);

    TranslateTransition tt = new TranslateTransition(Duration.seconds(2), light);
    tt.setFromX(-3);
    tt.setToX(3);
    tt.setAutoReverse(true);
    tt.setCycleCount(Animation.INDEFINITE);

    AmbientLight globalLight = new AmbientLight(Color.WHITE.deriveColor(0, 1, 0.2, 1));


    worldRoot.getChildren().addAll(c, c2, c3, globalLight, light);

    SubScene subScene = new SubScene(worldRoot, 800, 600, true, SceneAntialiasing.BALANCED);
    subScene.setCamera(camera);

    tt.play();

    return new Group(new Rectangle(800, 600), subScene);
}