Class LXPattern

All Implemented Interfaces:
LXComponent.Renamable, LXLoopTask, LXPath, LXPresetComponent, LXSerializable, LXMidiListener, LXModulationContainer, LXOscComponent, LXParameterListener
Direct Known Subclasses:
AlternatingPattern, ChasePattern, ChevronPattern, DmxPattern, GeometryTestPattern, GradientPattern, GraphicEqualizerPattern, ImagePattern, LifePattern, LXModelPattern, LXPattern.Placeholder, NoisePattern, OrboxPattern, PlanesPattern, ScriptPattern, SlideshowPattern, SolidPattern, SoundObjectPattern, SparklePattern, TestPattern

public abstract class LXPattern extends LXDeviceComponent implements LXComponent.Renamable, LXOscComponent
A pattern is the core object that the animation engine uses to generate colors for all the points.
  • Field Details

  • Constructor Details

    • LXPattern

      protected LXPattern(LX lx)
  • Method Details

    • addListener

      public final void addListener(LXPattern.Listener listener)
    • removeListener

      public final void removeListener(LXPattern.Listener listener)
    • isSnapshotControl

      public boolean isSnapshotControl(LXParameter parameter)
      Description copied from class: LXDeviceComponent
      Returns whether this parameter is stored along with snapshots
      Overrides:
      isSnapshotControl in class LXDeviceComponent
      Parameters:
      parameter - Parameter
      Returns:
      true if this can be included in snapshots
    • isHiddenControl

      public boolean isHiddenControl(LXParameter parameter)
      Description copied from class: LXDeviceComponent
      Returns whether this parameter is visible in default remote control or device control UIs
      Overrides:
      isHiddenControl in class LXDeviceComponent
      Parameters:
      parameter - Parameter to check
      Returns:
      true if this should be hidden by default
    • getPath

      public String getPath()
      Description copied from class: LXComponent
      Accessor for the path of this object. Returns the path this component was registered with. Some subclasses may override this if path structure is dynamic.
      Specified by:
      getPath in interface LXPath
      Overrides:
      getPath in class LXComponent
      Returns:
      path of this component relative to its parent
    • updateCompositeBlendOptions

      public void updateCompositeBlendOptions()
    • setIndex

      public void setIndex(int index)
    • getIndex

      public int getIndex()
    • getChannel

      public final LXChannel getChannel()
      Gets the channel that this pattern is loaded in. May be null if the pattern is not yet loaded onto any channel.
      Returns:
      Channel pattern is loaded onto
    • setChannel

      public final LXPattern setChannel(LXChannel channel)
      Called by the engine when pattern is loaded onto a channel. This may only be called once, by the engine. Do not call directly.
      Parameters:
      channel - Channel pattern is loaded onto
      Returns:
      this
    • setInterval

      public LXPattern setInterval(int begin, int end)
      Set an interval during which this pattern is allowed to run. Begin and end times are specified in minutes of the daytime. So midnight corresponds to the value of 0, 360 would be 6:00am, 1080 would be 18:00 (or 6:00pm)
      Parameters:
      begin - Interval start time
      end - Interval end time
      Returns:
      this
    • clearInterval

      public LXPattern clearInterval()
      Clears a timer interval set to this pattern.
      Returns:
      this
    • hasInterval

      public final boolean hasInterval()
      Tests whether there is an interval for this pattern.
      Returns:
      true if there is an interval
    • isInInterval

      public final boolean isInInterval()
      Tests whether this pattern is in an eligible interval.
      Returns:
      true if the pattern has an interval, and is currently in it.
    • setAutoCycleEligible

      public final LXPattern setAutoCycleEligible(boolean eligible)
      Sets whether this pattern is eligible for automatic selection.
      Parameters:
      eligible - Whether eligible for auto-rotation
      Returns:
      this
    • toggleAutoCycleEligible

      public final LXPattern toggleAutoCycleEligible()
      Toggles the eligibility state of this pattern.
      Returns:
      this
    • isAutoCycleEligible

      public final boolean isAutoCycleEligible()
      Determines whether this pattern is eligible to be run at the moment. A pattern is eligible if its eligibility flag has not been set to false, and if it either has no interval, or is currently in its interval.
      Returns:
      True if pattern is eligible to run now
    • initCompositeDamping

      public void initCompositeDamping(boolean wasActivePattern)
    • updateCompositeDamping

      public void updateCompositeDamping(double deltaMs, boolean dampingOn, double dampingTimeSecs)
    • getCompositeDampingLevel

      public double getCompositeDampingLevel()
    • addEffect

      public final LXPattern addEffect(LXEffect effect)
    • addEffect

      public final LXPattern addEffect(LXEffect effect, int index)
    • removeEffect

      public final LXPattern removeEffect(LXEffect effect)
    • reloadEffect

      public LXPattern reloadEffect(LXEffect effect)
    • moveEffect

      public LXPattern moveEffect(LXEffect effect, int index)
    • getEffects

      public final List<LXEffect> getEffects()
    • getEffect

      public LXEffect getEffect(int i)
    • getEffect

      public LXEffect getEffect(String label)
    • 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
    • onLoop

      protected final void onLoop(double deltaMs)
      Overrides:
      onLoop in class LXLayeredComponent
    • run

      protected abstract void run(double deltaMs)
      Main pattern loop function. Invoked in a render loop. Subclasses must implement this function.
      Parameters:
      deltaMs - Number of milliseconds elapsed since last invocation
    • activate

      public final void activate(LXMixerEngine.PatternFriendAccess lock)
      Method invoked by the mixer engine to notify a pattern that it is going to become activated. Not a user-facing API.
    • deactivate

      public final void deactivate(LXMixerEngine.PatternFriendAccess lock)
      Method invoked by the mixer engine to notify a pattern that it is not going to be run. Not a user-facing API.
    • onActive

      protected void onActive()
      Subclasses may override this method. It will be invoked when the pattern is about to become active. Patterns may take care of any initialization needed or reset parameters if desired.
    • onInactive

      protected void onInactive()
      Subclasses may override this method. It will be invoked when the pattern is no longer active. Resources may be freed if desired.
    • onTransitionStart

      public void onTransitionStart()
      Subclasses may override this method. It will be invoked if a transition into this pattern is taking place. This will be called after onActive. This is not invoked on an already-running pattern. It is only called on the new pattern.
    • onTransitionEnd

      public void onTransitionEnd()
      Subclasses may override this method. It will be invoked when the transition into this pattern is complete.
    • midiDispatch

      public void midiDispatch(LXShortMessage message)
      Description copied from class: LXDeviceComponent
      Dispatch a MIDI message to this device, and any of its modulators which should receive that
      Overrides:
      midiDispatch in class LXDeviceComponent
      Parameters:
      message - Message
    • 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 LXDeviceComponent
      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 LXDeviceComponent
      Parameters:
      lx - LX instance
      obj - Object to deserialize
    • dispose

      public void dispose()
      Description copied from class: LXComponent
      Invoked when a component is being removed from the system and will no longer be used at all. This unregisters the component and should free up any resources and parameter listeners. Ideally after this method is called the object should be eligible for garbage collection. Subclasses are generally expected to override this method to handle their particular cleanup work. They should also generally call super.dispose() at the appropriate time to perform the basic cleanup, which may need to happen either before or after cleaning up other objects.
      Overrides:
      dispose in class LXDeviceComponent