Class ParameterList

java.lang.Object
qupath.lib.plugins.parameters.ParameterList
All Implemented Interfaces:
Serializable

public class ParameterList extends Object implements Serializable
A collection of Parameters, which can be used for analysis & queried to construct appropriate GUIs.

Each Parameter requires a key to be associated with it.

The order or parameters is maintained.

Author:
Pete Bankhead
See Also:
  • Constructor Details

    • ParameterList

      public ParameterList()
  • Method Details

    • setHiddenParameters

      public void setHiddenParameters(boolean hidden, String... keys)
      Set the 'hidden' flag for parameters with the specified keys. This can be used to notify any consumer that certain parameters are not required, or otherwise should not be presented to the user.
      Parameters:
      hidden -
      keys -
    • duplicate

      public ParameterList duplicate()
      Create a deep copy of this parameter list.
      Returns:
    • addDoubleParameter

      public ParameterList addDoubleParameter(String key, String prompt, double defaultValue)
      Add a double parameter to this list.
      Parameters:
      key -
      prompt -
      defaultValue -
      Returns:
    • addDoubleParameter

      public ParameterList addDoubleParameter(String key, String prompt, double defaultValue, String unit, String helpText)
      Add a double parameter to this list, optionally including a unit and help text.
      Parameters:
      key -
      prompt -
      defaultValue -
      unit -
      helpText -
      Returns:
    • addDoubleParameter

      public ParameterList addDoubleParameter(String key, String prompt, double defaultValue, String unit, double lowerBound, double upperBound, String helpText)
      Add a bounded double parameter to this list.
      Parameters:
      key -
      prompt -
      defaultValue -
      unit -
      lowerBound -
      upperBound -
      helpText -
      Returns:
    • addIntParameter

      public ParameterList addIntParameter(String key, String prompt, int defaultValue)
      Add an int parameter.
      Parameters:
      key -
      prompt -
      defaultValue -
      Returns:
    • addIntParameter

      public ParameterList addIntParameter(String key, String prompt, int defaultValue, String unit, String helpText)
      Add an int parameter, with optional unit and help text.
      Parameters:
      key -
      prompt -
      defaultValue -
      unit -
      helpText -
      Returns:
    • addIntParameter

      public ParameterList addIntParameter(String key, String prompt, int defaultValue, String unit, double lowerBound, double upperBound, String helpText)
      Add a bounded int parameter, with optional unit and help text.
      Parameters:
      key -
      prompt -
      defaultValue -
      unit -
      lowerBound -
      upperBound -
      helpText -
      Returns:
    • addEmptyParameter

      public ParameterList addEmptyParameter(String prompt)
      Add an 'empty' parameter, that is one that does not take any values. The purpose of this is to give a mechanism to add a free text prompt whenever parameter lists are being displayed.

      These will be called empty1, empty2 etc. (so similar names must not be used for other parameters).

      Parameters:
      prompt -
      Returns:
      See Also:
    • addTitleParameter

      public ParameterList addTitleParameter(String prompt)
      Add a title parameter. These will be called title1, title2 etc. (so similar names must not be used for other parameters).
      Parameters:
      prompt -
      Returns:
      See Also:
    • addBooleanParameter

      public ParameterList addBooleanParameter(String key, String prompt, boolean defaultValue)
      Add a boolean parameter.
      Parameters:
      key -
      prompt -
      defaultValue -
      Returns:
    • addBooleanParameter

      public ParameterList addBooleanParameter(String key, String prompt, boolean defaultValue, String helpText)
      Add a boolean parameter, with help text.
      Parameters:
      key -
      prompt -
      defaultValue -
      helpText -
      Returns:
    • addStringParameter

      public ParameterList addStringParameter(String key, String prompt, String defaultValue)
      Add a String parameter.
      Parameters:
      key -
      prompt -
      defaultValue -
      Returns:
    • addStringParameter

      public ParameterList addStringParameter(String key, String prompt, String defaultValue, String helpText)
      Add a String parameter, with help text.
      Parameters:
      key -
      prompt -
      defaultValue -
      helpText -
      Returns:
    • addChoiceParameter

      public <S> ParameterList addChoiceParameter(String key, String prompt, S defaultValue, List<S> choices)
      Add a choice parameter, with an list of choices.
      Type Parameters:
      S -
      Parameters:
      key -
      prompt -
      defaultValue -
      choices -
      Returns:
    • addChoiceParameter

      public <S> ParameterList addChoiceParameter(String key, String prompt, S defaultValue, List<S> choices, String helpText)
      Add a choice parameter, with an list of choices and help text.
      Type Parameters:
      S -
      Parameters:
      key -
      prompt -
      defaultValue -
      choices -
      helpText -
      Returns:
    • getParameters

      public Map<String,Parameter<?>> getParameters()
      Returns a map of keys and their corresponding parameters
      Returns:
    • getKeyValueParameters

      public Map<String,Object> getKeyValueParameters(boolean includeHidden)
      Returns a map of keys and their corresponding parameter values
      Parameters:
      includeHidden -
      Returns:
    • containsKey

      public boolean containsKey(Object key)
      Returns true if a parameter exists in this list with a specified key.
      Parameters:
      key -
      Returns:
    • getBooleanParameterValue

      public Boolean getBooleanParameterValue(String key)
      Get a boolean parameter value (or its default) for the specified key.
      Parameters:
      key -
      Returns:
      Throws:
      IllegalArgumentException - if no boolean parameter exists for the specified key
    • getDoubleParameterValue

      public Double getDoubleParameterValue(String key)
      Get a double parameter value (or its default) for the specified key.
      Parameters:
      key -
      Returns:
      Throws:
      IllegalArgumentException - if no double parameter exists for the specified key
    • getIntParameterValue

      public Integer getIntParameterValue(String key)
      Get a integer parameter value (or its default) for the specified key.
      Parameters:
      key -
      Returns:
      Throws:
      IllegalArgumentException - if no integer parameter exists for the specified key
    • getStringParameterValue

      public String getStringParameterValue(String key)
      Get a String parameter value (or its default) for the specified key.
      Parameters:
      key -
      Returns:
      Throws:
      IllegalArgumentException - if no String parameter exists for the specified key
    • getChoiceParameterValue

      public Object getChoiceParameterValue(String key)
      Get a choice parameter value (or its default) for the specified key.
      Parameters:
      key -
      Returns:
      Throws:
      IllegalArgumentException - if no choice parameter exists for the specified key
    • removeParameter

      public Parameter<?> removeParameter(String key)
      Remove a parameter from this list.
      Parameters:
      key -
      Returns:
    • removeEmptyParameters

      public boolean removeEmptyParameters()
      Remove all empty parameters from this list.
      Returns:
    • updateParameterList

      public static void updateParameterList(ParameterList params, Map<String,String> mapNew, Locale locale)
      Update a ParameterList with the values specified in a map.
      Parameters:
      params -
      mapNew -
      locale - The Locale to use for any parsing required.
    • equalParameters

      public static boolean equalParameters(ParameterList params1, ParameterList params2)
      Check whether two parameter lists contain the same parameters with the same values (or defaults, if no values are set). Note: 'hidden' status is ignored for parameters.
      Parameters:
      params1 -
      params2 -
      Returns:
      true if the two lists contain the same parameters, and return the same results for getValueOrDefault() for all matching parameters.
    • getParameterListJSON

      @Deprecated public static String getParameterListJSON(ParameterList params, String delimiter)
      Deprecated.
      Get a JSON representation of a ParameterList's contents. Note that the current Locale will not be applied to format numbers, and a decimal point will always be used.
      Parameters:
      params -
      delimiter -
      Returns:
    • getParameterListJSON

      @Deprecated public static String getParameterListJSON(Map<String,?> map, String delimiter)
      Deprecated.
      use convertToJson(Map) instead.
      Get a JSON representation of a specified map (expected to contain parameters). Note that the current Locale will not be applied to format numbers, and a decimal point will always be used.
      Parameters:
      map -
      delimiter -
      Returns:
    • convertToJson

      public static String convertToJson(Map<String,?> map)
      Convert a Map to a one-line JSON representation, omitting hidden parameters. This is useful for scripting.
      Parameters:
      map -
      Returns:
      See Also:
    • convertToJson

      public static String convertToJson(ParameterList params)
      Convert a ParameterList a one-line JSON representation, omitting hidden parameters. This is useful for scripting.
      Parameters:
      params -
      Returns:
      See Also: