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 class
TimeRange.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 boolean
before(RationalTime other)
The end of this strictly precedes other by a value >= epsilon.boolean
before(RationalTime other, double epsilon)
The end of this strictly precedes other by a value >= epsilon.boolean
before(TimeRange other)
The end of this strictly precedes the start of other by a value >= epsilon.boolean
before(TimeRange other, double epsilon)
The end of this strictly precedes the start of other by a value >= epsilon.boolean
begins(RationalTime other)
The start of this strictly equals other.boolean
begins(RationalTime other, double epsilon)
The start of this strictly equals other.boolean
begins(TimeRange other)
The start of this strictly equals the start of other.boolean
begins(TimeRange other, double epsilon)
The start of this strictly equals the start of other.RationalTime
clamped(RationalTime other)
Clamp 'other', according to this.startTime/endTimeExclusiveTimeRange
clamped(TimeRange other)
Clamp 'other', according to this.startTime/endTimeExclusiveboolean
contains(RationalTime other)
The start of this precedes other.boolean
contains(TimeRange other)
The start of this precedes start of other.TimeRange
durationExtendedBy(RationalTime other)
RationalTime
endTimeExclusive()
Time of the first sample outside the time range.RationalTime
endTimeInclusive()
The time of the last sample that contains data in the TimeRange.boolean
equals(TimeRange other)
boolean
equals(java.lang.Object obj)
TimeRange
extendedBy(TimeRange other)
Construct a new TimeRange that is this one extended by anotherboolean
finishes(RationalTime other)
The end of this strictly equals other.boolean
finishes(RationalTime other, double epsilon)
The end of this strictly equals other.boolean
finishes(TimeRange other)
The start of this strictly antecedes the start of other by a value >= epsilon.boolean
finishes(TimeRange other, double epsilon)
The start of this strictly antecedes the start of other by a value >= epsilon.RationalTime
getDuration()
RationalTime
getStartTime()
boolean
meets(TimeRange other)
The end of this strictly equals the start of other and the start of this strictly equals the end of other.boolean
meets(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.boolean
notEquals(TimeRange other)
boolean
overlaps(RationalTime other)
this contains other.boolean
overlaps(TimeRange other)
The start of this strictly precedes end of other by a value >= epsilon.boolean
overlaps(TimeRange other, double epsilon)
The start of this strictly precedes end of other by a value >= epsilon.static TimeRange
rangeFromStartEndTime(RationalTime startTime, RationalTime endTime)
Create a TimeRange from start and end RationalTimesjava.lang.String
toString()
-
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:
equals
in 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:
toString
in classjava.lang.Object
-