• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java FxTimer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.reactfx.util.FxTimer的典型用法代码示例。如果您正苦于以下问题:Java FxTimer类的具体用法?Java FxTimer怎么用?Java FxTimer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FxTimer类属于org.reactfx.util包,在下文中一共展示了FxTimer类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: setScale

import org.reactfx.util.FxTimer; //导入依赖的package包/类
/**
 * Set the maps scale.
 *
 * @param scale of map
 */
public void setScale(double scale) {
    if (scale < ZOOM_MAX) {
        if (scale > ZOOM_MIN) {
            this.scale = scale;
        } else {
            this.scale = ZOOM_MIN;
        }
    } else {
        this.scale = ZOOM_MAX;
    }

    setDragMode(true);
    redraw();

    lastScrollTime = System.currentTimeMillis();

    FxTimer.runLater(Duration.ofSeconds(REDRAW_DELAY_SECONDS), () -> {
        if (isInDragMode() && System.currentTimeMillis() - lastScrollTime > REDRAW_DELAY_SECONDS * 500) {
            setDragMode(false);
            redraw();
        }
    });
}
 
开发者ID:floric,项目名称:HTWK_Visu,代码行数:29,代码来源:BasicCanvas.java


示例2: 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();
}
 
开发者ID:cameronleger,项目名称:neural-style-gui,代码行数:19,代码来源:MainController.java


示例3: 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
            );
        }
    };
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:22,代码来源:EventStreams.java


示例4: restartableTicks0

import org.reactfx.util.FxTimer; //导入依赖的package包/类
/**
 * Returns a {@link #ticks0(Duration)} EventStream whose timer restarts whenever
 * impulse emits an event. Note: since {@link #ticks0(Duration)} is used, restarting
 * the timer will make the returned EventStream immediately emit a new tick.
 * @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<?> restartableTicks0(Duration interval, EventStream<?> impulse) {
    return new EventStreamBase<Void>() {
        private final Timer timer = FxTimer.createPeriodic0(
                interval, () -> emit(null));

        @Override
        protected Subscription observeInputs() {
            timer.restart();
            return Subscription.multi(
                    impulse.subscribe(x -> timer.restart()),
                    timer::stop
            );
        }
    };
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:23,代码来源:EventStreams.java


示例5: fxRestartableTicksTest

import org.reactfx.util.FxTimer; //导入依赖的package包/类
@Test
public void fxRestartableTicksTest() throws InterruptedException, ExecutionException {
    CompletableFuture<Integer> nTicks = new CompletableFuture<>();
    Platform.runLater(() -> {
        EventCounter counter = new EventCounter();
        EventSource<?> impulse = new EventSource<Void>();
        Subscription sub = EventStreams.restartableTicks(Duration.ofMillis(100), impulse)
                .subscribe(counter::accept);
        FxTimer.runLater(Duration.ofMillis(400), sub::unsubscribe);
        FxTimer.runLater(Duration.ofMillis(80),() -> impulse.push(null));
        FxTimer.runLater(Duration.ofMillis(260),() -> impulse.push(null));
        // 000: Start -> 80 (restart)
        // 080: Start
        // 180: End (tick)
        // 180: Start -> 80 (restart)
        // 260: Start
        // 360: End (tick)
        // 400: unsubscribed: 2 ticks
        // wait a little more to test that no more ticks arrive anyway
        FxTimer.runLater(Duration.ofMillis(550), () -> nTicks.complete(counter.get()));
    });
    assertEquals(2, nTicks.get().intValue());
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:24,代码来源:TicksTest.java


示例6: fxRestartableTicks0Test

import org.reactfx.util.FxTimer; //导入依赖的package包/类
@Test
public void fxRestartableTicks0Test() throws InterruptedException, ExecutionException {
    CompletableFuture<Integer> nTicks = new CompletableFuture<>();
    Platform.runLater(() -> {
        EventCounter counter = new EventCounter();
        EventSource<?> impulse = new EventSource<Void>();
        Subscription sub = EventStreams.restartableTicks0(Duration.ofMillis(100), impulse)
                .subscribe(counter::accept);
        FxTimer.runLater(Duration.ofMillis(400), sub::unsubscribe);
        FxTimer.runLater(Duration.ofMillis(80), () -> impulse.push(null));
        FxTimer.runLater(Duration.ofMillis(260), () -> impulse.push(null));
        // 000: 0 (tick) -> 80 (restart)
        // 080: 0 (tick)
        // 180: 0 (tick) -> 80 (restart)
        // 260: 0 (tick)
        // 360: 0 (tick)
        // 400: unsubscribed: 5 ticks
        // wait a little more to test that no more ticks arrive anyway
        FxTimer.runLater(Duration.ofMillis(550), () -> nTicks.complete(counter.get()));
    });
    assertEquals(5, nTicks.get().intValue());
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:23,代码来源:TicksTest.java


示例7: 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();
        }
    });
}
 
开发者ID:cameronleger,项目名称:neural-style-gui,代码行数:15,代码来源:MainController.java


示例8: runLater

import org.reactfx.util.FxTimer; //导入依赖的package包/类
@Override
public Timer runLater(Duration delay, Runnable runnable) {
    if (timer == null) {
        timer = FxTimer.create(delay, runnable);
        timer.restart();
    } else {
        log.warn("runLater called on an already running timer.");
    }
    return this;
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:11,代码来源:UITimer.java


示例9: 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;
}
 
开发者ID:bisq-network,项目名称:exchange,代码行数:11,代码来源:UITimer.java


示例10: thenAccumulateFor

import org.reactfx.util.FxTimer; //导入依赖的package包/类
/**
 * Returns an event stream that emits the first event emitted from this
 * stream and then, if the next event arrives within the given duration
 * since the last emitted event, it is converted to an accumulator value
 * using {@code initialTransformation}. Any further events that still
 * arrive within {@code duration} are accumulated to the accumulator value
 * using the given reduction function. After {@code duration} has passed
 * since the last emitted event, the accumulator value is deconstructed
 * into a series of events using the given {@code deconstruction} function
 * and these events are emitted, the accumulator value is cleared and any
 * events that arrive within {@code duration} are accumulated, and so on.
 */
