Package heronarts.lx.structure
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Class which defines a LXFixture output.static enum
Output protocolsprotected class
Class which represents a segment of the pixels in this fixture object (and its children), with a starting point, number and stride length all relative to this fixture's size.class
Helper class to ensure that Submodels are *only* constructed using the points from the produced LXModel array.static class
static enum
Nested classes/interfaces inherited from class heronarts.lx.LXComponent
LXComponent.Hidden, LXComponent.Placeholder, LXComponent.Renamable
Nested classes/interfaces inherited from interface heronarts.lx.LXSerializable
LXSerializable.Utils
-
Field Summary
Modifier and TypeFieldDescriptionfinal BoundedParameter
final BooleanParameter
static final int
static final int
final BooleanParameter
final BooleanParameter
final BooleanParameter
protected static final LXFixture.Submodel[]
protected final List<LXFixture.OutputDefinition>
Publicly accessible list of the outputs that should be sent to this fixturefinal BoundedParameter
Publicly accessible immutable view of the points in this fixture.static final double
final BoundedParameter
final BoundedParameter
final BooleanParameter
final BooleanParameter
final StringParameter
final BoundedParameter
final BoundedParameter
final BoundedParameter
final BoundedParameter
Fields inherited from class heronarts.lx.LXComponent
internalParameters, KEY_CHILDREN, KEY_CLASS, KEY_COMPONENT_ID, KEY_ID, KEY_INTERNAL, KEY_PARAMETER_PATH, KEY_PARAMETERS, KEY_PATH, KEY_RESET, label, legacyInternalParameters, legacyParameters, lx, modulationColor, modulationControlsExpanded, modulationsExpanded, parameters, presetFile
Fields inherited from interface heronarts.lx.LXPath
ROOT, ROOT_PREFIX, ROOT_SLASH
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
protected LXFixture
addGeometryParameter
(String path, LXParameter parameter) Adds a parameter which impacts the position of points in the fixture.protected LXFixture
addMetricsParameter
(String path, LXParameter parameter) Adds a parameter which impacts the number of LEDs that are in the fixture.protected void
addModelMetaData
(Map<String, String> metaData) Subclasses may override to add additiona metadata fields for inclusion in the modelprotected void
This method adds an output definition to the fixtureprotected void
addOutputDirect
(LXOutput output) Subclasses call this method to add a direct output to this fixture.protected LXFixture
addOutputParameter
(String path, LXParameter parameter) Adds a parameter which impacts the outputs of the fixture.protected LXComponent
addParameter
(String path, LXParameter parameter) Adds a parameter to the component at a fixed path.protected LXFixture
addTagParameter
(String path, LXParameter parameter) Adds a parameter which impacts the tags of the fixture.protected void
addTransform
(LXFixture.Transform transform) protected void
Subclasses may override this method to do custom preparation work beforecomputeGeometryMatrix(LXMatrix)
is called.protected abstract void
Subclasses must override this method to provide an implementation that produces the necessary set of outputs for this fixture to be sent.protected void
protected void
computeGeometryMatrix
(LXMatrix geometryMatrix) Subclasses may override this if they perform geometric transformations in a different order or using totally different parameters.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.protected LXModel
Subclasses may override this method to use custom model typeprotected LXPoint
constructPoint
(int localIndex) Subclasses may override this method to use custom point typesprotected LXPoint
Subclasses may override this method to use custom point typesvoid
dispose()
Invoked when a component is being removed from the system and will no longer be used at all.final void
fixtureGenerationChanged
(LXFixture fixture) The generation of this fixture has changed, its metrics or hierarchy are now different.final void
fixtureGeometryChanged
(LXFixture fixture) The geometry of this fixture has changed, its metrics and hierarchy are consistent but the point locations may have changed.final void
fixtureOutputChanged
(LXFixture fixture) The output settings of this fixture has changed, the top level structure should re-consolidate all the outputs.final void
fixtureTagsChanged
(LXFixture fixture) The tags of this fixture has changed, the container will need to take this into account.protected String[]
Subclasses may override to return an array of default tag types for this fixture in the model hierarchyprotected int
Returns a copy of the geometry matrix for this fixtureReturns the geometry transformation matrix, copied into the given matrixint
getIndex()
final int
Returns the offset of this fixture in the index buffergetPath()
Accessor for the path of this object.void
load
(LX lx, JsonObject obj) Loads the LX component.void
Subclasses are free to override this if desired.protected final void
Invoked when this fixture has been loaded or added to some container.protected void
protected void
Subclasses may override this method to update their outputs in the case that the point indexing of this fixture has changed.protected void
removeChild
(LXFixture child) protected void
protected void
removeOutputDirect
(LXOutput output) Subclasses call this method to remove a output from the fixture.protected void
setStructure
(LXStructure structure) protected LXFixture
Set the string tag values for this fixtureprotected abstract int
size()
Subclasses must implement to specify the number of points in the fixture.protected LXFixture.Submodel[]
Subclasses may override when they specify submodelsfinal int
Total points in this model and all its submodelsMethods inherited from class heronarts.lx.LXComponent
addArray, addChild, addInternalParameter, addLegacyInternalParameter, addLegacyParameter, addParameter, addParameters, contains, copyParameters, getCategory, getChild, getComponentName, getComponentName, getComponentName, getDescription, getId, getLabel, getLX, getOscAddress, getOscLabel, getOscPath, getParameter, getParameters, getParent, handleOscMessage, hasParameter, isValidOscParameter, loadParameters, loadPreset, removeParameter, removeParameter, removeParameter, removeParameter, save, savePreset, setDescription, setParent, toOscQuery, toOscQuery, toOscQuery, toString, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, isDescendant
-
Field Details
-
DEFAULT_OUTPUT_STRIDE
public static final int DEFAULT_OUTPUT_STRIDE- See Also:
-
DEFAULT_OUTPUT_REPEAT
public static final int DEFAULT_OUTPUT_REPEAT- See Also:
-
POSITION_RANGE
public static final double POSITION_RANGE- See Also:
-
selected
-
identify
-
x
-
y
-
z
-
yaw
-
pitch
-
roll
-
scale
-
deactivate
-
enabled
-
brightness
-
mute
-
solo
-
tags
-
children
-
outputsDirect
Publicly accessible list of the outputs that should be sent to this fixture -
outputDefinitions
-
tagList
-
metaData
-
points
Publicly accessible immutable view of the points in this fixture. Should not be directly modified. Only contains this fixture's direct points, not any of its children. -
NO_SUBMODELS
-
-
Constructor Details
-
LXFixture
-
LXFixture
-
-
Method Details
-
addParameter
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 classLXComponent
- Parameters:
path
- String key path to the parameter, must be uniqueparameter
- Parameter to add to the component- Returns:
- this
-
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 interfaceLXPath
- Overrides:
getPath
in classLXComponent
- Returns:
- path of this component relative to its parent
-
getIndex
public int getIndex() -
getFirstPointIndex
protected int getFirstPointIndex() -
setStructure
-
addChild
-
removeChild
-
fixtureGenerationChanged
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 interfaceLXFixtureContainer
- Parameters:
fixture
- Fixture that has changed
-
fixtureGeometryChanged
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 interfaceLXFixtureContainer
- Parameters:
fixture
- Fixture that has changed
-
fixtureOutputChanged
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 interfaceLXFixtureContainer
- Parameters:
fixture
- Fixture that has changed
-
fixtureTagsChanged
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 interfaceLXFixtureContainer
- Parameters:
fixture
- Fixture that has changed
-
addMetricsParameter
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 parameterparameter
- Parameter- Returns:
- this
-
addGeometryParameter
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 parameterparameter
- Parameter- Returns:
- this
-
addOutputParameter
Adds a parameter which impacts the outputs of the fixture. Whenever one is changed, the outputs will be regenerated.- Parameters:
path
- Path to parameterparameter
- Parameter- Returns:
- this
-
addTagParameter
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 parameterparameter
- Parameter- Returns:
- this
-
onParameterChanged
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 interfaceLXParameterListener
- Overrides:
onParameterChanged
in classLXComponent
- 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 calladdOutputDefinition(OutputDefinition)
oraddOutputDirect(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
This method adds an output definition to the fixture- Parameters:
output
- Output definition to add to the fixture
-
removeOutputDefinition
-
addOutputDirect
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
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
-
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 beforecomputeGeometryMatrix(LXMatrix)
is called. -
computeGeometryMatrix
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
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 positionpoints
- 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 modelchildModels
- Child modelstags
- Model tags- Returns:
- LXModel instance, or concrete subclass
-
constructPoint
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
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
Subclasses may override to add additiona metadata fields for inclusion in the model- Parameters:
metaData
- Map to add meta-data fields to
-
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
Set the string tag values for this fixture- Parameters:
tags
- Tag values- Returns:
- this
-
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
Returns a copy of the geometry matrix for this fixture- Returns:
- Copy of geometry matrix
-
getGeometryMatrix
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 callsuper.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 classLXComponent
-
load
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 interfaceLXSerializable
- Overrides:
load
in classLXComponent
- Parameters:
lx
- LX instanceobj
- Object to deserialize
-