Package heronarts.lx.parameter
Class DiscreteParameter
java.lang.Object
heronarts.lx.parameter.LXListenableParameter
heronarts.lx.parameter.LXListenableNormalizedParameter
heronarts.lx.parameter.DiscreteParameter
- All Implemented Interfaces:
LXPath
,LXNormalizedParameter
,LXParameter
- Direct Known Subclasses:
CompoundDiscreteParameter
,DiscreteColorParameter
,LXPalette.IndexSelector
,ObjectParameter
Parameter type with a discrete set of possible integer values.
-
Nested Class Summary
Nested classes/interfaces inherited from interface heronarts.lx.parameter.LXNormalizedParameter
LXNormalizedParameter.OscMode
Nested classes/interfaces inherited from interface heronarts.lx.parameter.LXParameter
LXParameter.Collection, LXParameter.Formatter, LXParameter.Monitor, LXParameter.MultiMonitor, LXParameter.Polarity, LXParameter.Units
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
protected int
final MutableParameter
protected int
Fields inherited from class heronarts.lx.parameter.LXListenableParameter
description
Fields inherited from interface heronarts.lx.LXPath
ROOT, ROOT_PREFIX, ROOT_SLASH
-
Constructor Summary
ConstructorDescriptionDiscreteParameter
(String label, int range) Parameter with values from [0, range-1], 0 by defaultDiscreteParameter
(String label, int min, int max) Parameter with values from [min, max-1], min by defaultDiscreteParameter
(String label, int value, int min, int max) Parameter with values from [min, max-1], value by defaultDiscreteParameter
(String label, String[] options) Parameter with set of String label valuesDiscreteParameter
(String label, String[] options, int value) Parameter with set of String label values, and a default -
Method Summary
Modifier and TypeMethodDescriptiondecrement
(boolean wrap) decrement
(int amt) decrement
(int amt, boolean wrap) int
The currently selected optionint
int
getIndex()
int
int
double
Gets the value of the parameter in a normalized space from 0 to 1The currently selected optionString[]
The set of string labels for these parametersint
getRange()
double
getValueFromNormalized
(double normalized) Get the equivalent raw parameter value from a normalized valueint
increment
(boolean wrap) increment
(int amt) increment
(int amt, boolean wrap) protected int
normalizedToValue
(double normalized) setDescription
(String description) setIncrementMode
(DiscreteParameter.IncrementMode incrementMode) setIndex
(int index) Set the value by indexsetMappable
(boolean mappable) Sets whether this parameter should be eligible for MIDI/modulation mapping or not.setNormalized
(double normalized) Sets the value or the parameter in normalized space from 0 to 1setOptions
(String[] options) Set the range and option strings for the parametersetOptions
(String[] options, boolean updateRange) Set the range and option strings for the parametersetRange
(int range) Sets range from [0, range-1] inclusivesetRange
(int minValue, int maxValue) Sets the range from [minValue, maxValue-1] inclusivesetUnits
(LXParameter.Units units) setWrappable
(boolean wrappable) protected double
updateValue
(double value) Invoked when the value has changed.Methods inherited from class heronarts.lx.parameter.LXListenableNormalizedParameter
getExponent, getNormalizedWithModulation, getOscMode, incrementNormalized, incrementNormalized, isWrappable, setExponent, setOscMode
Methods inherited from class heronarts.lx.parameter.LXListenableParameter
addListener, addListener, bang, dispose, getDescription, getFormatter, getLabel, getParent, getParentParameter, getPath, getPolarity, getUnits, getValue, incrementValue, isDefault, isMappable, removeListener, reset, reset, setComponent, setFormatter, setPolarity, setValue, setValue
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.LXNormalizedParameter
getBaseNormalized, getBaseNormalizedf, getNormalizedf
Methods inherited from interface heronarts.lx.parameter.LXParameter
dispose, getBaseValue, getBaseValuef, getFormatter, getLabel, getParentParameter, getPolarity, getUnits, getValue, getValuef, isMappable, reset, setComponent, setFormatter, setValue
Methods inherited from interface heronarts.lx.LXPath
getCanonicalLabel, getCanonicalLabel, getCanonicalPath, getCanonicalPath, getDescription, getParent, getPath, isDescendant
-
Field Details
-
minValue
protected int minValue -
maxValue
protected int maxValue -
range
protected int range -
optionsChanged
-
-
Constructor Details
-
DiscreteParameter
Parameter with values from [0, range-1], 0 by default- Parameters:
label
- Name of parameterrange
- range of values
-
DiscreteParameter
Parameter with values from [min, max-1], min by default- Parameters:
label
- Labelmin
- Minimum valuemax
- Maximum value is 1 less than this
-
DiscreteParameter
Parameter with values from [min, max-1], value by default- Parameters:
label
- Labelvalue
- Default valuemin
- Minimum value (inclusive)max
- Maximum value (exclusive)
-
DiscreteParameter
Parameter with set of String label values- Parameters:
label
- Labeloptions
- Values
-
DiscreteParameter
Parameter with set of String label values, and a default- Parameters:
label
- Labeloptions
- Valuesvalue
- Default index
-
-
Method Details
-
setUnits
- Overrides:
setUnits
in classLXListenableNormalizedParameter
-
setWrappable
- Overrides:
setWrappable
in classLXListenableNormalizedParameter
-
setMappable
Description copied from interface:LXParameter
Sets whether this parameter should be eligible for MIDI/modulation mapping or not.- Specified by:
setMappable
in interfaceLXParameter
- Overrides:
setMappable
in classLXListenableParameter
- Parameters:
mappable
- Whether parameter should be available for mapping- Returns:
- this
-
setDescription
- Overrides:
setDescription
in classLXListenableParameter
-
updateValue
protected double updateValue(double value) Description copied from class:LXListenableParameter
Invoked when the value has changed. Subclasses should update any special internal state according to this new value.- Specified by:
updateValue
in classLXListenableParameter
- Parameters:
value
- New value- Returns:
- this
-
getMinValue
public int getMinValue() -
getMaxValue
public int getMaxValue() -
getRange
public int getRange() -
getOptions
The set of string labels for these parameters- Returns:
- Strings, may be null
-
getBaseOption
The currently selected option- Returns:
- String description, or numerical value
-
getOption
The currently selected option- Returns:
- String description, or numerical value
-
setOptions
Set the range and option strings for the parameter- Parameters:
options
- Array of string labels- Returns:
- this
-
setOptions
Set the range and option strings for the parameter- Parameters:
options
- Array of string labelsupdateRange
- Also update the range- Returns:
- this
-
setRange
Sets the range from [minValue, maxValue-1] inclusive- Parameters:
minValue
- Minimum valuemaxValue
- Maximum value, exclusive- Returns:
- this
-
setRange
Sets range from [0, range-1] inclusive- Parameters:
range
- Number of discrete values- Returns:
- this
-
setIndex
Set the value by index- Parameters:
index
- Index in all eligible values, 0 corresponds to minimum value- Returns:
- this
-
increment
-
increment
-
increment
-
increment
-
decrement
-
decrement
-
decrement
-
decrement
-
getValuei
public int getValuei() -
getBaseValuei
public int getBaseValuei() -
getIndex
public int getIndex() -
getBaseIndex
public int getBaseIndex() -
getNormalized
public double getNormalized()Description copied from interface:LXNormalizedParameter
Gets the value of the parameter in a normalized space from 0 to 1- Returns:
- Value of parameter, normalized to range from 0 to 1
-
getValueFromNormalized
public double getValueFromNormalized(double normalized) Description copied from interface:LXNormalizedParameter
Get the equivalent raw parameter value from a normalized value- Parameters:
normalized
- Normalized value- Returns:
- The equivalent raw value
-
normalizedToValue
protected int normalizedToValue(double normalized) -
setNormalized
Description copied from interface:LXNormalizedParameter
Sets the value or the parameter in normalized space from 0 to 1- Parameters:
normalized
- The normalized value, from 0 to 1- Returns:
- this, for method chaining
-
getIncrementMode
-
setIncrementMode
-