sub_arctic.anim
Class time_interval

java.lang.Object
  |
  +--sub_arctic.anim.time_interval
Direct Known Subclasses:
continuous_interval

public class time_interval
extends java.lang.Object

This class is handy for manipulating transitions both by the user and by the animation agent. It keeps track of when a transition is to occur and allows you to specify a time_interval either in absolute time or in various relative ways.


Field Summary
protected  long _delay
           
protected  long _duration
          If used _used_duration is true, this will contain the duration.
protected  long _end_time
          End (if known) is here
protected  int _related_how
          If we are relative, how are we relative? Will be one of the constants AFTER_START_OF or AFTER_END_OF.
protected  transition _related_to
          If we are relative, who are we relative to?
protected  boolean _specified_end
          Did they specify an end time.
protected  boolean _specified_start
          Did they specify a start time.
protected  long _start_time
          Start (if known) is here
protected  boolean _used_duration
          Did they specify this in terms of duration?
static int AFTER_END_OF
          Use this constant to express that this time interval starts after the end of some other transition.
static int AFTER_START_OF
          Use this constant to express that this time interval starts after the start of some other transition.
 
Constructor Summary
time_interval()
          Create a time interval that you will fill in the values for later.
time_interval(int how, transition t, long parm)
          Create one of these puppies...
time_interval(long start, long end)
          Create a time_interval with a known start and end point.
 
Method Summary
 long delay()
          Retrieve the amount of time after the start or end of the other transition if we are related to other transitions.
 long duration()
          Return how long this interval is.
 long end_time()
          Retrieve the end time of this interval.
static long now()
          What's the current time in milliseconds?
 int related_how()
          This will return one of the relationship constants AFTER_START_OF or AFTER_END_OF if this time_interval is related to another transition.
 transition related_to()
          Retrieve what transition we are related to, if any.
 void set_delay(long d)
          Set the delay after a relative transition.
 void set_duration(long millis)
          Set the interval of ending time to be a duration in milliseconds.
 void set_ending_time_from_now(long millis)
          Set the ending time to be a particular amount of time from now.
 void set_ending_time(long millis)
          Set the interval ending time to be a particular value in milliseconds.
 void set_start_time_from_now(long millis)
          Set the start point to be a know point in millis from now.
 void set_start_time(long millis)
          Set the start point to be a known point in milliseconds.
 boolean specified_end()
          Return if the user specified an end time for this interval.
 boolean specified_start()
          Return if the user specified a start time for this interval.
 long start_time()
          Retrieve the start time of this interval.
 boolean used_duration()
          Return if the user specified this interval in terms of duration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_specified_start

protected boolean _specified_start
Did they specify a start time.

_specified_end

protected boolean _specified_end
Did they specify an end time.

_used_duration

protected boolean _used_duration
Did they specify this in terms of duration?

_duration

protected long _duration
If used _used_duration is true, this will contain the duration.

AFTER_START_OF

public static final int AFTER_START_OF
Use this constant to express that this time interval starts after the start of some other transition.

AFTER_END_OF

public static final int AFTER_END_OF
Use this constant to express that this time interval starts after the end of some other transition.

_start_time

protected long _start_time
Start (if known) is here

_end_time

protected long _end_time
End (if known) is here

_related_to

protected transition _related_to
If we are relative, who are we relative to?

_related_how

protected int _related_how
If we are relative, how are we relative? Will be one of the constants AFTER_START_OF or AFTER_END_OF.

_delay

protected long _delay
Constructor Detail

time_interval

public time_interval(int how,
                     transition t,
                     long parm)
Create one of these puppies... This creates a relative transition... you should supply either AFTER_START_OF and AFTER_END_OF as the "how" parameter. The parm is number of milliseconds after the start or end.

Parameters:
int - how how to be related to the supplied transition
transition - t the transition we are related to
long - parm the amount of delay after the start or end of the related to transition

time_interval

public time_interval(long start,
                     long end)
Create a time_interval with a known start and end point. These are in milliseconds.

Parameters:
long - start the start time
long - end the end time

time_interval

public time_interval()
Create a time interval that you will fill in the values for later.
Method Detail

used_duration

public boolean used_duration()
Return if the user specified this interval in terms of duration.
Returns:
boolean true if the user specified a duration

specified_start

public boolean specified_start()
Return if the user specified a start time for this interval.
Returns:
boolean true if the user specified a start time

specified_end

public boolean specified_end()
Return if the user specified an end time for this interval.
Returns:
boolean true if the user specified an end time

duration

public long duration()
Return how long this interval is. Note that if you specified this as a duration, we return it, otherwise we calculate it. We DO NOT check to see if your start and end time are as yet known, so you would be well advised to check _used_duration and valid() to see if its ok to call this.

Returns:
long the duration of this interval in milliseconds

now

public static long now()
What's the current time in milliseconds?

Returns:
long the current time

start_time

public long start_time()
Retrieve the start time of this interval. You may want to check to make sure this interval has a start time before calling this.

Returns:
long the start time of this interval in milliseconds

end_time

public long end_time()
Retrieve the end time of this interval. You may want to check to make sure this interval has an end time before calling this.

Returns:
long the end time of this interval in milliseconds

related_to

public transition related_to()
Retrieve what transition we are related to, if any.
Returns:
transition the transition to which we are related via AFTER_START_OF or AFTER_END_OF.

related_how

public int related_how()
This will return one of the relationship constants AFTER_START_OF or AFTER_END_OF if this time_interval is related to another transition.

Returns:
int one of the constants AFTER_START_OF and AFTER_END_OF

delay

public long delay()
Retrieve the amount of time after the start or end of the other transition if we are related to other transitions.
Returns:
long the amount of delay after the start or end of the other transition.

set_delay

public void set_delay(long d)
Set the delay after a relative transition.
Parameters:
long - d the new delay value

set_duration

public void set_duration(long millis)
Set the interval of ending time to be a duration in milliseconds.

Parameters:
long - millis the new duration in milliseconds

set_ending_time

public void set_ending_time(long millis)
Set the interval ending time to be a particular value in milliseconds.

Parameters:
long - millis the new ending time in milliseconds.

set_ending_time_from_now

public void set_ending_time_from_now(long millis)
Set the ending time to be a particular amount of time from now.
Parameters:
long - millis the new ending point in time (distance from now in milliseconds).

set_start_time

public void set_start_time(long millis)
Set the start point to be a known point in milliseconds.

Parameters:
long - millis the new start time in milliseconds

set_start_time_from_now

public void set_start_time_from_now(long millis)
Set the start point to be a know point in millis from now.

Parameters:
long - millis the new start time (distance from now in milliseconds)