Class Clock

  • All Implemented Interfaces:

    
    public final class Clock
    
                        

    A simple class for timing of animations and things. Literally a delta function.

    PolyUI internally uses nanoseconds as the time unit. There are a few reasons for this:

    • animations will be smoother as frames are usually shorter than 1ms, around 0.007ms. This means that the delta will be a decimal, which is not possible with longs, so some accuracy is lost with milliseconds.

    • System.nanoTime (the function we use to measure time) ignores changes to the system clock, so if the user changes their clock PolyUI won't crash or go very crazy because of a negative time.

    • 9,223,372,036,854,775,808 is max for a long, so the program can run for 2,562,047.78802 hours, or 106,751.991167 days, or 292.471 years. So we can use these.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      public abstract class Clock.Executor

      Create a new Executor.

      public final class Clock.FixedTimeExecutor

      Create a new FixedTimeExecutor.

      public final class Clock.UntilExecutor

      An executor that will do its function until the given amount of time has passed.

      public final class Clock.ConditionalExecutor

      An executor that will do its function until the given condition is true.

      public final class Clock.AfterExecutor

      An executor that will do its function after the given amount of time has passed.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final Long now
      private final Long delta
    • Constructor Summary

      Constructors 
      Constructor Description
      Clock()
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Long getNow()
      final Long getDelta()
      final Long peek()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait