Search in sources :

Example 11 with Duration

use of javafx.util.Duration in project trex-stateless-gui by cisco-system-traffic-generator.

the class TrexApp method speedupTooltip.

/**
 * Speeding up displaying tootlip for JDK 8 ref:
 * http://stackoverflow.com/questions/26854301/control-javafx-tooltip-delay
 */
private void speedupTooltip() {
    try {
        Tooltip tooltip = new Tooltip();
        Field fieldBehavior = tooltip.getClass().getDeclaredField("BEHAVIOR");
        fieldBehavior.setAccessible(true);
        Object objBehavior = fieldBehavior.get(tooltip);
        Field fieldTimer = objBehavior.getClass().getDeclaredField("activationTimer");
        fieldTimer.setAccessible(true);
        Timeline objTimer = (Timeline) fieldTimer.get(objBehavior);
        objTimer.getKeyFrames().clear();
        objTimer.getKeyFrames().add(new KeyFrame(new Duration(250)));
    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
        LOG.error(e);
    }
}
Also used : Field(java.lang.reflect.Field) Timeline(javafx.animation.Timeline) Tooltip(javafx.scene.control.Tooltip) KeyFrame(javafx.animation.KeyFrame) Duration(javafx.util.Duration)

Example 12 with Duration

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

the class ExtendedAnimatedFlowContainer 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) AnimatedFlowContainer(io.datafx.controller.flow.container.AnimatedFlowContainer) 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 13 with Duration

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

the class JFXNodeUtils method addDelayedEventHandler.

public static <T extends Event> EventHandler<? super T> addDelayedEventHandler(Node control, Duration delayTime, final EventType<T> eventType, final EventHandler<? super T> eventHandler) {
    Wrapper<T> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(delayTime);
    holdTimer.setOnFinished(finish -> eventHandler.handle(eventWrapper.content));
    final EventHandler<? super T> eventEventHandler = event -> {
        eventWrapper.content = event;
        holdTimer.playFromStart();
    };
    control.addEventHandler(eventType, eventEventHandler);
    return eventEventHandler;
}
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) PauseTransition(javafx.animation.PauseTransition)

Example 14 with Duration

use of javafx.util.Duration in project Smartcity-Smarthouse by TechnionYP5777.

the class StatusRegionBuilderImpl method addTimerStatusField.

/*
     * (non-Javadoc)
     * 
     * @see il.ac.technion.cs.smarthouse.developers_api.application_builder.
     * StatusRegionBuilder#addTimerStatusField(java.lang.String,
     * il.ac.technion.cs.smarthouse.developers_api.application_builder.
     * GuiBinderObject,
     * il.ac.technion.cs.smarthouse.developers_api.application_builder.
     * GuiBinderObject,
     * il.ac.technion.cs.smarthouse.developers_api.application_builder.
     * ColorRange)
     */
@Override
public StatusRegionBuilderImpl addTimerStatusField(String title, GuiBinderObject<Boolean> timerToggle, GuiBinderObject<Double> timerDuration, ColorRange<Double> d) {
    final Label timeLabel = createStatusLabel("");
    final Timeline timeline;
    final GuiBinderObject<Duration> time = new GuiBinderObject<>(Duration.ZERO);
    timeLabel.setText(0.0 + " [sec]");
    timeline = new Timeline(new KeyFrame(Duration.millis(100), ¢ -> {
        time.setData(time.getData().add(((KeyFrame) ¢.getSource()).getTime()));
        timerDuration.setData(time.getData().toSeconds());
        timeLabel.setText(timerDuration.getData() + " [sec]");
    }));
    timerToggle.addOnDataChangedListener(v -> {
        if (v.getData()) {
            timeline.setCycleCount(Animation.INDEFINITE);
            timeline.play();
        } else {
            timeline.stop();
            time.setData(Duration.ZERO);
            timerDuration.setData(time.getData().toSeconds());
            timeLabel.setText(timerDuration.getData() + " [sec]");
        }
    });
    if (d != null)
        timerDuration.addOnDataChangedListener(v -> setColor(v, d, timeLabel));
    addAppBuilderItem(new AppBuilderItem(title, timeLabel));
    return this;
}
Also used : ColorRange(il.ac.technion.cs.smarthouse.developers_api.application_builder.ColorRange) KeyFrame(javafx.animation.KeyFrame) Duration(javafx.util.Duration) Label(javafx.scene.control.Label) Font(javafx.scene.text.Font) Timeline(javafx.animation.Timeline) GuiBinderObject(il.ac.technion.cs.smarthouse.developers_api.application_builder.GuiBinderObject) StatusRegionBuilder(il.ac.technion.cs.smarthouse.developers_api.application_builder.StatusRegionBuilder) Animation(javafx.animation.Animation) Timeline(javafx.animation.Timeline) Label(javafx.scene.control.Label) KeyFrame(javafx.animation.KeyFrame) Duration(javafx.util.Duration) GuiBinderObject(il.ac.technion.cs.smarthouse.developers_api.application_builder.GuiBinderObject)

Example 15 with Duration

use of javafx.util.Duration in project SmartCity-Market by TechnionYP5777.

the class AbstractApplicationScreen method fadeTransition.

public static void fadeTransition(Node n) {
    FadeTransition x = new FadeTransition(new Duration(2000), n);
    x.setFromValue(0);
    x.setToValue(100);
    x.setCycleCount(1);
    x.setInterpolator(Interpolator.LINEAR);
    x.play();
}
Also used : FadeTransition(javafx.animation.FadeTransition) 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