Search in sources :

Example 26 with Duration

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

the class JFXNodeUtils method addDelayedPropertyInvalidationListener.

public static <T> InvalidationListener addDelayedPropertyInvalidationListener(ObservableValue<T> property, Duration delayTime, BiConsumer<T, InvalidationListener> consumer) {
    Wrapper<T> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(delayTime);
    final InvalidationListener invalidationListener = observable -> {
        eventWrapper.content = property.getValue();
        holdTimer.playFromStart();
    };
    holdTimer.setOnFinished(event -> consumer.accept(eventWrapper.content, invalidationListener));
    property.addListener(invalidationListener);
    return invalidationListener;
}
Also used : EventHandler(javafx.event.EventHandler) MouseEvent(javafx.scene.input.MouseEvent) UnmodifiableListSet(com.sun.javafx.collections.UnmodifiableListSet) InvalidationListener(javafx.beans.InvalidationListener) ArrayList(java.util.ArrayList) BackgroundFill(javafx.scene.layout.BackgroundFill) Locale(java.util.Locale) BiConsumer(java.util.function.BiConsumer) Direction(com.sun.javafx.scene.traversal.Direction) KeyCode(javafx.scene.input.KeyCode) Color(javafx.scene.paint.Color) Node(javafx.scene.Node) Event(javafx.event.Event) Set(java.util.Set) KeyEvent(javafx.scene.input.KeyEvent) Background(javafx.scene.layout.Background) EventType(javafx.event.EventType) Consumer(java.util.function.Consumer) Duration(javafx.util.Duration) List(java.util.List) Region(javafx.scene.layout.Region) PauseTransition(javafx.animation.PauseTransition) Paint(javafx.scene.paint.Paint) ObservableValue(javafx.beans.value.ObservableValue) Queue(java.util.Queue) ArrayDeque(java.util.ArrayDeque) InvalidationListener(javafx.beans.InvalidationListener) PauseTransition(javafx.animation.PauseTransition)

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