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.

  • Constructor Details

  • Method Details

    • getStartTime

      public RationalTime getStartTime()
    • getDuration

      public RationalTime getDuration()
    • endTimeInclusive

      public RationalTime 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

      public RationalTime 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

      public TimeRange durationExtendedBy​(RationalTime other)
    • extendedBy

      public TimeRange extendedBy​(TimeRange other)
      Construct a new TimeRange that is this one extended by another
      Parameters:
      other - timeRange by which the duration is extended
      Returns:
      extended TimeRange
    • clamped

      public RationalTime clamped​(RationalTime other)
      Clamp 'other', according to this.startTime/endTimeExclusive
      Parameters:
      other - RationalTime to clamp to
      Returns:
      clamped TimeRange
    • clamped

      public TimeRange clamped​(TimeRange other)
      Clamp 'other', according to this.startTime/endTimeExclusive
      Parameters:
      other - TimeRange to clamp to
      Returns:
      clamped TimeRange
    • contains

      public boolean contains​(RationalTime other)
      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

      public boolean contains​(TimeRange other)
      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

      public boolean overlaps​(RationalTime other)
      this contains other. other ↓ * [ this ]
      Parameters:
      other - RationalTime to check for
      Returns:
      does this overlap other
    • overlaps

      public boolean overlaps​(TimeRange other, double epsilon)
      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 for
      epsilon - comparison tolerance
      Returns:
      does this overlap other
    • overlaps

      public boolean overlaps​(TimeRange other)
      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

      public boolean before​(TimeRange other, double epsilon)
      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 for
      epsilon - comparison tolerance
      Returns:
      is this before other
    • before

      public boolean before​(TimeRange other)
      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

      public boolean before​(RationalTime other, double epsilon)
      The end of this strictly precedes other by a value >= epsilon. other ↓ [ this ] *
      Parameters:
      other - RationalTime to check for
      epsilon - comparison tolerance
      Returns:
      is this before other
    • before

      public boolean before​(RationalTime other)
      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

      public 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. [this][other] The converse would be other.meets(this)
      Parameters:
      other - TimeRange to check for
      epsilon - comparison tolerance
      Returns:
      does this meet other
    • meets

      public 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. [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

      public boolean begins​(TimeRange other, double epsilon)
      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 for
      epsilon - comparison tolerance
      Returns:
      do the beginnings of both match
    • begins

      public boolean begins​(TimeRange other)
      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

      public boolean begins​(RationalTime other, double epsilon)
      The start of this strictly equals other. other ↓ * [ this ]
      Parameters:
      other - RationalTime to check for
      epsilon - comparison tolerance
      Returns:
      does the RationalTime match the beginning of this
    • begins

      public boolean begins​(RationalTime other)
      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

      public boolean finishes​(TimeRange other, double epsilon)
      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 for
      epsilon - comparison tolerance
      Returns:
      do the ends of both match
    • finishes

      public boolean finishes​(TimeRange other)
      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

      public boolean finishes​(RationalTime other, double epsilon)
      The end of this strictly equals other. other ↓ * [ this ]
      Parameters:
      other - RationalTime to check for
      epsilon - comparison tolerance
      Returns:
      does the RationalTime match the end of this
    • finishes

      public boolean finishes​(RationalTime other)
      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

      public boolean equals​(TimeRange other)
    • equals

      public boolean equals​(java.lang.Object obj)
      Overrides:
      equals in class java.lang.Object
    • notEquals

      public boolean notEquals​(TimeRange other)
    • rangeFromStartEndTime

      public static TimeRange rangeFromStartEndTime​(RationalTime startTime, RationalTime endTime)
      Create a TimeRange from start and end RationalTimes
      Parameters:
      startTime - start time
      endTime - end time
      Returns:
      TimeRange from start and end RationalTimes
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object