Interface Cursor.Operator

All Superinterfaces:
Comparator<Cursor>
Enclosing class:
Cursor

public static interface Cursor.Operator extends Comparator<Cursor>
The Cursor.Operator interface specifies all the operations that can be performed on Cursors which depend upon the TimeBase setting. Clients of the Cursor API will generally retrieve the appropriate Operator before working with cursor operations - typically this comes from the context of an LXClip.
  • Method Details

    • isZero

      boolean isZero(Cursor cursor)
      Return true if the cursor is at position 0
      Parameters:
      cursor - Cursor
      Returns:
      true if the cursor is at position 0
    • isBefore

      boolean isBefore(Cursor c1, Cursor c2)
      Returns true if c1 is strictly before c2
      Parameters:
      c1 - First cursor
      c2 - Second cursor
      Returns:
      true if c1 is strictly before c2
    • isBeforeOrEqual

      boolean isBeforeOrEqual(Cursor c1, Cursor c2)
      Returns true if c1 is before or at the same time as c2
      Parameters:
      c1 - First cursor
      c2 - Second cursor
      Returns:
      true if c1 is before or at the same time as c2
    • isAfter

      boolean isAfter(Cursor c1, Cursor c2)
      Returns true if c1 is strictly after c2
      Parameters:
      c1 - First cursor
      c2 - Second cursor
      Returns:
      true if c1 is strictly after c2
    • isAfterOrEqual

      boolean isAfterOrEqual(Cursor c1, Cursor c2)
      Returns true if c1 is after or at the same time as c2
      Parameters:
      c1 - First cursor
      c2 - Second cursor
      Returns:
      true if c1 is after or at the same time as c2
    • isEqual

      boolean isEqual(Cursor c1, Cursor c2)
      Returns true if c1 is at the same time as c2
      Parameters:
      c1 - First cursor
      c2 - Second cursor
      Returns:
      true if c1 is at the same time as c2
    • isInRange

      boolean isInRange(Cursor cursor, Cursor before, Cursor after)
      Returns true if the cursor falls in the given range, inclusive
      Parameters:
      cursor - Cursor to check
      before - Lower bound
      after - Upper bound
      Returns:
      true if the cursor falls in the given range, inclusive
    • getRatio

      double getRatio(Cursor c1, Cursor c2)
      Returns a proportional ratio between the two Cursor positions
      Parameters:
      c1 - First cursor
      c2 - Second cursor
      Returns:
      Ratio of c1 position to c2, or 0 if c2.isZero()
    • getLerpFactor

      double getLerpFactor(Cursor cursor, Cursor pre, Cursor post)
      Gets the lerp factor of a cursor, as a normalized value with 0-1 representing the range between pre and post
      Parameters:
      cursor - Cursor value
      pre - Reference start cursor
      post - Reference end cursor
      Returns:
      Normalized value from 0-1 assuming this Cursor is between pre and post
    • getLerpRatio

      double getLerpRatio(Cursor cursor, Cursor pre, Cursor post)
      Gets the ratio of a cursor value to the difference between pre and post. Note that the cursor doesn't have to be contained by pre and post, it's treated as a magnitude
      Parameters:
      cursor - Cursor value
      pre - Reference starting point
      post - Reference ending point
      Returns:
      Ratio of the magnitude of this cursor to the difference between pre and post
    • min

      default Cursor min(Cursor c1, Cursor c2)
      Returns the cursor that takes place first, or c1 if equal
      Parameters:
      c1 - First cursor
      c2 - Second cursor
      Returns:
      Whichever cursor is earlier, or c1 if equal
    • max

      default Cursor max(Cursor c1, Cursor c2)
      Returns the cursor that takes place later, or c2 if equal
      Parameters:
      c1 - First cursor
      c2 - Second cursor
      Returns:
      Whichever cursor is later, or c2 if equal
    • constrain

      default Cursor constrain(Cursor cursor, LXClip clip)
      Constrain the cursor's value to the bounds of this clip
      Parameters:
      cursor - Cursor to constrain
      clip - Clip to constrain cursor bounds to
      Returns:
      Cursor
    • constrain

      default Cursor constrain(Cursor cursor, Cursor max)
      Constrain the cursor to the range from ZERO to the target cursor
      Parameters:
      cursor - Cursor to constrain
      max - Maximum acceptable cursor value
      Returns:
      Cursor with modification applied
    • constrain

      default Cursor constrain(Cursor cursor, Cursor min, Cursor max)
      Constrain the cursor to the range
      Parameters:
      cursor - Cursor to constrain
      min - Minimum acceptable cursor value
      max - Maximum acceptable cursor value
      Returns:
      This cursor, modified to fall within bounds
    • bound

      default Cursor bound(Cursor cursor, LXClip clip)
      Non-destructive equivalent of constrain. Returns ZERO if this cursor is before the ZERO-max range, and max if this cursor is after the ZERO-max range. Otherwise the cursor itself is returned
      Parameters:
      cursor - Cursor to bound
      clip - Clip whose length to bound by
      Returns:
      Cursor if within bounds, otherwise ZERO/clip.length.cursor
    • bound

      default Cursor bound(Cursor cursor, Cursor max)
      Non-destructive equivalent of constrain. Returns ZERO if this cursor is before the ZERO-max range, and max if this cursor is after the ZERO-max range. Otherwise the cursor itself is returned
      Parameters:
      cursor - Cursor to bound
      max - Maximum bound
      Returns:
      Cursor if within bounds, otherwise ZERO/max are returned
    • bound

      default Cursor bound(Cursor cursor, Cursor min, Cursor max)
      Non-destructive equivalent of constrain. Returns min if this cursor is before the min-max range, and max if this cursor is after the min-max range. Otherwise the cursor itself is returned
      Parameters:
      cursor - Cursor to bound
      min - Minimum bound
      max - Maximum bound
      Returns:
      Cursor if within bounds, otherwise min/max are returned
    • snap

      Cursor snap(Cursor cursor, LXClip clip, Cursor snapSize)
      Snap this cursor's value to the nearest interval
      Parameters:
      clip - Clip context
      snapSize - Snap interval
      Returns:
      Cursor, updated
    • snapFloor

      Cursor snapFloor(Cursor cursor, LXClip clip, Cursor snapSize)
      Snap this cursor's value to the nearest interval, strictly at this point or before
      Parameters:
      clip - Clip context
      snapSize - Snap interval
      Returns:
      Cursor, updated
    • snapCeiling

      Cursor snapCeiling(Cursor cursor, LXClip clip, Cursor snapSize)
      Snaps this cursor's value to the nearest interval, strictly at this point or after
      Parameters:
      cursor - Cursor to snap
      clip - Clip context
      snapSize - Snap interval
      Returns:
      Cursor, updated - may exceed clip length
    • snapUp

      Cursor snapUp(Cursor cursor, LXClip clip, Cursor snapSize)
      Snap this cursor's value up to the next interval
      Parameters:
      clip - Clip context
      snapSize - Snap interval
      Returns:
      Cursor, updated
    • snapDown

      Cursor snapDown(Cursor cursor, LXClip clip, Cursor snapSize)
      Snap this cursor's value down to the previous interval
      Parameters:
      clip - Clip context
      snapSize - Snap interval
      Returns:
      Cursor, updated
    • applyDelta

      default Cursor applyDelta(Cursor cursor, Cursor delta, boolean add)
      Apply a delta to the given cursor, limiting the result to not go below 0
      Parameters:
      cursor - Input cursor
      delta - Delta to apply
      add - True to add, false to subtract
      Returns:
      New cursor with operation applied, non-negative
    • formatLabel

      String formatLabel(LXClip clip, Cursor cursor, Cursor labelSpacing)
      Format a cursor to a user-displayable string
      Parameters:
      clip - Clip
      cursor - Cursor
      labelSpacing - Label spacing
      Returns:
      User-displayable string