viper.api.time
Class InstantRange

java.lang.Object
  extended byedu.umd.cfar.lamp.viper.util.Range
      extended byviper.api.time.InstantRange
All Implemented Interfaces:
java.lang.Cloneable, java.util.Collection, IntervalIndexList, java.io.Serializable, java.util.Set, TemporalRange

public class InstantRange
extends Range
implements TemporalRange, java.io.Serializable

A range of Instants - basically, a set of non-overlapping Intervals, or a set of Instant objects.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class edu.umd.cfar.lamp.viper.util.IntervalIndexList
IntervalIndexList.Change
 
Constructor Summary
InstantRange()
           
 
Method Summary
 boolean add(java.lang.Object o)
          
 java.lang.Object clone()
          
 Interval createInterval(java.lang.Comparable s, java.lang.Comparable e)
          Creates a new interval. This is used instead of a constructor, so subclasses of this range which wish to return subclasses of interval should override this method.
 void crop(InstantInterval validSpan)
          Crops the range so that it is down to this size.
 Interval getExtrema()
          Gets the Span that starts at the beginning of the first Span and ends at the end of the last Span.
static boolean intersect(TemporalRange alpha, TemporalRange beta)
          Tests to see if the two ranges intersect somewhere.
 boolean intersects(TemporalRange other)
          Test to see if this range intersects another. Implementations will likely assume that the two use compatable instant types.
 boolean isFrameBased()
          Tests to see if the range uses Frame instants.
 boolean isTimeBased()
          Tests to see if the range uses Time instants.
static InstantRange parseFrameRange(java.lang.String val)
          Parses a Range of Frames in the form of a white-space delimited sequence of Span tokens.
static InstantRange parseTimeRange(java.lang.String val)
          Parses a Range of Times in the form of a white-space delimited sequence of Span tokens.
 boolean remove(java.lang.Object o)
          
 void shift(Instant amount)
          Shifts the range by the given amount of time.
 boolean withinRangeInclusive(Instant s, Instant e)
          Checks to see if the span is inside the Range.
 
Methods inherited from class edu.umd.cfar.lamp.viper.util.Range
add, addAll, addAll, addAll, clear, cloneInto, contains, containsAll, endOf, equals, firstAfter, firstAfterOrAt, firstBefore, get, getContiguousIntervalCount, hashCode, intersect, intersectComplement, intersects, intersects, intersects, isEmpty, iterator, iterator, map, remove, removeAll, retainAll, set, setSpans, size, subList, toArray, toArray, toString, union, withinRange, withinRange
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface viper.api.time.TemporalRange
contains
 
Methods inherited from interface edu.umd.cfar.lamp.viper.util.IntervalIndexList
addAll, clear, endOf, firstAfter, firstAfterOrAt, firstBefore, get, getContiguousIntervalCount, isEmpty, iterator, iterator, map, remove, set, subList
 

Constructor Detail

InstantRange

public InstantRange()
Method Detail

parseFrameRange

public static InstantRange parseFrameRange(java.lang.String val)
Parses a Range of Frames in the form of a white-space delimited sequence of Span tokens. For example, "12:19 24 30:100" would be three Spans of Frames: one from 12 to 19, another that represents just Frame 24, and finally the Span of Frames from 30 to 100, inclusive.

Parameters:
val - white space delimited sequence of numbers or two increasing numbers seperated by a colon.
Returns:
A new Range object representative of the value

parseTimeRange

public static InstantRange parseTimeRange(java.lang.String val)
Parses a Range of Times in the form of a white-space delimited sequence of Span tokens. For example, "12:19 24 30:100" would be three Spans of Times: one from 12 to 19, another that represents just the 24th microsecond, and finally the Span of Times from the 30th microsecond to 100th, inclusive.

Parameters:
val - white space delimited sequence of numbers or two increasing numbers seperated by a colon.
Returns:
A new Range object representative of the value

withinRangeInclusive

public boolean withinRangeInclusive(Instant s,
                                    Instant e)
Checks to see if the span is inside the Range.

Parameters:
s - The first Instant to check for.
e - The last Instant to check.
Returns:
true iff all Instants in [s,e] are in this

add

public boolean add(java.lang.Object o)

Specified by:
add in interface java.util.Set
Overrides:
add in class Range
See Also:
Set.add(java.lang.Object)

remove

public boolean remove(java.lang.Object o)

Specified by:
remove in interface java.util.Set
Overrides:
remove in class Range
See Also:
Set.remove(java.lang.Object)

getExtrema

public Interval getExtrema()
Gets the Span that starts at the beginning of the first Span and ends at the end of the last Span.

Specified by:
getExtrema in interface TemporalRange
Overrides:
getExtrema in class Range
Returns:
Span a Span that has all the others as a subset. Null if empty.

isFrameBased

public boolean isFrameBased()
Tests to see if the range uses Frame instants.

Specified by:
isFrameBased in interface TemporalRange
Returns:
if the range is specified in terms of frames

isTimeBased

public boolean isTimeBased()
Tests to see if the range uses Time instants.

Specified by:
isTimeBased in interface TemporalRange
Returns:
if the range is specified in terms of time

intersect

public static boolean intersect(TemporalRange alpha,
                                TemporalRange beta)
Tests to see if the two ranges intersect somewhere.

Parameters:
alpha - a range to test
beta - another range
Returns:
if they intersect

intersects

public boolean intersects(TemporalRange other)
Test to see if this range intersects another. Implementations will likely assume that the two use compatable instant types.

Specified by:
intersects in interface TemporalRange
Parameters:
other - the range to check
Returns:
if the ranges share an instant

clone

public java.lang.Object clone()

Specified by:
clone in interface TemporalRange
Overrides:
clone in class Range
See Also:
Object.clone()

createInterval

public Interval createInterval(java.lang.Comparable s,
                               java.lang.Comparable e)
Creates a new interval. This is used instead of a constructor, so subclasses of this range which wish to return subclasses of interval should override this method.

Overrides:
createInterval in class Range
Parameters:
s -
e -
Returns:

shift

public void shift(Instant amount)
Description copied from interface: TemporalRange
Shifts the range by the given amount of time.

Specified by:
shift in interface TemporalRange
Parameters:
amount - the number of frames to shift

crop

public void crop(InstantInterval validSpan)
Crops the range so that it is down to this size.

Parameters:
validSpan -