Java Code Examples for javafx.animation.Animation#INDEFINITE

The following examples show how to use javafx.animation.Animation#INDEFINITE . 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: SpriteView.java    From quantumjava with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void startAnimation() {
    Timeline timeline = new Timeline(Animation.INDEFINITE,
        new KeyFrame(Duration.seconds(.25), new KeyValue(frame, 0)),
        new KeyFrame(Duration.seconds(.5), new KeyValue(frame, 1)),
        new KeyFrame(Duration.seconds(.75), new KeyValue(frame, 2)),
        new KeyFrame(Duration.seconds(1), new KeyValue(frame, 1))
    );
    timeline.onFinishedProperty().setValue(e -> timeline.play());
    timeline.play();
}
 
Example 2
Source File: SpriteView.java    From quantumjava with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void moveTo(Main.Location loc) {
    walking = new Timeline(Animation.INDEFINITE,
        new KeyFrame(Duration.seconds(.001), new KeyValue(direction, location.getValue().directionTo(loc))),
        new KeyFrame(Duration.seconds(.002), new KeyValue(location, loc)),
        new KeyFrame(Duration.seconds(1), new KeyValue(translateXProperty(), loc.getX() * Main.CELL_SIZE)),
        new KeyFrame(Duration.seconds(1), new KeyValue(translateYProperty(), loc.getY() * Main.CELL_SIZE)),
        new KeyFrame(Duration.seconds(.25), new KeyValue(frame, 0)),
        new KeyFrame(Duration.seconds(.5), new KeyValue(frame, 1)),
        new KeyFrame(Duration.seconds(.75), new KeyValue(frame, 2)),
        new KeyFrame(Duration.seconds(1), new KeyValue(frame, 1))
    );
    walking.setOnFinished(e -> {
        if (arrivalHandler != null) {
            arrivalHandler.handle(e);
        }
    });
    Platform.runLater(walking::play);
}
 
Example 3
Source File: SpriteView.java    From training with MIT License 6 votes vote down vote up
public void moveTo(Main.Location loc) {
    walking = new Timeline(Animation.INDEFINITE,
        new KeyFrame(Duration.seconds(.001), new KeyValue(direction, location.getValue().directionTo(loc))),
        new KeyFrame(Duration.seconds(.002), new KeyValue(location, loc)),
        new KeyFrame(Duration.seconds(1), new KeyValue(translateXProperty(), loc.getX() * Main.CELL_SIZE)),
        new KeyFrame(Duration.seconds(1), new KeyValue(translateYProperty(), loc.getY() * Main.CELL_SIZE)),
        new KeyFrame(Duration.seconds(.25), new KeyValue(frame, 0)),
        new KeyFrame(Duration.seconds(.5), new KeyValue(frame, 1)),
        new KeyFrame(Duration.seconds(.75), new KeyValue(frame, 2)),
        new KeyFrame(Duration.seconds(1), new KeyValue(frame, 1))
    );
    walking.setOnFinished(e -> {
        if (arrivalHandler != null) {
            arrivalHandler.handle(e);
        }
    });
    Application.invokeLater(walking::play);
}
 
Example 4
Source File: SpriteView.java    From quantumjava with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void startValueAnimation() {
    Timeline timeline = new Timeline(Animation.INDEFINITE,
            new KeyFrame(Duration.seconds(.25), new KeyValue(value, 0)),
            new KeyFrame(Duration.seconds(.5), new KeyValue(value, 1)),
            new KeyFrame(Duration.seconds(.75), new KeyValue(value, 2)),
            new KeyFrame(Duration.seconds(1), new KeyValue(value, 1))
    );
    timeline.onFinishedProperty().setValue(e -> timeline.play());
    timeline.play();
}
 
Example 5
Source File: SpriteView.java    From training with MIT License 5 votes vote down vote up
public void startAnimation() {
    Timeline timeline = new Timeline(Animation.INDEFINITE,
        new KeyFrame(Duration.seconds(.25), new KeyValue(frame, 0)),
        new KeyFrame(Duration.seconds(.5), new KeyValue(frame, 1)),
        new KeyFrame(Duration.seconds(.75), new KeyValue(frame, 2)),
        new KeyFrame(Duration.seconds(1), new KeyValue(frame, 1))
    );
    timeline.onFinishedProperty().setValue(e -> timeline.play());
    timeline.play();
}
 
Example 6
Source File: SVAnimation.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
public String getCycleCount() {
    return cycleCount == Animation.INDEFINITE ? "INDEFINITE" : Integer.toString(cycleCount);
}
 
Example 7
Source File: FxTimer.java    From bisq with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Prepares a (stopped) timer that lasts for {@code interval} and that executes the given action periodically
 * when the timer <em>ends</em>.
 */
public static Timer createPeriodic(java.time.Duration interval, Runnable action) {
    return new FxTimer(interval, interval, action, Animation.INDEFINITE);
}
 
Example 8
Source File: FxTimer.java    From bisq with GNU Affero General Public License v3.0 2 votes vote down vote up
/**
 * Prepares a (stopped) timer that lasts for {@code interval} and that executes the given action periodically
 * when the timer <em>starts</em>.
 */
public static Timer createPeriodic0(java.time.Duration interval, Runnable action) {
    return new FxTimer(java.time.Duration.ZERO, interval, action, Animation.INDEFINITE);
}
 
Example 9
Source File: FxTimer.java    From ReactFX with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Prepares a (stopped) timer that lasts for {@code interval} and that executes the given action periodically
 * when the timer <em>ends</em>.
 */
public static Timer createPeriodic(java.time.Duration interval, Runnable action) {
    return new FxTimer(interval, interval, action, Animation.INDEFINITE);
}
 
Example 10
Source File: FxTimer.java    From ReactFX with BSD 2-Clause "Simplified" License 2 votes vote down vote up
/**
 * Prepares a (stopped) timer that lasts for {@code interval} and that executes the given action periodically
 * when the timer <em>starts</em>.
 */
public static Timer createPeriodic0(java.time.Duration interval, Runnable action) {
    return new FxTimer(java.time.Duration.ZERO, interval, action, Animation.INDEFINITE);
}