default <A> AwaitingEventStream<T> thenAccumulateFor(
        Duration duration,
        Function<? super T, ? extends A> initialTransformation,
        BiFunction<? super A, ? super T, ? extends A> reduction,
        Function<? super A, List<T>> deconstruction) {
    return new ThenAccumulateForStream<>(
            this,
            initialTransformation,
            reduction,
            deconstruction,
            action -> FxTimer.create(duration, action));
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:25,代码来源:EventStream.java


示例11: 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;
        }
    };
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:23,代码来源:EventStreams.java


示例12: ticks0

import org.reactfx.util.FxTimer; //导入依赖的package包/类
/**
 * Returns an event stream that emits periodic <i>ticks</i>. The first tick
 * is emitted at time 0.
 * 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<?> ticks0(Duration interval) {
    return new EventStreamBase<Void>() {
        private final Timer timer = FxTimer.createPeriodic0(
                interval, () -> emit(null));

        @Override
        protected Subscription observeInputs() {
            timer.restart();
            return timer::stop;
        }
    };
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:23,代码来源:EventStreams.java


示例13: fxTicksTest

import org.reactfx.util.FxTimer; //导入依赖的package包/类
@Test
public void fxTicksTest() throws InterruptedException, ExecutionException {
    CompletableFuture<Integer> nTicks = new CompletableFuture<>();
    Platform.runLater(() -> {
        EventCounter counter = new EventCounter();
        Subscription sub = EventStreams.ticks(Duration.ofMillis(100)).subscribe(counter::accept);
        FxTimer.runLater(Duration.ofMillis(350), sub::unsubscribe); // stop after 3 ticks
        // wait a little more to test that no more than 3 ticks arrive anyway
        FxTimer.runLater(Duration.ofMillis(550), () -> nTicks.complete(counter.get()));
    });
    assertEquals(3, nTicks.get().intValue());
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:13,代码来源:TicksTest.java


示例14: fxTicks0Test

import org.reactfx.util.FxTimer; //导入依赖的package包/类
@Test
public void fxTicks0Test() throws InterruptedException, ExecutionException {
    CompletableFuture<Integer> nTicks = new CompletableFuture<>();
    Platform.runLater(() -> {
     EventCounter counter = new EventCounter();
     Subscription sub = EventStreams.ticks0(Duration.ofMillis(100)).subscribe(counter::accept);
     // 000 (tick 1) -> 100 (tick 2) -> 200 (tick 3) -> 300 (tick 4) -> 350 (interrupted) = 4 ticks
     FxTimer.runLater(Duration.ofMillis(350), sub::unsubscribe); // stop after 4 ticks
     // wait a little more to test that no more than 4 ticks arrive anyway
     FxTimer.runLater(Duration.ofMillis(550), () -> nTicks.complete(counter.get()));
    });
    assertEquals(4, nTicks.get().intValue());
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:14,代码来源:TicksTest.java


示例15: alertDialog

import org.reactfx.util.FxTimer; //导入依赖的package包/类
@SuppressWarnings("restriction")
public void alertDialog(String title, String header, StringProperty msg,
	ConstructionManager constructionManager, ConstructionSite site, boolean hasTimer,
	ConstructionStageInfo stageInfo, int constructionSkill){
	//System.out.println("ConstructionWizard : Calling alertDialog()");
	Alert alert = new Alert(AlertType.CONFIRMATION);
	//alert.setOnCloseRequest((event) -> event.consume());
	//alert.initStyle(StageStyle.UNDECORATED);
	alert.initOwner(mainScene.getStage());
	alert.initModality(Modality.NONE); // users can zoom in/out, move around the settlement map and move a vehicle elsewhere
	//alert.initModality(Modality.APPLICATION_MODAL);
	double x = mainScene.getStage().getWidth();
	double y = mainScene.getStage().getHeight();
	double xx = alert.getDialogPane().getWidth();
	double yy = alert.getDialogPane().getHeight();

	alert.setX((x - xx)/2D);
	alert.setY((y - yy)*3D/4D);
	alert.setTitle(title);
	alert.setHeaderText(header);
	alert.setContentText(msg.get());
	// 2015-12-19 Used JavaFX binding
	alert.getDialogPane().contentTextProperty().bind(msg);
	//alert.getDialogPane().headerTextProperty().bind(arg0);

	ButtonType buttonTypeYes = new ButtonType("Yes");
	ButtonType buttonTypeNo = new ButtonType("No");
	ButtonType buttonTypeMouseKB = new ButtonType("Use Mouse");
	ButtonType buttonTypeCancelTimer = null;

	Timer timer = null;
	if (hasTimer) {
		buttonTypeCancelTimer = new ButtonType("Cancel Timer");
		alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo, buttonTypeMouseKB, buttonTypeCancelTimer);

		IntegerProperty i = new SimpleIntegerProperty(wait_time_in_secs);
		// 2015-12-19 Added ReactFX's Timer and FxTimer
		timer = FxTimer.runPeriodically(java.time.Duration.ofMillis(1000), () -> {
        	int num = i.get() - 1;
        	if (num >= 0) {
        		i.set(num);
        	}
        	//System.out.println(num);
        	if (num == 0) {
        		Button button = (Button) alert.getDialogPane().lookupButton(buttonTypeYes);
        	    button.fire();
        	}
        	msg.set("Notes: (1) Will default to \"Yes\" in " + num + " secs unless timer is cancelled."
        			+ " (2) To manually place a site, use Mouse Control.");
		});
	}
	else {
		msg.set("Note: To manually place a site, use Mouse Control.");
		alert.getButtonTypes().setAll(buttonTypeYes, buttonTypeNo, buttonTypeMouseKB);
	}

	Optional<ButtonType> result = null;
	result = alert.showAndWait();

	if (result.isPresent() && result.get() == buttonTypeYes) {
		logger.info(site.getName() + " is put in place in " + constructionManager.getSettlement());

	} else if (result.isPresent() && result.get() == buttonTypeNo) {
		//constructionManager.removeConstructionSite(site);
    	//System.out.println("just removing building");
		site = positionNewSite(site);//, constructionSkill);
		confirmSiteLocation(site, constructionManager, false, stageInfo, constructionSkill);

	} else if (result.isPresent() && result.get() == buttonTypeMouseKB) {
		placementDialog(title,header, site);

	} else if (hasTimer && result.isPresent() && result.get() == buttonTypeCancelTimer) {
		timer.stop();
		alertDialog(title, header, msg, constructionManager, site, false, stageInfo, constructionSkill);
	}

}
 
开发者ID:mars-sim,项目名称:mars-sim,代码行数:78,代码来源:ConstructionWizard.java


示例16: openFile

import org.reactfx.util.FxTimer; //导入依赖的package包/类
public void openFile(String title, String oldFileName, String oldRevision, String newFileName,
                     String newRevision, Patch<String> pathc) throws IOException {

    this.patch = pathc;

    oldLabel.setText(oldRevision);
    newLabel.setText(newRevision);

    fillCodeArea(oldCodeArea, oldFileName);
    fillCodeArea(newCodeArea, newFileName);

    paragraphDiffList = calculateParagraphDifference();

    highlightParagraphDifference();

    Optional<Pair<Pair<Integer, Integer>, Pair<Integer, Integer>>> p = paragraphDiffList
            .stream().findFirst();

    if (p.isPresent()) {
        diffIdx = 0;
        oldCodeArea.moveTo(p.get().getFirst().getFirst(), 0);
        newCodeArea.moveTo(p.get().getSecond().getFirst(), 0);
    }


    Scene scene = new Scene(gridPanel, 1024, 768);
    scene.getStylesheets().add(this.getClass().getResource(Const.KEYWORDS_CSS).toExternalForm());
    scene.getStylesheets().add(this.getClass().getResource(Const.DEFAULT_CSS).toExternalForm());

    final Stage stage = new Stage();
    stage.setScene(scene);
    stage.setTitle(title);
    stage.getIcons().add(new Image(this.getClass().getResourceAsStream(Const.ICON)));
    stage.show();

    FxTimer.runLater( Duration.ofMillis(DELAY),  () -> paintChanges(0, 0) );

    eventSubscription();

}
 
开发者ID:iazarny,项目名称:gitember,代码行数:41,代码来源:DiffViewController.java


示例17: reduceSuccessions

import org.reactfx.util.FxTimer; //导入依赖的package包/类
/**
 * A more general version of
 * {@link #reduceSuccessions(BinaryOperator, Duration)}
 * that allows the accumulated event to be of different type.
 *
 * <p><b>Note:</b> This function can be used only when this stream and
 * the returned stream are used from the JavaFX application thread. If
 * you are using the event streams on a different thread, use
 * {@link #reduceSuccessions(Function, BiFunction, Duration, ScheduledExecutorService, Executor)}
 * instead.</p>
 *
 * @param initialTransformation function to transform a single event
 * from this stream to an event that can be emitted from the returned
 * stream.
 * @param reduction function to add an event to the accumulated value.
 * @param timeout the maximum time difference between two subsequent
 * events that can still be accumulated.
 * @param <U> type of events emitted from the returned stream.
 */
default <U> AwaitingEventStream<U> reduceSuccessions(
        Function<? super T, ? extends U> initialTransformation,
        BiFunction<? super U, ? super T, ? extends U> reduction,
        Duration timeout) {

    Function<Runnable, Timer> timerFactory =
            action -> FxTimer.create(timeout, action);
    return new SuccessionReducingStream<T, U>(
            this, initialTransformation, reduction, timerFactory);
}
 
开发者ID:TomasMikula,项目名称:ReactFX,代码行数:30,代码来源:EventStream.java



注:本文中的org.reactfx.util.FxTimer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ImageInfo类代码示例发布时间:2022-05-22
下一篇:
Java IInventory类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap