home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / RELEASE.ZIP / sub_arctic / anim / timer_transition.java < prev    next >
Encoding:
Java Source  |  1996-10-04  |  3.4 KB  |  103 lines

  1. package sub_arctic.anim;
  2.  
  3. import sub_arctic.input.event;
  4.  
  5. /**
  6.  * This is a subclass of transition which just generates a "pulse" to
  7.  * an object which an amount of time has elapsed. The object must
  8.  * be an implementation of the interface "timer."  If you wish to
  9.  * cancel a timer before it goes off, you will need to use the
  10.  * remove_transition() function on the animation agent.<p>
  11.  * 
  12.  * @author Ian Smith 
  13.  */
  14. public class timer_transition extends transition {
  15.  
  16.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  17.    
  18.   /**
  19.    * This is the object we are going to notify.
  20.    */
  21.   timer _target;
  22.  
  23.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  24.    
  25.   /**
  26.    * Create a timer transition which is scheduled to go off in some
  27.    * number of milliseconds. This is a best effort system, so it may
  28.    * be some arbitrary amount of time (but usually small) after this
  29.    * time elapses before your timer gets notified.<p>
  30.    *
  31.    * @param timer t the object to be notified
  32.    * @param long l the number of milliseconds until the notification
  33.    */
  34.   public timer_transition(timer t, long l) {
  35.     super(null,null,null);
  36.  
  37.     long n=time_interval.now();
  38.     _target=t;
  39.     set_interval(new time_interval(n,n+l));
  40.   }
  41.  
  42.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  43.    
  44.   /**
  45.    * Start a transition. This type of transition ignores this call.<p>
  46.    * 
  47.    * @param event e the animation event that caused things to get going
  48.    * @param Object user_info the object passed to the animation agent when 
  49.    *                         the animatable joined its focus set
  50.    */
  51.   public void start(event e,Object user_info) { }
  52.  
  53.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  54.    
  55.   /**
  56.    * Perform a step... This type of transition ignores this call.<p>
  57.    * 
  58.    * @param event e the animation event for this step
  59.    * @param Object user_info the object passed to the animation agent when 
  60.    *                         the animatable joined its focus set
  61.    * @param long current_time the time it is "now" for this time step
  62.    */
  63.   public void step(event e, Object user_info, long current_time) {
  64.  
  65.     /* are we past the end or at it?*/
  66.     if (current_time>=interval().end_time()) {
  67.       _finished=true;
  68.     }
  69.  
  70.   }
  71.  
  72.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  73.    
  74.   /**
  75.    * Send the end message to the timer that the time has expired.
  76.    *
  77.    * @param event e the animation event for this step
  78.    * @param Object user_info the object passed to the animation agent when 
  79.    *                         the animatable joined its focus set (ignored)
  80.    */
  81.   public void end(event e, Object user_info) {
  82.     _target.time_expired(e);
  83.   }
  84.  
  85.   /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
  86. }
  87. /*=========================== COPYRIGHT NOTICE ===========================
  88.  
  89. This file is part of the subArctic user interface toolkit.
  90.  
  91. Copyright (c) 1996 Scott Hudson and Ian Smith
  92. All rights reserved.
  93.  
  94. The subArctic system is freely available for most uses under the terms
  95. and conditions described in 
  96.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  97. and appearing in full in the lib/interactor.java source file.
  98.  
  99. The current release and additional information about this software can be 
  100. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  101.  
  102. ========================================================================*/
  103.