Java Code Examples for javafx.animation.ScaleTransition#setToX()

The following examples show how to use javafx.animation.ScaleTransition#setToX() . 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: SpaceInvadersController.java    From FXGLGames with MIT License 6 votes vote down vote up
private Animation getAnimationLoseLife(Texture texture) {
    texture.setFitWidth(64);
    texture.setFitHeight(64);

    Viewport viewport = gameScene.getViewport();

    TranslateTransition tt = new TranslateTransition(Duration.seconds(0.66), texture);
    tt.setToX(viewport.getWidth() / 2 - texture.getFitWidth() / 2);
    tt.setToY(viewport.getHeight() / 2 - texture.getFitHeight() / 2);

    ScaleTransition st = new ScaleTransition(Duration.seconds(0.66), texture);
    st.setToX(0);
    st.setToY(0);

    return new SequentialTransition(tt, st);
}
 
Example 2
Source File: LaunchScreeenController.java    From FakeImageDetection with GNU General Public License v3.0 6 votes vote down vote up
private void animate() {
    TranslateTransition tt = new TranslateTransition(Duration.millis(duration), load_image_button);
    TranslateTransition tLogo = new TranslateTransition(Duration.millis(duration), christopher);
    TranslateTransition tDesc = new TranslateTransition(Duration.millis(duration), description);

    ScaleTransition st = new ScaleTransition(Duration.millis(duration), load_image_button);
    st.setToX(3);
    st.setToY(3);

    tt.setByY(-180f);

    tLogo.setToY(50);
    tDesc.setToY(500);
    buttonParallelTransition = new ParallelTransition(load_image_button, st, tt, tLogo, tDesc);

    buttonParallelTransition.play();
    buttonParallelTransition.setOnFinished((e) -> {
        load_image_button.setOpacity(1);
    });
}
 
Example 3
Source File: SpaceInvadersController.java    From FXGLGames with MIT License 6 votes vote down vote up
private Animation getAnimationLoseLife(Texture texture) {
    texture.setFitWidth(64);
    texture.setFitHeight(64);

    Viewport viewport = gameScene.getViewport();

    TranslateTransition tt = new TranslateTransition(Duration.seconds(0.66), texture);
    tt.setToX(viewport.getWidth() / 2 - texture.getFitWidth() / 2);
    tt.setToY(viewport.getHeight() / 2 - texture.getFitHeight() / 2);

    ScaleTransition st = new ScaleTransition(Duration.seconds(0.66), texture);
    st.setToX(0);
    st.setToY(0);

    return new SequentialTransition(tt, st);
}
 
Example 4
Source File: InternalWindow.java    From desktoppanefx with Apache License 2.0 5 votes vote down vote up
private ScaleTransition hideWindow() {
    ScaleTransition st = new ScaleTransition(Duration.millis(100), this);
    st.setToX(0);
    st.setToY(0);
    st.setByX(1);
    st.setByY(1);
    st.setCycleCount(1);
    return st;
}
 
Example 5
Source File: GameManager.java    From util4j with Apache License 2.0 5 votes vote down vote up
/**
 * Animation that creates a fade in effect when a tile is added to the game 
 * by increasing the tile scale from 0 to 100% 
 * @param tile to be animated
 * @return a scale transition 
 */
private ScaleTransition animateNewlyAddedTile(Tile tile) {
    final ScaleTransition scaleTransition = new ScaleTransition(ANIMATION_NEWLY_ADDED_TILE, tile);
    scaleTransition.setToX(1.0);
    scaleTransition.setToY(1.0);
    scaleTransition.setInterpolator(Interpolator.EASE_OUT);
    scaleTransition.setOnFinished(e -> {
        // after last movement on full grid, check if there are movements available
        if (this.gameGrid.values().parallelStream().noneMatch(Objects::isNull) && mergeMovementsAvailable() == 0 ) {
            board.setGameOver(true);
        }
    });
    return scaleTransition;
}
 
Example 6
Source File: GameManager.java    From util4j with Apache License 2.0 5 votes vote down vote up
/**
 * Animation that creates a pop effect when two tiles merge
 * by increasing the tile scale to 120% at the middle, and then going back to 100% 
 * @param tile to be animated
 * @return a sequential transition 
 */
private SequentialTransition animateMergedTile(Tile tile) {
    final ScaleTransition scale0 = new ScaleTransition(ANIMATION_MERGED_TILE, tile);
    scale0.setToX(1.2);
    scale0.setToY(1.2);
    scale0.setInterpolator(Interpolator.EASE_IN);

    final ScaleTransition scale1 = new ScaleTransition(ANIMATION_MERGED_TILE, tile);
    scale1.setToX(1.0);
    scale1.setToY(1.0);
    scale1.setInterpolator(Interpolator.EASE_OUT);

    return new SequentialTransition(scale0, scale1);
}
 
Example 7
Source File: LaunchScreeenController.java    From FakeImageDetection with GNU General Public License v3.0 5 votes vote down vote up
private void startSimpleMetaDataAnimation() {
    float animationExtension = 3.25f;
    bulgingTransition = new ScaleTransition(Duration.millis(1000), load_image_button);
    bulgingTransition.setToX(animationExtension);
    bulgingTransition.setToY(animationExtension);
    bulgingTransition.autoReverseProperty().setValue(true);
    bulgingTransition.setCycleCount(2);
    bulgingTransition.play();
    load_image_button.setFont(Font.font("Roboto", FontWeight.NORMAL, 8));
    load_image_button.setText("Checking Metadata..");

}
 
