Class DiscreteParameter

All Implemented Interfaces:
LXPath, LXNormalizedParameter, LXParameter
Direct Known Subclasses:
CompoundDiscreteParameter, DiscreteColorParameter, LXPalette.IndexSelector, ObjectParameter

public class DiscreteParameter extends LXListenableNormalizedParameter
Parameter type with a discrete set of possible integer values.
  • Field Details

    • minValue

      protected int minValue
    • maxValue

      protected int maxValue
    • range

      protected int range
    • optionsChanged

      public final MutableParameter optionsChanged
  • Constructor Details

    • DiscreteParameter

      public DiscreteParameter(String label, int range)
      Parameter with values from [0, range-1], 0 by default
      Parameters:
      label - Name of parameter
      range - range of values
    • DiscreteParameter

      public DiscreteParameter(String label, int min, int max)
      Parameter with values from [min, max-1], min by default
      Parameters:
      label - Label
      min - Minimum value
      max - Maximum value is 1 less than this
    • DiscreteParameter

      public DiscreteParameter(String label, int value, int min, int max)
      Parameter with values from [min, max-1], value by default
      Parameters:
      label - Label
      value - Default value
      min - Minimum value (inclusive)
      max - Maximum value (exclusive)
    • DiscreteParameter

      public DiscreteParameter(String label, String[] options)
      Parameter with set of String label values
      Parameters:
      label - Label
      options - Values
    • DiscreteParameter

      public DiscreteParameter(String label, String[] options, int value)
      Parameter with set of String label values, and a default
      Parameters:
      label - Label
      options - Values
      value - Default index
  • Method Details

    • setUnits

      public DiscreteParameter setUnits(LXParameter.Units units)
      Overrides:
      setUnits in class LXListenableNormalizedParameter
    • setWrappable

      public DiscreteParameter setWrappable(boolean wrappable)
      Overrides:
      setWrappable in class LXListenableNormalizedParameter
    • setMappable

      public DiscreteParameter setMappable(boolean mappable)
      Description copied from interface: LXParameter
      Sets whether this parameter should be eligible for MIDI/modulation mapping or not.
      Specified by:
      setMappable in interface LXParameter
      Overrides:
      setMappable in class LXListenableParameter
      Parameters:
      mappable - Whether parameter should be available for mapping
      Returns:
      this
    • setDescription

      public DiscreteParameter setDescription(String description)
      Overrides:
      setDescription in class LXListenableParameter
    • 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 class LXListenableParameter
      Parameters:
      value - New value
      Returns:
      this
    • getMinValue

      public int getMinValue()
    • getMaxValue

      public int getMaxValue()
    • getRange

      public int getRange()
    • getOptions

      public String[] getOptions()
      The set of string labels for these parameters
      Returns:
      Strings, may be null
    • getBaseOption

      public String getBaseOption()
      The currently selected option
      Returns:
      String description, or numerical value
    • getOption

      public String getOption()
      The currently selected option
      Returns:
      String description, or numerical value
    • setOptions

      public DiscreteParameter setOptions(String[] options)
      Set the range and option strings for the parameter
      Parameters:
      options - Array of string labels
      Returns:
      this
    • setOptions

      public DiscreteParameter setOptions(String[] options, boolean updateRange)
      Set the range and option strings for the parameter
      Parameters:
      options - Array of string labels
      updateRange - Also update the range
      Returns:
      this
    • setRange

      public DiscreteParameter setRange(int minValue, int maxValue)
      Sets the range from [minValue, maxValue-1] inclusive
      Parameters:
      minValue - Minimum value
      maxValue - Maximum value, exclusive
      Returns:
      this
    • setRange

      public DiscreteParameter setRange(int range)
      Sets range from [0, range-1] inclusive
      Parameters:
      range - Number of discrete values
      Returns:
      this
    • setIndex

      public DiscreteParameter setIndex(int index)
      Set the value by index
      Parameters:
      index - Index in all eligible values, 0 corresponds to minimum value
      Returns:
      this
    • increment

      public DiscreteParameter increment()
    • increment

      public DiscreteParameter increment(boolean wrap)
    • increment

      public DiscreteParameter increment(int amt)
    • increment

      public DiscreteParameter increment(int amt, boolean wrap)
    • decrement

      public DiscreteParameter decrement()
    • decrement

      public DiscreteParameter decrement(boolean wrap)
    • decrement

      public DiscreteParameter decrement(int amt)
    • decrement

      public DiscreteParameter decrement(int amt, boolean wrap)
    • 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

      public DiscreteParameter setNormalized(double normalized)
      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

      public DiscreteParameter.IncrementMode getIncrementMode()
    • setIncrementMode

      public DiscreteParameter setIncrementMode(DiscreteParameter.IncrementMode incrementMode)