Package heronarts.lx.clip
Interface Cursor.Operator
- All Superinterfaces:
Comparator<Cursor>
- Enclosing class:
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 Summary
Modifier and TypeMethodDescriptiondefault CursorapplyDelta(Cursor cursor, Cursor delta, boolean add) Apply a delta to the given cursor, limiting the result to not go below 0default CursorNon-destructive equivalent of constrain.default CursorNon-destructive equivalent of constrain.default CursorNon-destructive equivalent of constrain.default CursorConstrain the cursor to the range from ZERO to the target cursordefault CursorConstrain the cursor to the rangedefault CursorConstrain the cursor's value to the bounds of this clipformatLabel(LXClip clip, Cursor cursor, Cursor labelSpacing) Format a cursor to a user-displayable stringdoublegetLerpFactor(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 postdoublegetLerpRatio(Cursor cursor, Cursor pre, Cursor post) Gets the ratio of a cursor value to the difference between pre and post.doubleReturns a proportional ratio between the two Cursor positionsbooleanReturnstrueif c1 is strictly after c2booleanisAfterOrEqual(Cursor c1, Cursor c2) Returnstrueif c1 is after or at the same time as c2booleanReturnstrueif c1 is strictly before c2booleanisBeforeOrEqual(Cursor c1, Cursor c2) Returnstrueif c1 is before or at the same time as c2booleanReturnstrueif c1 is at the same time as c2booleanReturnstrueif the cursor falls in the given range, inclusivebooleanReturntrueif the cursor is at position 0default CursorReturns the cursor that takes place later, or c2 if equaldefault CursorReturns the cursor that takes place first, or c1 if equalSnap this cursor's value to the nearest intervalsnapCeiling(Cursor cursor, LXClip clip, Cursor snapSize) Snaps this cursor's value to the nearest interval, strictly at this point or afterSnap this cursor's value down to the previous intervalSnap this cursor's value to the nearest interval, strictly at this point or beforeSnap this cursor's value up to the next intervalMethods inherited from interface java.util.Comparator
compare, equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Method Details
-
isZero
Returntrueif the cursor is at position 0- Parameters:
cursor- Cursor- Returns:
trueif the cursor is at position 0
-
isBefore
Returnstrueif c1 is strictly before c2- Parameters:
c1- First cursorc2- Second cursor- Returns:
trueif c1 is strictly before c2
-
isBeforeOrEqual
Returnstrueif c1 is before or at the same time as c2- Parameters:
c1- First cursorc2- Second cursor- Returns:
trueif c1 is before or at the same time as c2
-
isAfter
Returnstrueif c1 is strictly after c2- Parameters:
c1- First cursorc2- Second cursor- Returns:
trueif c1 is strictly after c2
-
isAfterOrEqual
Returnstrueif c1 is after or at the same time as c2- Parameters:
c1- First cursorc2- Second cursor- Returns:
trueif c1 is after or at the same time as c2
-
isEqual
Returnstrueif c1 is at the same time as c2- Parameters:
c1- First cursorc2- Second cursor- Returns:
trueif c1 is at the same time as c2
-
isInRange
Returnstrueif the cursor falls in the given range, inclusive- Parameters:
cursor- Cursor to checkbefore- Lower boundafter- Upper bound- Returns:
trueif the cursor falls in the given range, inclusive
-
getRatio
Returns a proportional ratio between the two Cursor positions- Parameters:
c1- First cursorc2- Second cursor- Returns:
- Ratio of c1 position to c2, or 0 if c2.isZero()
-
getLerpFactor
Gets the lerp factor of a cursor, as a normalized value with 0-1 representing the range between pre and post- Parameters:
cursor- Cursor valuepre- Reference start cursorpost- Reference end cursor- Returns:
- Normalized value from 0-1 assuming this Cursor is between pre and post
-
getLerpRatio
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 valuepre- Reference starting pointpost- Reference ending point- Returns:
- Ratio of the magnitude of this cursor to the difference between pre and post
-
min
Returns the cursor that takes place first, or c1 if equal- Parameters:
c1- First cursorc2- Second cursor- Returns:
- Whichever cursor is earlier, or c1 if equal
-
max
Returns the cursor that takes place later, or c2 if equal- Parameters:
c1- First cursorc2- Second cursor- Returns:
- Whichever cursor is later, or c2 if equal
-
constrain
Constrain the cursor's value to the bounds of this clip- Parameters:
cursor- Cursor to constrainclip- Clip to constrain cursor bounds to- Returns:
- Cursor
-
constrain
Constrain the cursor to the range from ZERO to the target cursor- Parameters:
cursor- Cursor to constrainmax- Maximum acceptable cursor value- Returns:
- Cursor with modification applied
-
constrain
Constrain the cursor to the range- Parameters:
cursor- Cursor to constrainmin- Minimum acceptable cursor valuemax- Maximum acceptable cursor value- Returns:
- This cursor, modified to fall within bounds
-
bound
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 boundclip- Clip whose length to bound by- Returns:
- Cursor if within bounds, otherwise ZERO/clip.length.cursor
-
bound
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 boundmax- Maximum bound- Returns:
- Cursor if within bounds, otherwise ZERO/max are returned
-
bound
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 boundmin- Minimum boundmax- Maximum bound- Returns:
- Cursor if within bounds, otherwise min/max are returned
-
snap
Snap this cursor's value to the nearest interval- Parameters:
clip- Clip contextsnapSize- Snap interval- Returns:
- Cursor, updated
-
snapFloor
Snap this cursor's value to the nearest interval, strictly at this point or before- Parameters:
clip- Clip contextsnapSize- Snap interval- Returns:
- Cursor, updated
-
snapCeiling
Snaps this cursor's value to the nearest interval, strictly at this point or after- Parameters:
cursor- Cursor to snapclip- Clip contextsnapSize- Snap interval- Returns:
- Cursor, updated - may exceed clip length
-
snapUp
Snap this cursor's value up to the next interval- Parameters:
clip- Clip contextsnapSize- Snap interval- Returns:
- Cursor, updated
-
snapDown
Snap this cursor's value down to the previous interval- Parameters:
clip- Clip contextsnapSize- Snap interval- Returns:
- Cursor, updated
-
applyDelta
Apply a delta to the given cursor, limiting the result to not go below 0- Parameters:
cursor- Input cursordelta- Delta to applyadd- True to add, false to subtract- Returns:
- New cursor with operation applied, non-negative
-
formatLabel
Format a cursor to a user-displayable string- Parameters:
clip- Clipcursor- CursorlabelSpacing- Label spacing- Returns:
- User-displayable string
-