本文整理汇总了Java中org.reactfx.util.FxTimer.createPeriodic方法的典型用法代码示例。如果您正苦于以下问题:Java FxTimer.createPeriodic方法的具体用法?Java FxTimer.createPeriodic怎么用?Java FxTimer.createPeriodic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.reactfx.util.FxTimer
的用法示例。
在下文中一共展示了FxTimer.createPeriodic方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupNvidiaListener
import org.reactfx.util.FxTimer; //导入方法依赖的package包/类
private void setupNvidiaListener() {
log.log(Level.FINER, "Setting nvidia ram listener.");
EventStreams.nonNullValuesOf(nvidiaService.progressProperty())
.filter(vramUsage -> vramUsage.doubleValue() > 0)
.subscribe(vramUsage -> vramBar.setProgress(vramUsage.doubleValue()));
log.log(Level.FINER, "Setting nvidia timer.");
nvidiaTimer = FxTimer.createPeriodic(Duration.ofMillis(1000), () -> {
log.log(Level.FINER, "Timer: checking service");
if (nvidiaService == null || nvidiaService.isRunning())
return;
log.log(Level.FINER, "Timer: starting service");
nvidiaService.restart();
nvidiaTimer.restart();
});
nvidiaTimer.restart();
}
示例2: restartableTicks
import org.reactfx.util.FxTimer; //导入方法依赖的package包/类
/**
* Returns a {@link #ticks(Duration)} EventStream whose timer restarts whenever
* impulse emits an event.
* @param interval - the amount of time that passes until this stream emits its next tick
* @param impulse - the EventStream that resets this EventStream's internal timer
*/
public static EventStream<?> restartableTicks(Duration interval, EventStream<?> impulse) {
return new EventStreamBase<Void>() {
private final Timer timer = FxTimer.createPeriodic(
interval, () -> emit(null));
@Override
protected Subscription observeInputs() {
timer.restart();
return Subscription.multi(
impulse.subscribe(x -> timer.restart()),
timer::stop
);
}
};
}
示例3: setupOutputImageListeners
import org.reactfx.util.FxTimer; //导入方法依赖的package包/类
private void setupOutputImageListeners() {
imageView.fitWidthProperty().bind(imageViewSizer.widthProperty());
imageView.fitHeightProperty().bind(imageViewSizer.heightProperty());
log.log(Level.FINER, "Setting image timer.");
imageOutputTimer = FxTimer.createPeriodic(Duration.ofMillis(250), () -> {
log.log(Level.FINER, "Timer: checking service");
if (imageOutputService != null && !imageOutputService.isRunning()) {
imageOutputService.reset();
imageOutputService.start();
}
});
}
示例4: runPeriodically
import org.reactfx.util.FxTimer; //导入方法依赖的package包/类
@Override
public Timer runPeriodically(Duration interval, Runnable runnable) {
if (timer == null) {
timer = FxTimer.createPeriodic(interval, runnable);
timer.restart();
} else {
log.warn("runPeriodically called on an already running timer.");
}
return this;
}
示例5: ticks
import org.reactfx.util.FxTimer; //导入方法依赖的package包/类
/**
* Returns an event stream that emits periodic <i>ticks</i>. The first tick
* is emitted after {@code interval} amount of time has passed.
* The returned stream may only be used on the JavaFX application thread.
*
* <p>As with all lazily bound streams, ticks are emitted only when there
* is at least one subscriber to the returned stream. This means that to
* release associated resources, it suffices to unsubscribe from the
* returned stream.
*/
public static EventStream<?> ticks(Duration interval) {
return new EventStreamBase<Void>() {
private final Timer timer = FxTimer.createPeriodic(
interval, () -> emit(null));
@Override
protected Subscription observeInputs() {
timer.restart();
return timer::stop;
}
};
}