NASA World Wind

gov.nasa.worldwind.util
Class TimedExpirySupport

java.lang.Object
  extended by gov.nasa.worldwind.util.TimedExpirySupport

public class TimedExpirySupport
extends Object

Handles expiration after some interval of time has passed. Expiration time is computed as a random value between a specified minimum and a specified maximum delay interval.


Field Summary
protected  boolean expired
           
protected  long expiryTime
           
protected  long maxExpiryTime
           
protected  long minExpiryTime
           
protected static Random rand
           
 
Constructor Summary
TimedExpirySupport()
          Constructs an instance with minimum expiry interval of 1 second and a max of 2 seconds.
TimedExpirySupport(long minExpiryTime, long maxExpiryTime)
          Constructs an instance with specified minimum and maximum expiry intervals.
 
Method Summary
 long getExpiryTime()
          Indicates the current expiration time, which is a random value between the specified minimum and maximum.
 long getMaxExpiryTime()
          Indicates this timer's maximum expiry interval.
 long getMinExpiryTime()
          Indicates this timer's minimum expiry interval.
 boolean isExpired(DrawContext dc)
          Indicates whether this timer has expired.
 boolean isExpired(long now)
          Indicates whether this timer has expired.
 void restart(DrawContext dc)
          Marks this timer as not expired and restarts the timer.
 void setExpired(boolean expired)
          Set the expiration state of this timer.
 void setExpiryTime(long minExpiryTime, long maxExpiryTime)
          Specifies the minimum and maximum expiration intervals.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

expired

protected boolean expired

expiryTime

protected long expiryTime

maxExpiryTime

protected long maxExpiryTime

minExpiryTime

protected long minExpiryTime

rand

protected static Random rand
Constructor Detail

TimedExpirySupport

public TimedExpirySupport()
Constructs an instance with minimum expiry interval of 1 second and a max of 2 seconds.


TimedExpirySupport

public TimedExpirySupport(long minExpiryTime,
                          long maxExpiryTime)
Constructs an instance with specified minimum and maximum expiry intervals. An interval is set to 0 if its specified value is less than 0.

Parameters:
minExpiryTime - the minimum interval allowed to pass before expiration, in milliseconds.
maxExpiryTime - the maximum interval allowed to pass before expiration, in milliseconds.
Method Detail

getExpiryTime

public long getExpiryTime()
Indicates the current expiration time, which is a random value between the specified minimum and maximum.

Returns:
the current expiration time, in milliseconds.

getMaxExpiryTime

public long getMaxExpiryTime()
Indicates this timer's maximum expiry interval.

Returns:
this timer's maximum expiry interval, in milliseconds.

getMinExpiryTime

public long getMinExpiryTime()
Indicates this timer's minimum expiry interval.

Returns:
this timer's minimum expiry interval, in milliseconds.

isExpired

public boolean isExpired(DrawContext dc)
Indicates whether this timer has expired.

Parameters:
dc - the current draw context.
Returns:
true if this timer has expired relative to the frame time, otherwise false.
Throws:
IllegalArgumentException - if the draw context is null.

isExpired

public boolean isExpired(long now)
Indicates whether this timer has expired.

Parameters:
now - the time to relate this timer's expiration time to. The timer is considered expired if this timer's expiry time is less than this value.
Returns:
true if this timer has expired relative to system time, otherwise false.

restart

public void restart(DrawContext dc)
Marks this timer as not expired and restarts the timer.

Parameters:
dc - the current draw context.
Throws:
IllegalArgumentException - if the draw context is null.

setExpired

public void setExpired(boolean expired)
Set the expiration state of this timer.

Parameters:
expired - true to indicate expired, false to indicate not expired.

setExpiryTime

public void setExpiryTime(long minExpiryTime,
                          long maxExpiryTime)
Specifies the minimum and maximum expiration intervals. An interval is set to 0 if its specified value is less than 0.

Parameters:
minExpiryTime - the minimum interval allowed to pass before expiration, in milliseconds.
maxExpiryTime - the maximum interval allowed to pass before expiration, in milliseconds.

NASA World Wind