Package heronarts.lx.parameter
Class LXListenableParameter
java.lang.Object
heronarts.lx.parameter.LXListenableParameter
- All Implemented Interfaces:
LXPath
,LXParameter
- Direct Known Subclasses:
AggregateParameter
,LXListenableNormalizedParameter
,MutableParameter
,StringParameter
This is a parameter instance that can be listened to, meaning we are able to
deterministically know when the value has changed. This means that all
modifications *must* come through setValue().
-
Nested Class Summary
Nested classes/interfaces inherited from interface heronarts.lx.parameter.LXParameter
LXParameter.Collection, LXParameter.Formatter, LXParameter.Monitor, LXParameter.MultiMonitor, LXParameter.Polarity, LXParameter.Units
-
Field Summary
Fields inherited from interface heronarts.lx.LXPath
ROOT, ROOT_PREFIX, ROOT_SLASH
-
Constructor Summary
ModifierConstructorDescriptionprotected
protected
LXListenableParameter
(double value) protected
LXListenableParameter
(String label) protected
LXListenableParameter
(String label, double value) -
Method Summary
Modifier and TypeMethodDescriptionaddListener
(LXParameterListener listener) addListener
(LXParameterListener listener, boolean fireImmediately) bang()
Manually notify all listeners of this parameter's current value.void
dispose()
Invoked when the parameter is done being used and none of its resources are needed anymore.Returns a contextual help message explaining the purpose of this parameter or component to the user, or null if none is available.Gets the formatter to be used for printing this parameter's valuegetLabel()
Gets the label for this parameterReturns the component that this object belongs toReturns the parent aggregate parameter that this parameter belongs togetPath()
Returns the immediate path of this component, relative to its parentGets the polarity of this parameter.getUnits()
Gets the unit format that this parameter's value stores.double
getValue()
Retrieves the value of the parameterincrementValue
(double amount) final boolean
boolean
Whether this parameter should be eligible for mapping via MIDI or modulation control.final LXListenableParameter
removeListener
(LXParameterListener listener) reset()
A method to reset the value of the parameter, if a default is available.reset
(double value) Resets the value of the parameter, giving it a new default.setComponent
(LXComponent component, String path) Sets the component that owns this parametersetDescription
(String description) setFormatter
(LXParameter.Formatter formatter) Sets the formatter used for printing this parameter's valuesetMappable
(boolean mappable) Sets whether this parameter should be eligible for MIDI/modulation mapping or not.setPolarity
(LXParameter.Polarity polarity) setUnits
(LXParameter.Units units) final LXParameter
setValue
(double value) Sets the value of the parameter.final LXParameter
setValue
(double value, boolean notifyListeners) protected abstract double
updateValue
(double value) Invoked when the value has changed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface heronarts.lx.parameter.LXParameter
getBaseValue, getBaseValuef, getValuef
Methods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, isDescendant
-
Field Details
-
description
-
-
Constructor Details
-
LXListenableParameter
protected LXListenableParameter() -
LXListenableParameter
-
LXListenableParameter
protected LXListenableParameter(double value) -
LXListenableParameter
-
-
Method Details
-
getFormatter
Description copied from interface:LXParameter
Gets the formatter to be used for printing this parameter's value- Specified by:
getFormatter
in interfaceLXParameter
- Returns:
- Formatter
-
setFormatter
Description copied from interface:LXParameter
Sets the formatter used for printing this parameter's value- Specified by:
setFormatter
in interfaceLXParameter
- Parameters:
formatter
- Formatter- Returns:
- The parameter
-
getUnits
Description copied from interface:LXParameter
Gets the unit format that this parameter's value stores.- Specified by:
getUnits
in interfaceLXParameter
- Returns:
- Units
-
setUnits
-
getPolarity
Description copied from interface:LXParameter
Gets the polarity of this parameter.- Specified by:
getPolarity
in interfaceLXParameter
- Returns:
- polarity of this parameter
-
setPolarity
-
addListener
-
addListener
-
removeListener
-
setDescription
-
getDescription
Description copied from interface:LXPath
Returns a contextual help message explaining the purpose of this parameter or component to the user, or null if none is available.- Specified by:
getDescription
in interfaceLXPath
- Returns:
- Contextual help string explaining purpose of the element
-
setComponent
Description copied from interface:LXParameter
Sets the component that owns this parameter- Specified by:
setComponent
in interfaceLXParameter
- Parameters:
component
- Componentpath
- Path name for parameter- Returns:
- this
-
getParentParameter
Description copied from interface:LXParameter
Returns the parent aggregate parameter that this parameter belongs to- Specified by:
getParentParameter
in interfaceLXParameter
- Returns:
- Parent aggregate parameter, or null
-
getParent
Description copied from interface:LXPath
Returns the component that this object belongs to -
getPath
Description copied from interface:LXPath
Returns the immediate path of this component, relative to its parent -
dispose
public void dispose()Description copied from interface:LXParameter
Invoked when the parameter is done being used and none of its resources are needed anymore.- Specified by:
dispose
in interfaceLXParameter
-
reset
Description copied from interface:LXParameter
A method to reset the value of the parameter, if a default is available. Not necessarily defined for all parameters, may be ignored.- Specified by:
reset
in interfaceLXParameter
- Returns:
- this
-
reset
Resets the value of the parameter, giving it a new default. Future calls to reset() with no parameter will use this value.- Parameters:
value
- New default value- Returns:
- this
-
incrementValue
-
setValue
Description copied from interface:LXParameter
Sets the value of the parameter.- Specified by:
setValue
in interfaceLXParameter
- Parameters:
value
- The value- Returns:
- this
-
setValue
-
getValue
public double getValue()Description copied from interface:LXParameter
Retrieves the value of the parameter- Specified by:
getValue
in interfaceLXParameter
- Returns:
- Parameter value
-
isDefault
public final boolean isDefault() -
getLabel
Description copied from interface:LXParameter
Gets the label for this parameter- Specified by:
getLabel
in interfaceLXParameter
- Specified by:
getLabel
in interfaceLXPath
- Returns:
- Label of parameter
-
bang
Manually notify all listeners of this parameter's current value. Useful in some situations to force state reset.- Returns:
- this
-
setMappable
Description copied from interface:LXParameter
Sets whether this parameter should be eligible for MIDI/modulation mapping or not.- Specified by:
setMappable
in interfaceLXParameter
- Parameters:
mappable
- Whether parameter should be available for mapping- Returns:
- this
-
isMappable
public boolean isMappable()Description copied from interface:LXParameter
Whether this parameter should be eligible for mapping via MIDI or modulation control.- Specified by:
isMappable
in interfaceLXParameter
- Returns:
true
if mappable, false if otherwise
-
updateValue
protected abstract double updateValue(double value) Invoked when the value has changed. Subclasses should update any special internal state according to this new value.- Parameters:
value
- New value- Returns:
- this
-