Class LXListenableParameter

java.lang.Object
heronarts.lx.parameter.LXListenableParameter
All Implemented Interfaces:
LXPath, LXParameter
Direct Known Subclasses:
AggregateParameter, LXListenableNormalizedParameter, MutableParameter, StringParameter

public abstract class LXListenableParameter extends Object implements LXParameter
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().
  • Field Details

    • description

      protected String description
  • Constructor Details

    • LXListenableParameter

      protected LXListenableParameter()
    • LXListenableParameter

      protected LXListenableParameter(String label)
    • LXListenableParameter

      protected LXListenableParameter(double value)
    • LXListenableParameter

      protected LXListenableParameter(String label, double value)
  • Method Details

    • getFormatter

      public LXParameter.Formatter getFormatter()
      Description copied from interface: LXParameter
      Gets the formatter to be used for printing this parameter's value
      Specified by:
      getFormatter in interface LXParameter
      Returns:
      Formatter
    • setFormatter

      public LXListenableParameter setFormatter(LXParameter.Formatter formatter)
      Description copied from interface: LXParameter
      Sets the formatter used for printing this parameter's value
      Specified by:
      setFormatter in interface LXParameter
      Parameters:
      formatter - Formatter
      Returns:
      The parameter
    • getUnits

      public LXParameter.Units getUnits()
      Description copied from interface: LXParameter
      Gets the unit format that this parameter's value stores.
      Specified by:
      getUnits in interface LXParameter
      Returns:
      Units
    • setUnits

      public LXListenableParameter setUnits(LXParameter.Units units)
    • getPolarity

      public LXParameter.Polarity getPolarity()
      Description copied from interface: LXParameter
      Gets the polarity of this parameter.
      Specified by:
      getPolarity in interface LXParameter
      Returns:
      polarity of this parameter
    • setPolarity

      public LXListenableParameter setPolarity(LXParameter.Polarity polarity)
    • addListener

      public LXListenableParameter addListener(LXParameterListener listener)
    • addListener

      public LXListenableParameter addListener(LXParameterListener listener, boolean fireImmediately)
    • removeListener

      public final LXListenableParameter removeListener(LXParameterListener listener)
    • setDescription

      public LXListenableParameter setDescription(String description)
    • getDescription

      public String 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 interface LXPath
      Returns:
      Contextual help string explaining purpose of the element
    • setComponent

      public LXParameter setComponent(LXComponent component, String path)
      Description copied from interface: LXParameter
      Sets the component that owns this parameter
      Specified by:
      setComponent in interface LXParameter
      Parameters:
      component - Component
      path - Path name for parameter
      Returns:
      this
    • getParentParameter

      public AggregateParameter getParentParameter()
      Description copied from interface: LXParameter
      Returns the parent aggregate parameter that this parameter belongs to
      Specified by:
      getParentParameter in interface LXParameter
      Returns:
      Parent aggregate parameter, or null
    • getParent

      public LXComponent getParent()
      Description copied from interface: LXPath
      Returns the component that this object belongs to
      Specified by:
      getParent in interface LXPath
      Returns:
      Parent component of this path object, or null if it is unowned
    • getPath

      public String getPath()
      Description copied from interface: LXPath
      Returns the immediate path of this component, relative to its parent
      Specified by:
      getPath in interface LXPath
      Returns:
      Path of this object relative to its parent component
    • 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 interface LXParameter
    • reset

      public LXParameter 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 interface LXParameter
      Returns:
      this
    • reset

      public LXParameter reset(double value)
      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

      public LXParameter incrementValue(double amount)
    • setValue

      public final LXParameter setValue(double value)
      Description copied from interface: LXParameter
      Sets the value of the parameter.
      Specified by:
      setValue in interface LXParameter
      Parameters:
      value - The value
      Returns:
      this
    • setValue

      public final LXParameter setValue(double value, boolean notifyListeners)
    • getValue

      public double getValue()
      Description copied from interface: LXParameter
      Retrieves the value of the parameter
      Specified by:
      getValue in interface LXParameter
      Returns:
      Parameter value
    • isDefault

      public final boolean isDefault()
    • getLabel

      public String getLabel()
      Description copied from interface: LXParameter
      Gets the label for this parameter
      Specified by:
      getLabel in interface LXParameter
      Specified by:
      getLabel in interface LXPath
      Returns:
      Label of parameter
    • bang

      public LXListenableParameter bang()
      Manually notify all listeners of this parameter's current value. Useful in some situations to force state reset.
      Returns:
      this
    • setMappable

      public LXListenableParameter 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
      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 interface LXParameter
      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