Package heronarts.lx.color
Class LXSwatch
java.lang.Object
heronarts.lx.LXComponent
heronarts.lx.color.LXSwatch
- All Implemented Interfaces:
LXComponent.Renamable
,LXLoopTask
,LXPath
,LXSerializable
,LXOscComponent
,LXParameterListener
public class LXSwatch
extends LXComponent
implements LXLoopTask, LXOscComponent, LXComponent.Renamable
A swatch is a set of up to 5 dynamic colors that can be referenced by patterns and effects.
-
Nested Class Summary
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 BooleanParameter
final List<LXDynamicColor>
static final int
final TriggerParameter
Fields inherited from class heronarts.lx.LXComponent
children, 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 TypeMethodDescriptionaddColor()
Adds a new dynamic color to the swatchaddColor
(int index, JsonObject colorObj) addListener
(LXSwatch.Listener listener) Registers a listener to the swatchvoid
dispose()
Invoked when a component is being removed from the system and will no longer be used at all.getColor
(int index) Retrieves the color at a given index in the swatch.int
getIndex()
getPath()
Accessor for the path of this object.void
load
(LX lx, JsonObject obj) Loads the LX component.void
loop
(double deltaMs) Removes the last color from the swatchremoveColor
(int index) Removes the color at a specific index from the swatchremoveColor
(LXDynamicColor color) Removes a specific color from the swatchremoveListener
(LXSwatch.Listener listener) Unregisters a listener to the swatchvoid
save
(LX lx, JsonObject obj) Serializes the LX component.Methods inherited from class heronarts.lx.LXComponent
addArray, addChild, addInternalParameter, addLegacyInternalParameter, addLegacyParameter, addParameter, addParameter, addParameters, contains, copyParameters, getCategory, getChild, getComponentName, getComponentName, getComponentName, getDescription, getId, getLabel, getLX, getOscAddress, getOscLabel, getOscPath, getParameter, getParameters, getParent, handleOscMessage, hasParameter, isValidOscParameter, loadParameters, loadPreset, onParameterChanged, removeParameter, removeParameter, removeParameter, removeParameter, 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.osc.LXOscComponent
getOscAddress, handleOscMessage
Methods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, isDescendant
-
Field Details
-
MAX_COLORS
public static final int MAX_COLORS- See Also:
-
colors
-
recall
-
autoCycleEligible
-
-
Constructor Details
-
LXSwatch
-
-
Method Details
-
getIndex
public int getIndex() -
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
-
loop
public void loop(double deltaMs) - Specified by:
loop
in interfaceLXLoopTask
-
getColor
Retrieves the color at a given index in the swatch. If this swatch does not specify a color at that index, then the last valid color is returned instead.- Parameters:
index
- Index- Returns:
- Dynamic color at that index
-
addColor
Adds a new dynamic color to the swatch- Returns:
- The newly added color
-
addColor
-
removeColor
Removes the last color from the swatch- Returns:
- The removed color
-
removeColor
Removes a specific color from the swatch- Parameters:
color
- The color to remove- Returns:
- The removed color
-
removeColor
Removes the color at a specific index from the swatch- Parameters:
index
- Index to remove- Returns:
- Color removed
-
addListener
Registers a listener to the swatch- Parameters:
listener
- Swatch listener- Returns:
- this
-
removeListener
Unregisters a listener to the swatch- Parameters:
listener
- Swatch listener- Returns:
- this
-
save
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 callsuper.save(lx, obj)
at the appropriate time.- Specified by:
save
in interfaceLXSerializable
- Overrides:
save
in classLXComponent
- Parameters:
lx
- LX instanceobj
- Object to serialize into
-
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
-
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
-