public abstract class LXComponent extends Object implements LXPath, LXParameterListener, LXSerializable
Modifier and Type | Class and Description |
---|---|
static interface |
LXComponent.Placeholder
A market interface for a Placeholder component that is used when an LXComponent
class implementation is missing at runtime.
|
static interface |
LXComponent.Renamable
Marker interface for components which can have their label changed.
|
LXSerializable.Utils
Modifier and Type | Field and Description |
---|---|
MutableParameter |
controlSurfaceSemaphore
A semaphore used to keep count of how many remote control surfaces may be
controlling this component.
|
static String |
KEY_CLASS |
static String |
KEY_COMPONENT_ID |
static String |
KEY_ID |
static String |
KEY_PARAMETER_PATH |
static String |
KEY_PATH |
StringParameter |
label
The user-facing label of this component.
|
protected LX |
lx
The LX instance that this component belongs to.
|
DiscreteColorParameter |
modulationColor
A color used to identify this component when it or one of its parameters
is used as a modulation source.
|
Modifier | Constructor and Description |
---|---|
protected |
LXComponent()
Creates a new component with no ID and not part of the LX hierarchy.
|
protected |
LXComponent(LX lx)
Creates a new component as part of an LX hierarchy.
|
protected |
LXComponent(LX lx,
int id)
Creates a new component as part of the LX hierarchy.
|
protected |
LXComponent(LX lx,
int id,
String label)
Creates a new component as part of the LX hierarchy.
|
protected |
LXComponent(LX lx,
String label)
Creates a new component as part of the LX hierarchy.
|
Modifier and Type | Method and Description |
---|---|
protected LXComponent |
addArray(String path,
List<? extends LXComponent> childArray)
Registers an array of subcomponents with this component.
|
protected LXComponent |
addChild(String path,
LXComponent child)
Registers a child component with this component.
|
protected LXComponent |
addInternalParameter(String path,
LXParameter parameter)
Internal implementation parameters.
|
protected LXComponent |
addParameter(LXParameter parameter)
Deprecated.
|
protected LXComponent |
addParameter(String path,
LXParameter parameter)
Adds a parameter to the component at a fixed path.
|
boolean |
contains(LXPath that)
Determines whether the given LX object is contained by this
parent, at any depth in the tree of child components and parameters.
|
protected LXComponent |
copyParameters(LXComponent that)
Utility method to copy all parameter values from another component.
|
void |
dispose()
Invoked when a component is being removed from the system and will no longer be used at all.
|
LXComponent |
getChild(String path)
Accesses the child component object at a given path.
|
static String |
getComponentName(Class<? extends LXComponent> cls)
Gets the name of a component class, automatically removing the suffix of
a generic LX superclass, if one is found
|
static String |
getComponentName(Class<? extends LXComponent> component,
String suffix)
Gets the name of a component class, with a suffix removed
|
static String |
getComponentName(LXComponent component,
String suffix)
Gets the name of an LXComponent object with suffix removed
|
int |
getId()
Accessor for the global id of this component.
|
String |
getLabel()
Accessor for the user-facing label of this component.
|
LX |
getLX()
Accessor to the LX instance that this component is part of.
|
String |
getOscAddress()
Gets the OSC address for this object
|
String |
getOscLabel()
Gets the OSC-friendly label for this object
|
String |
getOscPath()
Accessor for this component's OSC path relative to its parent.
|
LXParameter |
getParameter(String path)
Accessor for parameter at a given path
|
Collection<LXParameter> |
getParameters()
Returns a read-only view of all the parameters in this component.
|
LXComponent |
getParent()
Accessor for the parent component.
|
String |
getPath()
Accessor for the path of this object.
|
boolean |
handleOscMessage(OscMessage message,
String[] parts,
int index)
Handles an OSC message sent to this component.
|
void |
load(LX lx,
JsonObject obj)
Loads the LX component.
|
protected static void |
loadParameters(LXComponent component,
JsonObject obj,
Map<String,LXParameter> parameters)
Utility function to load a set of parameters
|
void |
onParameterChanged(LXParameter parameter)
Subclasses are free to override this if desired.
|
protected LXComponent |
removeParameter(LXParameter parameter)
Removes a parameter from the component.
|
protected LXComponent |
removeParameter(String path)
Removes a parameter from the component.
|
void |
save(LX lx,
JsonObject obj)
Serializes the LX component.
|
protected static void |
saveParameters(LXComponent component,
JsonObject obj,
Map<String,LXParameter> parameters)
Utility function to serialize a set of parameters
|
protected LXComponent |
setParent(LXComponent parent)
Registers this component with a parent object in the hierarchy.
|
String |
toString()
Returns a useful debug string for the component, indicating the class name
along with the ID number and the canonical path
|
String |
toString(LXComponent root)
Returns a useful debug string for the component, indicating the class name
along with the ID number and the canonical path
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
get, get, getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, getComponent, getComponent, getParameter, getParameter
protected LX lx
public final StringParameter label
LXComponent.Renamable
interface.public final DiscreteColorParameter modulationColor
public final MutableParameter controlSurfaceSemaphore
public static final String KEY_ID
public static final String KEY_CLASS
public static final String KEY_COMPONENT_ID
public static final String KEY_PARAMETER_PATH
public static final String KEY_PATH
protected LXComponent()
protected LXComponent(LX lx)
lx
- LX instanceprotected LXComponent(LX lx, String label)
lx
- LX instancelabel
- Initial label for the componentprotected LXComponent(LX lx, int id)
lx
- LX instanceid
- Fixed ID value to give this componentprotected LXComponent(LX lx, int id, String label)
lx
- LX instanceid
- Fixed ID value to give this componentlabel
- Initial label for the componentpublic static String getComponentName(Class<? extends LXComponent> component, String suffix)
component
- Component classsuffix
- Suffix to removepublic static String getComponentName(Class<? extends LXComponent> cls)
cls
- Component classpublic static String getComponentName(LXComponent component, String suffix)
component
- Component instancesuffix
- Suffix to removepublic LX getLX()
null
if this is a dynamic component that has not been registered yet.null
if unregisteredprotected LXComponent addArray(String path, List<? extends LXComponent> childArray)
path
- Path to register the array atchildArray
- Child objectsprotected LXComponent addChild(String path, LXComponent child)
path
- Path relative to thischild
- The child componentpublic LXComponent getChild(String path)
path
- Child pathnull
if not foundprotected final LXComponent setParent(LXComponent parent)
parent
- Parent componentpublic final LXComponent getParent()
null
if this component has
not been registered with any parent.public final int getId()
ID_UNASSIGNED
public String getOscPath()
getPath()
, but certain subclasses may modify this
to support different types of OSC paths that aren't required to match the LX
hierarchy.public final boolean contains(LXPath that)
that
- Potential child objecttrue
if a child component or parameter, false
otherwisepublic String getOscLabel()
public String getOscAddress()
public boolean handleOscMessage(OscMessage message, String[] parts, int index)
message
- Full OSC message objectparts
- The OSC address pattern, broken into an array of partsindex
- Which index into the parts array corresponds to this component's childrentrue
if the OSC message was handled and should be considered consumed, false
otherwisepublic String getPath()
public String getLabel()
LXComponent.Renamable
interface may allow the user to change this value.public String toString()
public String toString(LXComponent root)
root
- Component to simplify path relative topublic void dispose()
super.dispose()
at the appropriate
time to perform the basic cleanup, which may need to happen either before or after cleaning
up other objects.@Deprecated protected final LXComponent addParameter(LXParameter parameter)
addParameter(String, LXParameter)
instead.parameter
- Parameter to addprotected final LXComponent addInternalParameter(String path, LXParameter parameter)
path
- Path to internal parameterparameter
- Parameterprotected LXComponent addParameter(String path, LXParameter parameter)
path
- String key path to the parameter, must be uniqueparameter
- Parameter to add to the componentprotected LXComponent removeParameter(String path)
path
- Parameter pathprotected LXComponent removeParameter(LXParameter parameter)
parameter
- Parameterpublic final Collection<LXParameter> getParameters()
public final LXParameter getParameter(String path)
path
- Path to parameternull
public void onParameterChanged(LXParameter parameter)
onParameterChanged
in interface LXParameterListener
parameter
- Parameter that has a value changeprotected LXComponent copyParameters(LXComponent that)
that
- Other componentprotected static void saveParameters(LXComponent component, JsonObject obj, Map<String,LXParameter> parameters)
component
- Component that owns the parametersobj
- JsonObject to serialize toparameters
- Map of parameters to serializeprotected static void loadParameters(LXComponent component, JsonObject obj, Map<String,LXParameter> parameters)
component
- Component that owns the parametersobj
- JsonObject to serialize toparameters
- Map of parameters to unserializepublic void save(LX lx, JsonObject obj)
super.save(lx, obj)
at the appropriate time.save
in interface LXSerializable
lx
- LX instanceobj
- Object to serialize intopublic void load(LX lx, JsonObject obj)
load
in interface LXSerializable
lx
- LX instanceobj
- Object to deserializeLX library by Mark C. Slee. © 2012-2020