Example 8
Source File: NeuralnetInterfaceController.java    From FakeImageDetection with GNU General Public License v3.0 5 votes vote down vote up
private void startAnimation() {
    navigation_button.setText("Applying ELA on Image");
    float animationExtension = 1.2f;
    bulgingTransition = new ScaleTransition(Duration.millis(2000), navigation_button);
    bulgingTransition.setToX(animationExtension);
    bulgingTransition.setToY(animationExtension);
    bulgingTransition.autoReverseProperty().setValue(true);
    bulgingTransition.setCycleCount(bulgingTransition.INDEFINITE);
    bulgingTransition.play();
}
 
Example 9
Source File: GameManager.java    From Game2048FX with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Animation that creates a fade in effect when a tile is added to the game
 * by increasing the tile scale from 0 to 100%
 * @param tile to be animated
 * @return a scale transition
 */
private ScaleTransition animateNewlyAddedTile(Tile tile) {
    final ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(125*timeFactor), tile);
    scaleTransition.setToX(1.0);
    scaleTransition.setToY(1.0);
    scaleTransition.setInterpolator(Interpolator.EASE_OUT);
    return scaleTransition;
}
 
Example 10
Source File: GameManager.java    From Game2048FX with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Animation that creates a pop effect when two tiles merge
 * by increasing the tile scale to 120% at the middle, and then going back to 100%
 * @param tile to be animated
 * @return a sequential transition
 */
private SequentialTransition animateMergedTile(Tile tile) {
    final ScaleTransition scale0 = new ScaleTransition(Duration.millis(80*timeFactor), tile);
    scale0.setToX(1.2);
    scale0.setToY(1.2);
    scale0.setInterpolator(Interpolator.EASE_IN);

    final ScaleTransition scale1 = new ScaleTransition(Duration.millis(80*timeFactor), tile);
    scale1.setToX(1.0);
    scale1.setToY(1.0);
    scale1.setInterpolator(Interpolator.EASE_OUT);

    return new SequentialTransition(scale0, scale1);
}
 
Example 11
Source File: FXUtils.java    From TerasologyLauncher with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a {@link javafx.animation.ScaleTransition} with the given factor for the specified node element.
 *
 * @param factor the scaling factor
 * @param node   the target node
 * @return a transition object
 */
static ScaleTransition createScaleTransition(final double factor, final Node node) {
    final ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(200), node);
    scaleTransition.setFromX(node.getScaleX());
    scaleTransition.setFromY(node.getScaleY());
    scaleTransition.setToX(factor);
    scaleTransition.setToY(factor);
    return scaleTransition;
}
 
Example 12
Source File: RadialMenu.java    From Enzo with Apache License 2.0 4 votes vote down vote up
public void click(final MenuItem CLICKED_ITEM) {
    List<Transition> transitions = new ArrayList<>(items.size() * 2);
    for (Parent node : items.keySet()) {
        if (items.get(node).equals(CLICKED_ITEM)) {
            // Add enlarge transition to selected item
            ScaleTransition enlargeItem = new ScaleTransition(Duration.millis(300), node);
            enlargeItem.setToX(5.0);
            enlargeItem.setToY(5.0);
            transitions.add(enlargeItem);
        } else {
            // Add shrink transition to all other items
            ScaleTransition shrinkItem = new ScaleTransition(Duration.millis(300), node);
            shrinkItem.setToX(0.0);
            shrinkItem.setToY(0.0);
            transitions.add(shrinkItem);
        }
        // Add fade out transition to every node
        FadeTransition fadeOutItem = new FadeTransition(Duration.millis(300), node);
        fadeOutItem.setToValue(0.0);
        transitions.add(fadeOutItem);
    }

    // Add rotate and fade transition to main menu button
    if (options.isButtonHideOnSelect()) {
        RotateTransition rotateMainButton = new RotateTransition(Duration.millis(300), mainMenuButton);
        rotateMainButton.setToAngle(225);
        transitions.add(rotateMainButton);
        FadeTransition fadeOutMainButton = new FadeTransition(Duration.millis(300), mainMenuButton);
        fadeOutMainButton.setToValue(0.0);
        transitions.add(fadeOutMainButton);
        ScaleTransition shrinkMainButton = new ScaleTransition(Duration.millis(300), mainMenuButton);
        shrinkMainButton.setToX(0.0);
        shrinkMainButton.setToY(0.0);
        transitions.add(shrinkMainButton);
    } else {
        RotateTransition rotateBackMainButton = new RotateTransition();
        rotateBackMainButton.setNode(cross);
        rotateBackMainButton.setToAngle(0);
        rotateBackMainButton.setDuration(Duration.millis(200));
        rotateBackMainButton.setInterpolator(Interpolator.EASE_BOTH);
        transitions.add(rotateBackMainButton);
        FadeTransition mainButtonFadeOut = new FadeTransition();
        mainButtonFadeOut.setNode(mainMenuButton);
        mainButtonFadeOut.setDuration(Duration.millis(100));
        mainButtonFadeOut.setToValue(options.getButtonAlpha());
        transitions.add(mainButtonFadeOut);
    }

    // Play all transitions in parallel
    ParallelTransition selectTransition = new ParallelTransition();
    selectTransition.getChildren().addAll(transitions);
    selectTransition.play();

    // Set menu state back to closed
    setState(State.CLOSED);
    mainMenuButton.setOpen(false);
}