get JavaFX Translate Transition - Java JavaFX

Java examples for JavaFX:Animation

Description

get JavaFX Translate Transition

Demo Code


//package com.java2s;

import javafx.animation.TranslateTransition;

import javafx.scene.Group;
import javafx.util.Duration;

public class Main {
    private static TranslateTransition getTranslateTransition(
            final int xCoord, final int numberIndex, Group group,
            final boolean numberType) {
        TranslateTransition transition = new TranslateTransition(
                Duration.millis((8 - numberIndex) * 300), group);

        transition.setFromY(getYCoordForNumberType(numberType));
        transition.setToY(getYCoordForNumberType(numberType));
        transition.setFromX(650);//ww  w  .ja  v  a2  s .co  m
        transition.setToX(xCoord);
        transition.setCycleCount(1);
        transition.setAutoReverse(false);

        return transition;
    }

    private static int getYCoordForNumberType(final boolean numberType) {
        if (numberType)
            return 110;
        else
            return 490;
    }
}

Related Tutorials