Search in sources :

Example 1 with Duration

use of javafx.util.Duration in project JFoenix by jfoenixadmin.

the class AnimatedFlowContainer method setViewContext.

@Override
public <U> void setViewContext(ViewContext<U> context) {
    updatePlaceholder(context.getRootNode());
    if (animation != null) {
        animation.stop();
    }
    animation = new Timeline();
    animation.getKeyFrames().addAll(animationProducer.apply(this));
    animation.getKeyFrames().add(new KeyFrame(duration, (e) -> clearPlaceholder()));
    animation.play();
}
Also used : Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) FlowContainer(io.datafx.controller.flow.FlowContainer) Node(javafx.scene.Node) Timeline(javafx.animation.Timeline) WritableImage(javafx.scene.image.WritableImage) ViewContext(io.datafx.controller.context.ViewContext) SnapshotParameters(javafx.scene.SnapshotParameters) StackPane(javafx.scene.layout.StackPane) Function(java.util.function.Function) Duration(javafx.util.Duration) List(java.util.List) ImageView(javafx.scene.image.ImageView) ContainerAnimations(io.datafx.controller.flow.container.ContainerAnimations) Image(javafx.scene.image.Image) Timeline(javafx.animation.Timeline) KeyFrame(javafx.animation.KeyFrame)

Example 2 with Duration

use of javafx.util.Duration in project JFoenix by jfoenixadmin.

the class JFXNodesList method animateList.

/**
	 * animates the list to show/hide the nodes
	 */
public void animateList() {
    expanded = !expanded;
    if (animateTimeline.getStatus().equals(Status.RUNNING))
        animateTimeline.stop();
    animateTimeline.getKeyFrames().clear();
    double duration = 120 / (double) this.getChildren().size();
    // show child nodes 
    if (expanded)
        this.getChildren().forEach(child -> child.setVisible(true));
    // add child nodes animation
    for (int i = 1; i < this.getChildren().size(); i++) {
        Node child = this.getChildren().get(i);
        ArrayList<KeyValue> keyValues = animationsMap.get(child).call(expanded);
        animateTimeline.getKeyFrames().add(new KeyFrame(Duration.millis(i * duration), keyValues.toArray(new KeyValue[keyValues.size()])));
    }
    // add 1st element animation
    ArrayList<KeyValue> keyValues = animationsMap.get(this.getChildren().get(0)).call(expanded);
    animateTimeline.getKeyFrames().add(new KeyFrame(Duration.millis(160), keyValues.toArray(new KeyValue[keyValues.size()])));
    // hide child nodes to allow mouse events on the nodes behind them
    if (!expanded) {
        animateTimeline.setOnFinished((finish) -> {
            for (int i = 1; i < this.getChildren().size(); i++) this.getChildren().get(i).setVisible(false);
        });
    } else {
        animateTimeline.setOnFinished(null);
    }
    animateTimeline.play();
}
Also used : Button(javafx.scene.control.Button) KeyFrame(javafx.animation.KeyFrame) Status(javafx.animation.Animation.Status) Node(javafx.scene.Node) Timeline(javafx.animation.Timeline) StackPane(javafx.scene.layout.StackPane) HashMap(java.util.HashMap) VBox(javafx.scene.layout.VBox) ArrayList(java.util.ArrayList) Duration(javafx.util.Duration) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) KeyValue(javafx.animation.KeyValue) Callback(javafx.util.Callback) KeyValue(javafx.animation.KeyValue) Node(javafx.scene.Node) KeyFrame(javafx.animation.KeyFrame)

Example 3 with Duration

use of javafx.util.Duration in project jphp by jphp-compiler.

the class UXMediaPlayer method getCurrentTimeAsPercent.

@Getter
public long getCurrentTimeAsPercent() {
    Duration duration = getWrappedObject().getMedia().getDuration();
    Duration currentTime = getWrappedObject().getCurrentTime();
    return Math.round(currentTime.toMillis() * 100.0 / duration.toMillis());
}
Also used : Duration(javafx.util.Duration) Getter(php.runtime.annotation.Reflection.Getter)

Example 4 with Duration

use of javafx.util.Duration in project jphp by jphp-compiler.

the class UXMediaPlayer method setCurrentTimeAsPercent.

@Setter
public void setCurrentTimeAsPercent(long percent) {
    if (percent > 100) {
        percent = 100;
    }
    Duration duration = getWrappedObject().getMedia().getDuration();
    getWrappedObject().seek(Duration.millis(Math.round(duration.toMillis() * percent / 100.0)));
}
Also used : Duration(javafx.util.Duration) Setter(php.runtime.annotation.Reflection.Setter)

Example 5 with Duration

use of javafx.util.Duration in project fx2048 by brunoborges.

the class Board method animateScore.

public void animateScore() {
    if (gameMovePoints.get() == 0) {
        return;
    }
    final Timeline timeline = new Timeline();
    lblPoints.setText("+" + gameMovePoints.getValue().toString());
    lblPoints.setOpacity(1);
    double posX = vScore.localToScene(vScore.getWidth() / 2d, 0).getX();
    lblPoints.setTranslateX(0);
    lblPoints.setTranslateX(lblPoints.sceneToLocal(posX, 0).getX() - lblPoints.getWidth() / 2d);
    lblPoints.setLayoutY(20);
    final KeyValue kvO = new KeyValue(lblPoints.opacityProperty(), 0);
    final KeyValue kvY = new KeyValue(lblPoints.layoutYProperty(), 100);
    Duration animationDuration = Duration.millis(600);
    final KeyFrame kfO = new KeyFrame(animationDuration, kvO);
    final KeyFrame kfY = new KeyFrame(animationDuration, kvY);
    timeline.getKeyFrames().add(kfO);
    timeline.getKeyFrames().add(kfY);
    timeline.play();
}
Also used : Timeline(javafx.animation.Timeline) KeyValue(javafx.animation.KeyValue) KeyFrame(javafx.animation.KeyFrame) Duration(javafx.util.Duration)

Aggregations

Duration (javafx.util.Duration)26 KeyFrame (javafx.animation.KeyFrame)11 Timeline (javafx.animation.Timeline)11 Node (javafx.scene.Node)8 KeyValue (javafx.animation.KeyValue)6 Color (javafx.scene.paint.Color)6 List (java.util.List)5 InvalidationListener (javafx.beans.InvalidationListener)5 EventHandler (javafx.event.EventHandler)5 ArrayList (java.util.ArrayList)4 ActionEvent (javafx.event.ActionEvent)4 Image (javafx.scene.image.Image)4 ImageView (javafx.scene.image.ImageView)4 Region (javafx.scene.layout.Region)4 UnmodifiableListSet (com.sun.javafx.collections.UnmodifiableListSet)3 Direction (com.sun.javafx.scene.traversal.Direction)3 FadeTransition (javafx.animation.FadeTransition)3 Button (javafx.scene.control.Button)3 StackPane (javafx.scene.layout.StackPane)3 MediaFile (com.negativevr.media_library.files.MediaFile)2