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