当前位置: 首页>>代码示例>>Java>>正文


Java TimeListener类代码示例

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


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

示例1: registerListener

import com.blockwithme.time.TimeListener; //导入依赖的package包/类
@Override
public Task<TimeListener> registerListener(final TimeListener listener) {
    final MyTask<TimeListener> result = new MyTask<TimeListener>(listeners,
            Objects.requireNonNull(listener));
    listeners.add(result);
    return result;
}
 
开发者ID:skunkiferous,项目名称:TimeImpl,代码行数:8,代码来源:TimelineImpl.java

示例2: testPauseAndComputedRealTime

import com.blockwithme.time.TimeListener; //导入依赖的package包/类
public void testPauseAndComputedRealTime() throws Exception {
    try (final ClockService impl = newClockService()) {
        try (final Scheduler sched = impl.newScheduler("sched", null)) {
            try (final Timeline t = impl.coreTimeline()
                    .newChildTimeline(false, sched).setTicksPerSecond(10)
                    .setLocalTickScaling(10.0).paused().create("t")) {
                System.out.println(t);
                final AtomicLong tLastTick = new AtomicLong();
                final TimeListener tl = new TimeListener() {
                    @Override
                    public void onTimeChange(final Time tick) {
                        tLastTick.set(tick.runningElapsedTicks);
                        System.out.println("NOW:               "
                                + impl.clock().instant());
                        System.out.println("TS1: "
                                + tick.runningElapsedTicks + " "
                                + ((double) tick.tickDuration)
                                / Time.MILLI_MUS + " "
                                + tick.creationInstant());
                    }
                };
                try (final Task<TimeListener> task = t.registerListener(tl)) {
                    t.unpause();
                    sleep(1050);
                }
                final Time lastTime = t.lastTick();
                final long now = impl.currentTimeMicros();
                final double diffTimeSec = ((double) lastTime.creationTime - now)
                        / Time.SECOND_MUS;
                System.out
                        .println("Ticks: " + lastTime.runningElapsedTicks);
                System.out.println("diffTimeSec: " + diffTimeSec);
                System.out.println("diffTimeSec/tick: "
                        + (diffTimeSec / lastTime.runningElapsedTicks));
            }
        }
    }
}
 
开发者ID:skunkiferous,项目名称:TimeImpl,代码行数:39,代码来源:TimelineTest.java

示例3: Wrapper

import com.blockwithme.time.TimeListener; //导入依赖的package包/类
/** Creates a Wrapper. */
public Wrapper(final TimeListener theTask, final Time theTime) {
    task = Objects.requireNonNull(theTask, "theTask");
    time = Objects.requireNonNull(theTime, "theTime");
}
 
开发者ID:skunkiferous,项目名称:Time,代码行数:6,代码来源:ForkingTimeListener.java

示例4: ForkingTimeListener

import com.blockwithme.time.TimeListener; //导入依赖的package包/类
/** Creates a Fork, with the given task and Executor. */
public ForkingTimeListener(final TimeListener theTask,
        final Executor theExecutor) {
    task = Objects.requireNonNull(theTask, "theTask");
    executor = Objects.requireNonNull(theExecutor, "theExecutor");
}
 
开发者ID:skunkiferous,项目名称:Time,代码行数:7,代码来源:ForkingTimeListener.java


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