Package qupath.lib.plugins.parameters
Class ParameterList
java.lang.Object
qupath.lib.plugins.parameters.ParameterList
- All Implemented Interfaces:
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddBooleanParameter
(String key, String prompt, boolean defaultValue) Add a boolean parameter.addBooleanParameter
(String key, String prompt, boolean defaultValue, String helpText) Add a boolean parameter, with help text.<S> ParameterList
addChoiceParameter
(String key, String prompt, S defaultValue, List<S> choices) Add a choice parameter, with an list of choices.<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.addDoubleParameter
(String key, String prompt, double defaultValue) Add a double parameter to this list.addDoubleParameter
(String key, String prompt, double defaultValue, String unit, double lowerBound, double upperBound, String helpText) Add a bounded double parameter to this list.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.addEmptyParameter
(String prompt) Add an 'empty' parameter, that is one that does not take any values.addIntParameter
(String key, String prompt, int defaultValue) Add an int parameter.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.addIntParameter
(String key, String prompt, int defaultValue, String unit, String helpText) Add an int parameter, with optional unit and help text.addStringParameter
(String key, String prompt, String defaultValue) Add a String parameter.addStringParameter
(String key, String prompt, String defaultValue, String helpText) Add a String parameter, with help text.addTitleParameter
(String prompt) Add a title parameter.boolean
containsKey
(Object key) Returns true if a parameter exists in this list with a specified key.static String
convertToJson
(Map<String, ?> map) Convert aMap
to a one-line JSON representation, omitting hidden parameters.static String
convertToJson
(ParameterList params) Convert aParameterList
a one-line JSON representation, omitting hidden parameters.Create a deep copy of this parameter list.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).Get a boolean parameter value (or its default) for the specified key.Get a choice parameter value (or its default) for the specified key.Get a double parameter value (or its default) for the specified key.Get a integer parameter value (or its default) for the specified key.getKeyValueParameters
(boolean includeHidden) Returns a map of keys and their corresponding parameter valuesstatic String
getParameterListJSON
(Map<String, ?> map, String delimiter) Deprecated.static String
getParameterListJSON
(ParameterList params, String delimiter) Deprecated.useconvertToJson(ParameterList)
instead.Returns a map of keys and their corresponding parametersGet a String parameter value (or its default) for the specified key.boolean
Remove all empty parameters from this list.Parameter
<?> removeParameter
(String key) Remove a parameter from this list.void
setHiddenParameters
(boolean hidden, String... keys) Set the 'hidden' flag for parameters with the specified keys.static void
updateParameterList
(ParameterList params, Map<String, String> mapNew, Locale locale) Update a ParameterList with the values specified in a map.
-
Constructor Details
-
ParameterList
public ParameterList()
-
-
Method Details
-
setHiddenParameters
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
Create a deep copy of this parameter list.- Returns:
-
addDoubleParameter
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
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
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
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
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
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
Returns a map of keys and their corresponding parameters- Returns:
-
getKeyValueParameters
Returns a map of keys and their corresponding parameter values- Parameters:
includeHidden
-- Returns:
-
containsKey
Returns true if a parameter exists in this list with a specified key.- Parameters:
key
-- Returns:
-
getBooleanParameterValue
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
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
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
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
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
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
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.useconvertToJson(ParameterList)
instead.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.useconvertToJson(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
Convert aMap
to a one-line JSON representation, omitting hidden parameters. This is useful for scripting.- Parameters:
map
-- Returns:
- See Also:
-
convertToJson
Convert aParameterList
a one-line JSON representation, omitting hidden parameters. This is useful for scripting.- Parameters:
params
-- Returns:
- See Also:
-
convertToJson(Map)
instead.