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;
}
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);
}
}
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)));
}
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);
}
}
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;
}
Aggregations