Class LXClipLane<T extends LXClipEvent<?>>

java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.clip.LXClipLane<T>
All Implemented Interfaces:
LXPath, LXSerializable, LXParameterListener
Direct Known Subclasses:
MidiNoteClipLane, ParameterClipLane, PatternClipLane

public abstract class LXClipLane<T extends LXClipEvent<?>> extends LXComponent
  • Field Details

  • Constructor Details

    • LXClipLane

      protected LXClipLane(LXClip clip)
  • Method Details

    • CursorOp

      protected Cursor.Operator CursorOp()
    • getIndex

      public int getIndex()
    • recordEvent

      protected final LXClipLane<T> recordEvent(T event)
    • getUIThreadEvents

      public List<T> getUIThreadEvents()
    • eventIterator

      public ListIterator<T> eventIterator(Cursor fromCursor)
      Gets an iterator over this clip lane's events, starting from the position specified by the cursor. The iterator will start at the first event with time equal to or after that cursor.
      Parameters:
      fromCursor - Cursor to begin iteration from (inclusive)
      Returns:
      Iterator over events equal to or after the cursor
    • eventIterator

      public ListIterator<T> eventIterator(Cursor fromCursor, int offset)
      Gets an iterator over this clip lane's events, starting from the position specified by the cursor. The iterator will start at the first event with time equal to or after that cursor, with an offset specified in # of events
      Parameters:
      fromCursor - Cursor to begin iteration from (inclusive)
      offset - Offset the iterator by a number of events from the cursor
      Returns:
      Iterator over events equal to or after the cursor, plus offset
    • eventIterator

      public ListIterator<T> eventIterator(List<T> events, Cursor fromCursor, int offset)
      Gets an iterator over this clip lane's events, starting from the position specified by the cursor. The iterator will start at the first event with time equal to or after that cursor, with an offset specified in # of events
      Parameters:
      events - Event list
      fromCursor - Cursor to begin iteration from (inclusive)
      offset - Offset the iterator by a number of events from the cursor
      Returns:
      Iterator over events equal to or after the cursor, plus offset
    • eventIterator

      public ListIterator<T> eventIterator(List<T> events, Cursor fromCursor, boolean inclusive)
      Gets an iterator over the the events beginning at a given cursor position
      Parameters:
      events - Events to get an iterator for
      fromCursor - Cursor to iterate from
      inclusive - Whether to include events strictly at fromCursor
      Returns:
      Iterator beginning at fromCursor
    • eventIndex

      public int eventIndex(List<T> events, Cursor fromCursor, boolean inclusive)
    • eventIndex

      public int eventIndex(List<T> events, Cursor fromCursor, boolean inclusive, int offset)
    • cursorPlayIndex

      protected int cursorPlayIndex(Cursor cursor)
    • cursorInsertIndex

      protected int cursorInsertIndex(Cursor cursor)
    • cursorPlayIndex

      protected int cursorPlayIndex(List<T> events, Cursor cursor)
    • cursorInsertIndex

      protected int cursorInsertIndex(List<T> events, Cursor cursor)
    • _insertEvent

      protected void _insertEvent(T event)
    • insertEvent

      public LXClipLane<T> insertEvent(T event)
    • moveEvent

      public LXClipLane<T> moveEvent(T event, Cursor cursor)
    • getPreviousEvent

      protected T getPreviousEvent(List<T> events, Cursor cursor)
      Gets the last event occurring before this cursor insert position, if any. Events already in the array with a cursor exactly equal to this cursor are considered to all be previous.
      Parameters:
      events - List of events
      cursor - Cursor position
      Returns:
      Last event with time equal to or less than this cursor
    • getPreviousEvent

      protected T getPreviousEvent(Cursor cursor)
      Gets the last event occurring before this cursor insert position, if any. Events already in the array with a cursor exactly equal to this cursor are considered to all be previous.
      Parameters:
      cursor - Cursor position
      Returns:
      Last event with time equal to or less than this cursor
    • getPreviousEvent

      protected T getPreviousEvent()
      Gets the last event in the lane occurring at or before the time value of the current cursor position.
      Returns:
      Last event equal to or before this cursor position
    • setEventsCursors

      public void setEventsCursors(ArrayList<T> originalEvents, Cursor fromSelectionMin, Cursor fromSelectionMax, Cursor toSelectionMin, Cursor toSelectionMax, Map<T,Double> fromValues, Map<T,Cursor> fromCursors, Map<T,Cursor> toCursors, LXCommand.Clip.Event.SetCursors.Operation operation)
      Set the cursors for a set of events in a range. This event will also destructively clobber any events that the new stretched selection range overlaps with (other than those strictly contained in the set of modified cursors).
      Parameters:
      originalEvents - The original reference event list to modify
      fromSelectionMin - Original lower bound on selection range
      fromSelectionMax - Original upper bound on selection range
      toSelectionMin - New lower bound on selection range
      toSelectionMax - New upper bound on selection range
      fromValues - Ordered map of original event values, pre-modification
      fromCursors - Ordered map of original position of events pre-modification
      toCursors - Ordered map of events to re-position from within the original range
      operation - What kind of modification operation this is
    • reverseEvents

      protected void reverseEvents(List<T> events)
    • setEventNormalized

      protected void setEventNormalized(T event, double value)
    • stitchSelectionMin

      protected T stitchSelectionMin(List<T> originalEvents, List<T> modifiedEvents, Cursor selectionMin, int stitchIndex, boolean force)
    • stitchSelectionMax

      protected T stitchSelectionMax(List<T> originalEvents, List<T> modifiedEvents, Cursor selectionMax, int stitchIndex, boolean force)
    • stitchInner

      protected T stitchInner(List<T> events, Cursor cursor, int rightIndex, boolean isMin, boolean force)
    • stitchOuter

      protected T stitchOuter(List<T> events, Cursor cursor, int rightIndex)
    • stitchInsertIfNeeded

      protected int stitchInsertIfNeeded(List<T> events, T stitch, boolean after)
    • stitchRemoveIfRedundant

      protected boolean stitchRemoveIfRedundant(List<T> events, T stitch, int index)
    • getLabel

      public abstract String getLabel()
      Description copied from class: LXComponent
      Accessor for the user-facing label of this component. Objects that implement the LXComponent.Renamable interface may allow the user to change this value.
      Specified by:
      getLabel in interface LXPath
      Overrides:
      getLabel in class LXComponent
      Returns:
      Label for this component
    • removeRange

      public boolean removeRange(Cursor from, Cursor to)
    • removeRange

      protected boolean removeRange(Cursor from, Cursor to, boolean notify)
    • removeEvent

      public LXClipLane<T> removeEvent(T event)
      Remove the given event from this clip lane
      Parameters:
      event - Event to remove
      Returns:
      this
    • removeEvents

      public LXClipLane<T> removeEvents(List<Integer> eventIndices)
      Remove events at the given indices, which must be sorted ascending
      Parameters:
      eventIndices - List of event indices to remove, sorted ascending
      Returns:
      this
    • load

      public void load(LX lx, JsonObject obj)
      Description copied from class: LXComponent
      Loads the LX component. Restores the ID of the component, as well as its internal and user-facing parameters. Any explicitly registered children will be automatically loaded, so long as they are direct descendants. Dynamic arrays will not be automatically loaded, this is left to subclasses to implement.
      Specified by:
      load in interface LXSerializable
      Overrides:
      load in class LXComponent
      Parameters:
      lx - LX instance
      obj - Object to deserialize
    • beginLoadEvents

      protected void beginLoadEvents(List<T> loadEvents)
    • endLoadEvents

      protected void endLoadEvents(List<T> loadEvents)
    • loadEvent

      protected abstract T loadEvent(LX lx, JsonObject eventObj)
    • save

      public void save(LX lx, JsonObject obj)
      Description copied from class: LXComponent
      Serializes the LX component. By default, all internal and user-facing parameters are serialized, as well as any explicitly registered child components. Note that child arrays are not serialized, or any other dynamic components. Subclasses may override to perform more saving, and are expected to call super.save(lx, obj) at the appropriate time.
      Specified by:
      save in interface LXSerializable
      Overrides:
      save in class LXComponent
      Parameters:
      lx - LX instance
      obj - Object to serialize into