Class LXSnapshotEngine

java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.snapshot.LXSnapshotEngine
All Implemented Interfaces:
LXLoopTask, LXPath, LXSerializable, LXOscComponent, LXParameterListener

public class LXSnapshotEngine extends LXComponent implements LXOscComponent, LXLoopTask
The snapshot engine stores snapshots in time of the state of project settings. This includes mixer settings, the parameter values of the active patterns and effects that are running at the given time.
  • Field Details

  • Constructor Details

    • LXSnapshotEngine

      public LXSnapshotEngine(LX lx)
  • Method Details

    • registerGlobal

      public LXSnapshotEngine registerGlobal(LXComponent component)
      Registers a global component for storage in global snapshots
      Parameters:
      component - Global component
      Returns:
      this
    • onParameterChanged

      public void onParameterChanged(LXParameter parameter)
      Description copied from class: LXComponent
      Subclasses are free to override this if desired. It will automatically fire for any listenable parameter that is registered with this component.
      Specified by:
      onParameterChanged in interface LXParameterListener
      Overrides:
      onParameterChanged in class LXComponent
      Parameters:
      parameter - Parameter that has a value change
    • addListener

      public LXSnapshotEngine addListener(LXSnapshotEngine.Listener listener)
    • removeListener

      public LXSnapshotEngine removeListener(LXSnapshotEngine.Listener listener)
    • addSnapshot

      public LXGlobalSnapshot addSnapshot()
      Adds a new snapshot that takes the current state of the program.
      Returns:
      New snapshot that holds a view of the current state
    • addSnapshot

      public LXSnapshotEngine addSnapshot(LXGlobalSnapshot snapshot)
      Adds a snapshot to the engine. This snapshot is assumed to already exist and have been somehow populated.
      Parameters:
      snapshot - Snapshot to add
      Returns:
      this
    • addSnapshot

      public LXSnapshotEngine addSnapshot(LXGlobalSnapshot snapshot, int index)
      Adds a snapshot to the engine. This snapshot is assumed to already exist and have been somehow populated.
      Parameters:
      snapshot - Snapshot to add
      index - Index to add at
      Returns:
      this
    • removeSnapshot

      public LXSnapshotEngine removeSnapshot(LXGlobalSnapshot snapshot)
      Removes a snapshot from the engine
      Parameters:
      snapshot - Snapshot to remove
      Returns:
      this
    • moveSnapshot

      public LXSnapshotEngine moveSnapshot(LXGlobalSnapshot snapshot, int index)
      Moves a snapshot to a new order in the engine snapshot list
      Parameters:
      snapshot - Snapshot
      index - New position to occupy
      Returns:
      this
    • getCursorSnapshot

      public LXGlobalSnapshot getCursorSnapshot()
      Returns the snapshot that the cursor currently points to, if any.
      Returns:
      Snapshot or null
    • recall

      public boolean recall(LXGlobalSnapshot snapshot)
      Recall this snapshot, apply all of its values
      Parameters:
      snapshot - The snapshot to recall
      Returns:
      True the snapshot was recalled, false if it was already mid-transition
    • recall

      public boolean recall(LXGlobalSnapshot snapshot, List<LXCommand> commands)
      Recall this snapshot, and populate an array of commands which would need to be undone by this operation.
      Parameters:
      snapshot - Snapshot to recall
      commands - Array to populate with all the commands processed
      Returns:
      True the snapshot was recalled, false if it was already mid-transition
    • getTransitionProgress

      public double getTransitionProgress()
    • getAutoCycleProgress

      public double getAutoCycleProgress()
    • loop

      public void loop(double deltaMs)
      Specified by:
      loop in interface LXLoopTask
    • clear

      public void clear()
      Clears all snapshots from the engine. Generally should not be publicly used.
    • handleOscMessage

      public boolean handleOscMessage(OscMessage message, String[] parts, int index)
      Description copied from class: LXComponent
      Handles an OSC message sent to this component. By default this method handles registered components and parameters, but subclasses may override this method to handle different types of OSC messages.
      Specified by:
      handleOscMessage in interface LXOscComponent
      Overrides:
      handleOscMessage in class LXComponent
      Parameters:
      message - Full OSC message object
      parts - The OSC address pattern, broken into an array of parts
      index - Which index into the parts array corresponds to this component's children
      Returns:
      true if the OSC message was handled and should be considered consumed, false otherwise
    • findSnapshotViews

      public List<LXSnapshot.View> findSnapshotViews(LXComponent component)
      Find all snapshot views that involve the selected component. This is typically called before removal of that component to identify now-defunct references.
      Parameters:
      component - Component
      Returns:
      List of all views that reference this component, or null
    • findSnapshotParameterViews

      public List<LXSnapshot.View> findSnapshotParameterViews(LXParameter parameter)
    • removeSnapshotViews

      public void removeSnapshotViews(LXComponent component)
      Remove all snapshot views that reference the given component
      Parameters:
      component - Component that is referenced
    • removeSnapshotParameterViews

      public void removeSnapshotParameterViews(LXParameter parameter)
      Remove all snapshot views that reference the given parameter
      Parameters:
      parameter - Parameter that is referenced
    • 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
    • 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