Class RangeSliderOption

java.lang.Object
dev.boze.api.option.Option<double[]>
dev.boze.api.option.RangeSliderOption
All Implemented Interfaces:
Serializable<double[]>

public class RangeSliderOption extends Option<double[]>
A numeric option with a low and high value, adjusted using a two-handle range slider.
Both values are clamped between min and max and snapped to step. Use getMin() and getMax() to read the lower/higher of the two regardless of which handle is which.
  • Field Details

    • min

      public final double min
      The minimum value either handle can be set to
    • max

      public final double max
      The maximum value either handle can be set to
    • step

      public final double step
      The increment by which the handles change
  • Constructor Details

    • RangeSliderOption

      public RangeSliderOption(BaseModule owner, String name, String description, double low, double high, double min, double max, double step)
      Creates a new range slider option.
      Parameters:
      owner - The module that owns this option
      name - The name of this option
      description - The description of this option
      low - The initial low value
      high - The initial high value
      min - The minimum allowed value
      max - The maximum allowed value
      step - The increment between values
    • RangeSliderOption

      public RangeSliderOption(BaseModule owner, String name, String description, double low, double high, double min, double max, double step, Option<?> parent)
      Creates a new range slider option with a parent.
    • RangeSliderOption

      public RangeSliderOption(BaseModule owner, String name, String description, double low, double high, double min, double max, double step, BooleanSupplier visibility)
      Creates a new range slider option with visibility.
    • RangeSliderOption

      public RangeSliderOption(BaseModule owner, String name, String description, double low, double high, double min, double max, double step, BooleanSupplier visibility, Option<?> parent)
      Creates a new range slider option with visibility and a parent.
  • Method Details

    • getValue

      public double[] getValue()
      Description copied from class: Option
      Gets the current value of this option
      Specified by:
      getValue in class Option<double[]>
      Returns:
      The current value
    • setValue

      public double[] setValue(double[] newValue)
      Description copied from class: Option
      Sets the value of this option
      Specified by:
      setValue in class Option<double[]>
      Parameters:
      newValue - The new value to set
      Returns:
      The value that was set (may be different from newValue if validation was performed)
    • set

      public double set(int index, double newValue)
      Sets one handle's value, clamped to [min, max].
      Parameters:
      index - 0 or 1
      newValue - The new value
      Returns:
      The clamped value
    • minIndex

      public int minIndex()
      Returns:
      the index (0 or 1) of the lower handle
    • maxIndex

      public int maxIndex()
      Returns:
      the index (0 or 1) of the higher handle
    • getMin

      public double getMin()
      Returns:
      the lower of the two values
    • getMax

      public double getMax()
      Returns:
      the higher of the two values
    • reset

      public double[] reset()
      Description copied from class: Option
      Resets this option to its default value
      Specified by:
      reset in class Option<double[]>
      Returns:
      The default value
    • toJson

      public com.google.gson.JsonObject toJson()
      Returns:
      The object as a JsonObject
    • fromJson

      public double[] fromJson(com.google.gson.JsonObject object)
      Parameters:
      object - The JsonObject to deserialize
      Returns:
      The deserialized object