Class LXFixture

java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.structure.LXFixture
All Implemented Interfaces:
LXComponent.Renamable, LXPath, LXSerializable, LXParameterListener, LXFixtureContainer
Direct Known Subclasses:
JsonFixture, LXProtocolFixture

public abstract class LXFixture extends LXComponent implements LXFixtureContainer, LXComponent.Renamable
An LXFixture is a rich LXComponent representing a physical lighting fixture which may be addressed by output packets. This class encapsulates the ability to configure the dimensions and location of the lighting fixture as well as to specify its output modes and protocol.
  • Field Details

  • Constructor Details

    • LXFixture

      protected LXFixture(LX lx)
    • LXFixture

      protected LXFixture(LX lx, String label)
  • Method Details

    • addParameter

      protected LXComponent addParameter(String path, LXParameter parameter)
      Description copied from class: LXComponent
      Adds a parameter to the component at a fixed path. The parameter will be registered in the LX hierarchy, and if it is of a listenable type will also send and receive OSC messages. Listenable parameters will also be automatically registered with their parent component as a listener for notifications upon any change of value.
      Overrides:
      addParameter in class LXComponent
      Parameters:
      path - String key path to the parameter, must be unique
      parameter - Parameter to add to the component
      Returns:
      this
    • 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
    • getIndex

      public int getIndex()
    • getFirstPointIndex

      protected int getFirstPointIndex()
    • setStructure

      protected void setStructure(LXStructure structure)
    • addChild

      protected void addChild(LXFixture child)
    • removeChild

      protected void removeChild(LXFixture child)
    • fixtureGenerationChanged

      public final void fixtureGenerationChanged(LXFixture fixture)
      Description copied from interface: LXFixtureContainer
      The generation of this fixture has changed, its metrics or hierarchy are now different. The container will need to take this into account.
      Specified by:
      fixtureGenerationChanged in interface LXFixtureContainer
      Parameters:
      fixture - Fixture that has changed
    • fixtureGeometryChanged

      public final void fixtureGeometryChanged(LXFixture fixture)
      Description copied from interface: LXFixtureContainer
      The geometry of this fixture has changed, its metrics and hierarchy are consistent but the point locations may have changed.
      Specified by:
      fixtureGeometryChanged in interface LXFixtureContainer
      Parameters:
      fixture - Fixture that has changed
    • fixtureOutputChanged

      public final void fixtureOutputChanged(LXFixture fixture)
      Description copied from interface: LXFixtureContainer
      The output settings of this fixture has changed, the top level structure should re-consolidate all the outputs.
      Specified by:
      fixtureOutputChanged in interface LXFixtureContainer
      Parameters:
      fixture - Fixture that has changed
    • fixtureTagsChanged

      public final void fixtureTagsChanged(LXFixture fixture)
      Description copied from interface: LXFixtureContainer
      The tags of this fixture has changed, the container will need to take this into account.
      Specified by:
      fixtureTagsChanged in interface LXFixtureContainer
      Parameters:
      fixture - Fixture that has changed
    • addMetricsParameter

      protected LXFixture addMetricsParameter(String path, LXParameter parameter)
      Adds a parameter which impacts the number of LEDs that are in the fixture. Changes to these parameters require re-generating the whole points array.
      Parameters:
      path - Path to parameter
      parameter - Parameter
      Returns:
      this
    • addGeometryParameter

      protected LXFixture addGeometryParameter(String path, LXParameter parameter)
      Adds a parameter which impacts the position of points in the fixture. Changes to these parameters do not require rebuilding the points array, but the point positions are updated and model change notifications are required.
      Parameters:
      path - Path to parameter
      parameter - Parameter
      Returns:
      this
    • addOutputParameter

      protected LXFixture addOutputParameter(String path, LXParameter parameter)
      Adds a parameter which impacts the outputs of the fixture. Whenever one is changed, the outputs will be regenerated.
      Parameters:
      path - Path to parameter
      parameter - Parameter
      Returns:
      this
    • addTagParameter

      protected LXFixture addTagParameter(String path, LXParameter parameter)
      Adds a parameter which impacts the tags of the fixture. Whenever one is changed, the model will be regenerated with new tags.
      Parameters:
      path - Path to parameter
      parameter - Parameter
      Returns:
      this
    • onParameterChanged

      public void onParameterChanged(LXParameter p)
      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:
      p - Parameter that has a value change
    • regenerateOutputs

      protected void regenerateOutputs()
    • buildOutputs

      protected abstract void buildOutputs()
      Subclasses must override this method to provide an implementation that produces the necessary set of outputs for this fixture to be sent. The subclass should call addOutputDefinition(OutputDefinition) or addOutputDirect(LXOutput) for each output.
    • reindexOutputs

      protected void reindexOutputs()
      Subclasses may override this method to update their outputs in the case that the point indexing of this fixture has changed. Outputs may be removed and re-added inside this method if necessary.
    • addOutputDefinition

      protected void addOutputDefinition(LXFixture.OutputDefinition output)
      This method adds an output definition to the fixture
      Parameters:
      output - Output definition to add to the fixture
    • removeOutputDefinition

      protected void removeOutputDefinition(LXFixture.OutputDefinition output)
    • addOutputDirect

      protected void addOutputDirect(LXOutput output)
      Subclasses call this method to add a direct output to this fixture. This may only be called from within the buildOutputs() function. Generally, usage of this method is strongly discouraged in favor of addOutput(), which enables merging of packets across multiple fixtures.
      Parameters:
      output - Output to add directly to this fixture
    • removeOutputDirect

      protected void removeOutputDirect(LXOutput output)
      Subclasses call this method to remove a output from the fixture. This may only be performed from within the reindexOutputs or buildOutputs methods.
      Parameters:
      output - Output to remove
    • clearTransforms

      protected void clearTransforms()
    • addTransform

      protected void addTransform(LXFixture.Transform transform)
    • regenerate

      protected final void regenerate()
      Invoked when this fixture has been loaded or added to some container. Will rebuild the points and the metrics, and notify container of the change to this fixture's generation
    • beforeRegenerate

      protected void beforeRegenerate()
      Subclasses may override this method to do custom preparation work before computeGeometryMatrix(LXMatrix) is called.
    • computeGeometryMatrix

      protected void computeGeometryMatrix(LXMatrix geometryMatrix)
      Subclasses may override this if they perform geometric transformations in a different order or using totally different parameters. The supplied parameter is a mutable matrix which will initially hold the value of the parent transformation matrix. It can then be further manipulated based upon the parameters.
      Parameters:
      geometryMatrix - The geometry transformation matrix for this object
    • computePointGeometry

      protected abstract void computePointGeometry(LXMatrix transform, List<LXPoint> points)
      This method should be implemented by subclasses to generate the geometry of the fixture any time its geometry parameters have changed. The correct number of points will have already been computed, and merely need to have their positions set.
      Parameters:
      transform - A transform matrix representing the fixture's position
      points - The list of points that need to have their positions set
    • constructModel

      protected LXModel constructModel(List<LXPoint> modelPoints, List<? extends LXModel> childModels, List<String> tags)
      Subclasses may override this method to use custom model type
      Parameters:
      modelPoints - Points in the model
      childModels - Child models
      tags - Model tags
      Returns:
      LXModel instance, or concrete subclass
    • constructPoint

      protected LXPoint constructPoint(int localIndex)
      Subclasses may override this method to use custom point types
      Parameters:
      localIndex - Index of the point relative to this fixture
      Returns:
      LXPoint or concrete subclass
    • copyPoint

      protected LXPoint copyPoint(LXPoint copy)
      Subclasses may override this method to use custom point types
      Parameters:
      copy - Point to make a copy of
      Returns:
      LXPoint or concrete subclass, should be deep copy of the original
    • addModelMetaData

      protected void addModelMetaData(Map<String,String> metaData)
      Subclasses may override to add additiona metadata fields for inclusion in the model
      Parameters:
      metaData - Map to add meta-data fields to
    • getDefaultTags

      protected String[] getDefaultTags()
      Subclasses may override to return an array of default tag types for this fixture in the model hierarchy
      Returns:
      List of model tag types for this fixture
    • setTags

      protected LXFixture setTags(List<String> tags)
      Set the string tag values for this fixture
      Parameters:
      tags - Tag values
      Returns:
      this
    • toSubmodels

      protected LXFixture.Submodel[] toSubmodels()
      Subclasses may override when they specify submodels
      Returns:
      Array of submodel objects
    • size

      protected abstract int size()
      Subclasses must implement to specify the number of points in the fixture. This does not include the number of points that are in children.
      Returns:
      number of points immediately in the fixture
    • getIndexBufferOffset

      public final int getIndexBufferOffset()
      Returns the offset of this fixture in the index buffer
      Returns:
      Offset into the index buffer
    • getGeometryMatrix

      public LXMatrix getGeometryMatrix()
      Returns a copy of the geometry matrix for this fixture
      Returns:
      Copy of geometry matrix
    • getGeometryMatrix

      public LXMatrix getGeometryMatrix(LXMatrix m)
      Returns the geometry transformation matrix, copied into the given matrix
      Parameters:
      m - LXMatrix object to copy into
      Returns:
      Geometric transformation matrix, copied into parameter value
    • totalSize

      public final int totalSize()
      Total points in this model and all its submodels
      Returns:
      Total number of points in this model and all submodels
    • 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 LXComponent
    • 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