Class NumericParameter<S extends Number>

java.lang.Object
qupath.lib.plugins.parameters.NumericParameter<S>
Type Parameters:
S -
All Implemented Interfaces:
Serializable, Parameter<S>
Direct Known Subclasses:
DoubleParameter, IntParameter

public abstract class NumericParameter<S extends Number> extends Object
Abstract parameter to represent a numeric value.
Author:
Pete Bankhead
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected S
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Get a default value to use if the Parameter has not been otherwise set.
    Get a description of the meaning of the Parameter; may be displayed e.g.
    double
    Retrieve the lower bound.
    Get some prompt text that may be displayed to a user.
    Get the unit to display for this parameter (may be null if no unit is available).
    double
    Retrieve the upper bound.
    Get the current set value (may be null).
    Get the current set value, or any default if no value has been set.
    boolean
    Query whether getHelpText() returns a meaningful String (as opposed to null).
    boolean
    Returns true if this parameter has both lower and upper bounds constraining valid values.
    boolean
    Returns true if the parameter has a valid lower bound.
    boolean
    Returns true if the parameter has a valid upper bound.
    boolean
    Test is the 'hidden' flag is set for the parameter.
    boolean
    Returns true if this neither a lower nor an upper bound constraining valid values.
    boolean
    isValidInput(S value)
    Numbers are considered valid if they are not NaN
    void
    Set last value to null (so default can be used).
    abstract boolean
    setDoubleLastValue(double val)
    A class for setting the numeric value as a double (subclasses should convert this as needed).
    void
    setHidden(boolean hidden)
    Mark that a parameter should not be displayed to a user.
    void
    setRange(double minValue, double maxValue)
    Set the upper and lower bounds.
    boolean
    Set last value using a string; implementing classes may need to parse this
    boolean
    setValue(S value)
    Set the Parameter to have a specified value.
    abstract boolean
    Set the value of this parameter, constraining it to be within any lower and upper bounds if necessary.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface qupath.lib.plugins.parameters.Parameter

    duplicate
  • Field Details

    • lastValue

      protected S extends Number lastValue
  • Method Details

    • hasLowerAndUpperBounds

      public boolean hasLowerAndUpperBounds()
      Returns true if this parameter has both lower and upper bounds constraining valid values.
      Returns:
    • isUnbounded

      public boolean isUnbounded()
      Returns true if this neither a lower nor an upper bound constraining valid values.
      Returns:
    • getLowerBound

      public double getLowerBound()
      Retrieve the lower bound. May be Double.NEGATIVE_INFINITY if the parameter has no lower bound.
      Returns:
    • getUpperBound

      public double getUpperBound()
      Retrieve the upper bound. May be Double.POSITIVE_INFINITY if the parameter has no upper bound.
      Returns:
    • setRange

      public void setRange(double minValue, double maxValue)
      Set the upper and lower bounds.

      Note: depending on how the parameter is displayed (or if it is displayed) this might not appear to make a difference. If shown through a ParameterPanel (in QuPath's JavaFX GUI) it is better to set limits via the panel rather than directly using this method.

      Parameters:
      minValue -
      maxValue -
    • hasLowerBound

      public boolean hasLowerBound()
      Returns true if the parameter has a valid lower bound.
      Returns:
    • hasUpperBound

      public boolean hasUpperBound()
      Returns true if the parameter has a valid upper bound.
      Returns:
    • getUnit

      public String getUnit()
      Get the unit to display for this parameter (may be null if no unit is available).
      Returns:
    • setValueWithBoundsCheck

      public abstract boolean setValueWithBoundsCheck(S lastValue)
      Set the value of this parameter, constraining it to be within any lower and upper bounds if necessary.
      Parameters:
      lastValue -
      Returns:
    • setDoubleLastValue

      public abstract boolean setDoubleLastValue(double val)
      A class for setting the numeric value as a double (subclasses should convert this as needed).
      Parameters:
      val -
      Returns:
    • isValidInput

      public boolean isValidInput(S value)
      Numbers are considered valid if they are not NaN
      Parameters:
      value -
      Returns:
      true if the value would be valid, false otherwise
    • setStringLastValue

      public boolean setStringLastValue(Locale locale, String value)
      Description copied from interface: Parameter
      Set last value using a string; implementing classes may need to parse this
      Parameters:
      locale -
      value -
      Returns:
    • setHidden

      public void setHidden(boolean hidden)
      Description copied from interface: Parameter
      Mark that a parameter should not be displayed to a user. This is useful, for example, if a parameter list changes the parameters to be displayed depending upon the image available or current settings, e.g. using different parameters when the pixel size is known in microns.
      Specified by:
      setHidden in interface Parameter<S>
      Parameters:
      hidden -
    • isHidden

      public boolean isHidden()
      Description copied from interface: Parameter
      Test is the 'hidden' flag is set for the parameter.
      Specified by:
      isHidden in interface Parameter<S>
      Returns:
    • getDefaultValue

      public S getDefaultValue()
      Description copied from interface: Parameter
      Get a default value to use if the Parameter has not been otherwise set.
      Specified by:
      getDefaultValue in interface Parameter<S>
      Returns:
    • getValue

      public S getValue()
      Description copied from interface: Parameter
      Get the current set value (may be null).
      Specified by:
      getValue in interface Parameter<S>
      Returns:
      See Also:
    • resetValue

      public void resetValue()
      Description copied from interface: Parameter
      Set last value to null (so default can be used).
      Specified by:
      resetValue in interface Parameter<S>
    • getValueOrDefault

      public S getValueOrDefault()
      Description copied from interface: Parameter
      Get the current set value, or any default if no value has been set.
      Specified by:
      getValueOrDefault in interface Parameter<S>
      Returns:
      See Also:
    • getPrompt

      public String getPrompt()
      Description copied from interface: Parameter
      Get some prompt text that may be displayed to a user.
      Specified by:
      getPrompt in interface Parameter<S>
      Returns:
    • setValue

      public boolean setValue(S value)
      Description copied from interface: Parameter
      Set the Parameter to have a specified value.
      Specified by:
      setValue in interface Parameter<S>
      Parameters:
      value -
      Returns:
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hasHelpText

      public boolean hasHelpText()
      Description copied from interface: Parameter
      Query whether getHelpText() returns a meaningful String (as opposed to null).
      Specified by:
      hasHelpText in interface Parameter<S>
      Returns:
    • getHelpText

      public String getHelpText()
      Description copied from interface: Parameter
      Get a description of the meaning of the Parameter; may be displayed e.g. as a tooltip.
      Specified by:
      getHelpText in interface Parameter<S>
      Returns: