Class DelayedEvent

  • All Implemented Interfaces:
    java.lang.Runnable

    public class DelayedEvent
    extends java.lang.Object
    implements java.lang.Runnable
    • Field Summary

      Fields 
      Modifier and Type Field Description
      double duration
      The amount of time to wait (in seconds)
      boolean isRunning  
      private boolean naturalStop  
      java.lang.Thread thread  
    • Constructor Summary

      Constructors 
      Constructor Description
      DelayedEvent​(double duration)
      Create a new delayed event, which will call onFinish() after the specified amount of time
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel()
      Cancel the delayed event, and kill its thread.
      void fastForward()
      Call onFinish() now ("fast forward" through the delay)
      void onFinish()
      Called after duration has passed (after calling start())
      void run()  
      void start()
      Starts the delayed event
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • naturalStop

        private boolean naturalStop
      • duration

        public double duration
        The amount of time to wait (in seconds)
      • thread

        public java.lang.Thread thread
      • isRunning

        public boolean isRunning
    • Constructor Detail

      • DelayedEvent

        public DelayedEvent​(double duration)
        Create a new delayed event, which will call onFinish() after the specified amount of time
        Parameters:
        duration - How long to wait, in seconds
    • Method Detail

      • start

        public void start()
        Starts the delayed event
      • cancel

        public void cancel()
        Cancel the delayed event, and kill its thread. onFinish() is not called
      • fastForward

        public void fastForward()
        Call onFinish() now ("fast forward" through the delay)
      • onFinish

        public void onFinish()
        Called after duration has passed (after calling start())
      • run

        public void run()
        Specified by:
        run in interface java.lang.Runnable