Search in sources :

Example 21 with Duration

use of javafx.util.Duration in project lttng-scope by lttng.

the class LoadingOverlay method fadeIn.

public synchronized void fadeIn() {
    if (fCurrentFadeIn != null) {
        /* We're already fading in, let it continue. */
        return;
    }
    if (fCurrentFadeOut != null) {
        /*
             * Don't use stop() because that would revert to the initial opacity
             * right away.
             */
        fCurrentFadeOut.pause();
        fCurrentFadeOut = null;
    }
    double fullOpacity = fOpts.loadingOverlayFullOpacity.get();
    double fullFadeInDuration = fOpts.loadingOverlayFadeInDuration.get();
    double startOpacity = getOpacity();
    /* Do a rule-of-three to determine the duration of fade-in we need. */
    double neededDuration = ((fullOpacity - startOpacity) / fullOpacity) * fullFadeInDuration;
    FadeTransition fadeIn = new FadeTransition(new Duration(neededDuration), this);
    fadeIn.setFromValue(startOpacity);
    fadeIn.setToValue(fullOpacity);
    fadeIn.play();
    fCurrentFadeIn = fadeIn;
}
Also used : FadeTransition(javafx.animation.FadeTransition) Duration(javafx.util.Duration)

Example 22 with Duration

use of javafx.util.Duration in project drbookings by DrBookings.

the class RoomDetailsController method setTooltipTimes.

private static void setTooltipTimes(final Tooltip obj) {
    try {
        final Class<?> clazz = obj.getClass().getDeclaredClasses()[0];
        final Constructor<?> constructor = clazz.getDeclaredConstructor(Duration.class, Duration.class, Duration.class, boolean.class);
        constructor.setAccessible(true);
        final Object tooltipBehavior = // open
        constructor.newInstance(// open
        new Duration(50), // visible
        new Duration(5000), // close
        new Duration(200), false);
        final Field fieldBehavior = obj.getClass().getDeclaredField("BEHAVIOR");
        fieldBehavior.setAccessible(true);
        fieldBehavior.set(obj, tooltipBehavior);
    } catch (final Exception e) {
        logger.error(e.getLocalizedMessage(), e);
    }
}
Also used : TextField(javafx.scene.control.TextField) Field(java.lang.reflect.Field) Duration(javafx.util.Duration)

Example 23 with Duration

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

the class MainController method init.

/**
 * init fxml when loaded.
 */
@PostConstruct
public void init() throws Exception {
    // init the title hamburger icon
    final JFXTooltip burgerTooltip = new JFXTooltip("Open drawer");
    drawer.setOnDrawerOpening(e -> {
        final Transition animation = titleBurger.getAnimation();
        burgerTooltip.setText("Close drawer");
        animation.setRate(1);
        animation.play();
    });
    drawer.setOnDrawerClosing(e -> {
        final Transition animation = titleBurger.getAnimation();
        burgerTooltip.setText("Open drawer");
        animation.setRate(-1);
        animation.play();
    });
    titleBurgerContainer.setOnMouseClicked(e -> {
        if (drawer.isClosed() || drawer.isClosing()) {
            drawer.open();
        } else {
            drawer.close();
        }
    });
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/ui/popup/MainPopup.fxml"));
    loader.setController(new InputController());
    toolbarPopup = new JFXPopup(loader.load());
    optionsBurger.setOnMouseClicked(e -> toolbarPopup.show(optionsBurger, PopupVPosition.TOP, PopupHPosition.RIGHT, -12, 15));
    JFXTooltip.setVisibleDuration(Duration.millis(3000));
    JFXTooltip.install(titleBurgerContainer, burgerTooltip, Pos.BOTTOM_CENTER);
    // create the inner flow and content
    context = new ViewFlowContext();
    // set the default controller
    Flow innerFlow = new Flow(ButtonController.class);
    final FlowHandler flowHandler = innerFlow.createHandler(context);
    context.register("ContentFlowHandler", flowHandler);
    context.register("ContentFlow", innerFlow);
    final Duration containerAnimationDuration = Duration.millis(320);
    drawer.setContent(flowHandler.start(new ExtendedAnimatedFlowContainer(containerAnimationDuration, SWIPE_LEFT)));
    context.register("ContentPane", drawer.getContent().get(0));
    // side controller will add links to the content flow
    Flow sideMenuFlow = new Flow(SideMenuController.class);
    final FlowHandler sideMenuFlowHandler = sideMenuFlow.createHandler(context);
    drawer.setSidePane(sideMenuFlowHandler.start(new ExtendedAnimatedFlowContainer(containerAnimationDuration, SWIPE_LEFT)));
}
Also used : ExtendedAnimatedFlowContainer(demos.datafx.ExtendedAnimatedFlowContainer) JFXPopup(com.jfoenix.controls.JFXPopup) ViewFlowContext(io.datafx.controller.flow.context.ViewFlowContext) FXMLViewFlowContext(io.datafx.controller.flow.context.FXMLViewFlowContext) Transition(javafx.animation.Transition) Duration(javafx.util.Duration) JFXTooltip(com.jfoenix.controls.JFXTooltip) FlowHandler(io.datafx.controller.flow.FlowHandler) FXMLLoader(javafx.fxml.FXMLLoader) Flow(io.datafx.controller.flow.Flow) PostConstruct(javax.annotation.PostConstruct)

Example 24 with Duration

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

the class JFXAnimationTimer method addKeyFrame.

public void addKeyFrame(JFXKeyFrame keyFrame) throws Exception {
    if (isRunning()) {
        throw new Exception("Can't update animation timer while running");
    }
    Duration duration = keyFrame.getDuration();
    final Set<JFXKeyValue<?>> keyValuesSet = keyFrame.getValues();
    if (!keyValuesSet.isEmpty()) {
        final AnimationHandler handler = new AnimationHandler(duration, keyFrame.getAnimateCondition(), keyFrame.getValues());
        animationHandlers.add(handler);
        mutableFrames.put(keyFrame, handler);
    }
}
Also used : Duration(javafx.util.Duration)

Example 25 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, Consumer<T> justInTimeConsumer, Consumer<T> delayedConsumer) {
    Wrapper<T> eventWrapper = new Wrapper<>();
    PauseTransition holdTimer = new PauseTransition(delayTime);
    holdTimer.setOnFinished(event -> delayedConsumer.accept(eventWrapper.content));
    final InvalidationListener invalidationListener = observable -> {
        eventWrapper.content = property.getValue();
        justInTimeConsumer.accept(eventWrapper.content);
        holdTimer.playFromStart();
    };
    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