Package io.opentimeline.opentime
Class TimeRange
java.lang.Object
io.opentimeline.opentime.TimeRange
public class TimeRange
extends java.lang.Object
Contains a range of time, starting (and including) startTime and
lasting duration.value * (1/duration.rate) seconds.
It is possible to construct TimeRange object with a negative duration. However, the logical predicates are written as if duration is positive, and have undefined behavior for negative durations.
The duration on a TimeRange indicates a time range that is inclusive of the start time, and exclusive of the end time. All of the predicates are computed accordingly.
This default epsilon value is used in comparison between floating numbers. It is computed to be twice 192khz, the fastest commonly used audio rate. It can be changed in the future if necessary due to higher sampling rates or some other kind of numeric tolerance detected in the library.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTimeRange.TimeRangeBuilder -
Constructor Summary
Constructors Constructor Description TimeRange()TimeRange(RationalTime startTime)TimeRange(RationalTime startTime, RationalTime duration)TimeRange(TimeRange timeRange)TimeRange(TimeRange.TimeRangeBuilder timeRangeBuilder) -
Method Summary
Modifier and Type Method Description booleanbefore(RationalTime other)The end of this strictly precedes other by a value >= epsilon.booleanbefore(RationalTime other, double epsilon)The end of this strictly precedes other by a value >= epsilon.booleanbefore(TimeRange other)The end of this strictly precedes the start of other by a value >= epsilon.booleanbefore(TimeRange other, double epsilon)The end of this strictly precedes the start of other by a value >= epsilon.booleanbegins(RationalTime other)The start of this strictly equals other.booleanbegins(RationalTime other, double epsilon)The start of this strictly equals other.booleanbegins(TimeRange other)The start of this strictly equals the start of other.booleanbegins(TimeRange other, double epsilon)The start of this strictly equals the start of other.RationalTimeclamped(RationalTime other)Clamp 'other', according to this.startTime/endTimeExclusiveTimeRangeclamped(TimeRange other)Clamp 'other', according to this.startTime/endTimeExclusivebooleancontains(RationalTime other)The start of this precedes other.booleancontains(TimeRange other)The start of this precedes start of other.TimeRangedurationExtendedBy(RationalTime other)RationalTimeendTimeExclusive()Time of the first sample outside the time range.RationalTimeendTimeInclusive()The time of the last sample that contains data in the TimeRange.booleanequals(TimeRange other)booleanequals(java.lang.Object obj)TimeRangeextendedBy(TimeRange other)Construct a new TimeRange that is this one extended by anotherbooleanfinishes(RationalTime other)The end of this strictly equals other.booleanfinishes(RationalTime other, double epsilon)The end of this strictly equals other.booleanfinishes(TimeRange other)The start of this strictly antecedes the start of other by a value >= epsilon.booleanfinishes(TimeRange other, double epsilon)The start of this strictly antecedes the start of other by a value >= epsilon.RationalTimegetDuration()RationalTimegetStartTime()booleanmeets(TimeRange other)The end of this strictly equals the start of other and the start of this strictly equals the end of other.booleanmeets(TimeRange other, double epsilon)The end of this strictly equals the start of other and the start of this strictly equals the end of other.booleannotEquals(TimeRange other)booleanoverlaps(RationalTime other)this contains other.booleanoverlaps(TimeRange other)The start of this strictly precedes end of other by a value >= epsilon.booleanoverlaps(TimeRange other, double epsilon)The start of this strictly precedes end of other by a value >= epsilon.static TimeRangerangeFromStartEndTime(RationalTime startTime, RationalTime endTime)Create a TimeRange from start and end RationalTimesjava.lang.StringtoString()
-
Constructor Details
-
Method Details
-
getStartTime
-
getDuration
-
endTimeInclusive
The time of the last sample that contains data in the TimeRange. If the TimeRange goes from (0, 24) w/ duration (10, 24), this will be (9, 24) If the TimeRange goes from (0, 24) w/ duration (10.5, 24): (10, 24) In other words, the last frame with data (however fractional).- Returns:
- time of the last sample that contains data in the TimeRange
-
endTimeExclusive
Time of the first sample outside the time range. If Start Frame is 10 and duration is 5, then endTimeExclusive is 15, even though the last time with data in this range is 14. If Start Frame is 10 and duration is 5.5, then endTimeExclusive is 15.5, even though the last time with data in this range is 15.- Returns:
- time of the first sample outside the time range
-
durationExtendedBy
-
extendedBy
Construct a new TimeRange that is this one extended by another- Parameters:
other- timeRange by which the duration is extended- Returns:
- extended TimeRange
-
clamped
Clamp 'other', according to this.startTime/endTimeExclusive- Parameters:
other- RationalTime to clamp to- Returns:
- clamped TimeRange
-
clamped
Clamp 'other', according to this.startTime/endTimeExclusive- Parameters:
other- TimeRange to clamp to- Returns:
- clamped TimeRange
-
contains
The start of this precedes other. other precedes the end of this. other ↓ * [ this ]- Parameters:
other- RationalTime to check for- Returns:
- does this contain other
-
contains
The start of this precedes start of other. The end of this antecedes end of other. [ other ] [ this ] The converse would be other.contains(this)- Parameters:
other- TimeRange to check for- Returns:
- does this contain other
-
overlaps
this contains other. other ↓ * [ this ]- Parameters:
other- RationalTime to check for- Returns:
- does this overlap other
-
overlaps
The start of this strictly precedes end of other by a value >= epsilon. The end of this strictly antecedes start of other by a value >= epsilon. [ this ] [ other ] The converse would be other.overlaps(this)- Parameters:
other- TimeRange to check forepsilon- comparison tolerance- Returns:
- does this overlap other
-
overlaps
The start of this strictly precedes end of other by a value >= epsilon. The end of this strictly antecedes start of other by a value >= epsilon. [ this ] [ other ] The converse would be other.overlaps(this) Default epsilon value of 1/(2 * 192000) will be used- Parameters:
other- TimeRange to check for- Returns:
- does this overlap other
-
before
The end of this strictly precedes the start of other by a value >= epsilon. [ this ] [ other ] The converse would be other.before(this)- Parameters:
other- TimeRange to check forepsilon- comparison tolerance- Returns:
- is this before other
-
before
The end of this strictly precedes the start of other by a value >= epsilon. [ this ] [ other ] The converse would be other.before(this) Default epsilon value of 1/(2 * 192000) will be used- Parameters:
other- TimeRange to check for- Returns:
- is this before other
-
before
The end of this strictly precedes other by a value >= epsilon. other ↓ [ this ] *- Parameters:
other- RationalTime to check forepsilon- comparison tolerance- Returns:
- is this before other
-
before
The end of this strictly precedes other by a value >= epsilon. other ↓ [ this ] * Default epsilon value of 1/(2 * 192000) will be used- Parameters:
other- RationalTime to check for- Returns:
- is this before other
-
meets
The end of this strictly equals the start of other and the start of this strictly equals the end of other. [this][other] The converse would be other.meets(this)- Parameters:
other- TimeRange to check forepsilon- comparison tolerance- Returns:
- does this meet other
-
meets
The end of this strictly equals the start of other and the start of this strictly equals the end of other. [this][other] The converse would be other.meets(this) Default epsilon value of 1/(2 * 192000) will be used- Parameters:
other- TimeRange to check for- Returns:
- does this meet other
-
begins
The start of this strictly equals the start of other. The end of this strictly precedes the end of other by a value >= epsilon. [ this ] [ other ] The converse would be other.begins(this)- Parameters:
other- TimeRange to check forepsilon- comparison tolerance- Returns:
- do the beginnings of both match
-
begins
The start of this strictly equals the start of other. The end of this strictly precedes the end of other by a value >= epsilon. [ this ] [ other ] The converse would be other.begins(this) Default epsilon value of 1/(2 * 192000) will be used- Parameters:
other- TimeRange to check for- Returns:
- do the beginnings of both match
-
begins
The start of this strictly equals other. other ↓ * [ this ]- Parameters:
other- RationalTime to check forepsilon- comparison tolerance- Returns:
- does the RationalTime match the beginning of this
-
begins
The start of this strictly equals other. other ↓ * [ this ] Default epsilon value of 1/(2 * 192000) will be used- Parameters:
other- RationalTime to check for- Returns:
- does the RationalTime match the beginning of this
-
finishes
The start of this strictly antecedes the start of other by a value >= epsilon. The end of this strictly equals the end of other. [ this ] [ other ] The converse would be other.finishes(this)- Parameters:
other- TimeRange to check forepsilon- comparison tolerance- Returns:
- do the ends of both match
-
finishes
The start of this strictly antecedes the start of other by a value >= epsilon. The end of this strictly equals the end of other. [ this ] [ other ] The converse would be other.finishes(this) Default epsilon value of 1/(2 * 192000) will be used- Parameters:
other- TimeRange to check for- Returns:
- do the ends of both match
-
finishes
The end of this strictly equals other. other ↓ * [ this ]- Parameters:
other- RationalTime to check forepsilon- comparison tolerance- Returns:
- does the RationalTime match the end of this
-
finishes
The end of this strictly equals other. other ↓ * [ this ]- Parameters:
other- RationalTime to check for- Returns:
- does the RationalTime match the end of this
-
equals
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classjava.lang.Object
-
notEquals
-
rangeFromStartEndTime
Create a TimeRange from start and end RationalTimes- Parameters:
startTime- start timeendTime- end time- Returns:
- TimeRange from start and end RationalTimes
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-