Package qupath.lib.measurements
Interface MeasurementList
- All Superinterfaces:
AutoCloseable
,Serializable
Interface defining a feature measurement list, consisting of key value pairs.
To help enable efficiency for large sets of PathObjects requiring measurement lists, only String keys and numeric values are included.
In QuPath v0.4.0 several methods were deprecated, and these were removed in v0.6.0. The main aim was to make the API more consistent and easier to use.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Enum representing different types of measurement list, with different priorities regarding flexibility and efficiency. -
Method Summary
Modifier and TypeMethodDescriptionasMap()
Get a map view of this measurements list.void
clear()
Remove all the measurements from the list.default void
close()
Close the list.default boolean
containsKey
(String name) Returns true if this list contains a measurement with the specified name.double
Get value for the measurement with the specified name.getByIndex
(int ind) Get an immutable representation of a single measurement.Deprecated.Get an unmodifiable list of all measurements.getNames()
Get the names of all measurements currently in the list.default double
getOrDefault
(String name, double defaultValue) Get the specified measurement, or the provided default value if it is not contained in the list.default boolean
isEmpty()
Returns true if the list does not contain any measurements.keySet()
Get all available names as a set.void
Put a measurement value into the list, replacing any previous measurement with the same name.default void
putAll
(Collection<? extends Measurement> list) Put all the measurements from the specified list into this onedefault void
Put all the values from the specified map into this listdefault void
putAll
(MeasurementList list) Put all the measurements from the specified list into this onedouble
Remove a named measurementvoid
Remove all the measurements with the specified names.default void
removeMeasurements
(String... measurementNames) Deprecated.v0.6.0 useremoveAll(String...)
insteaddefault int
size()
Returns the number of measurements in the list.double[]
values()
Get a snapshot of all measurement values as a double array.
-
Method Details
-
put
Put a measurement value into the list, replacing any previous measurement with the same name.This is similar to adding, but with a check to remove any existing measurement with the same name (if multiple measurements have the same name, the first will be replaced).
- Parameters:
name
-value
-- Since:
- v0.4.0
-
getMeasurements
List<Measurement> getMeasurements()Get an unmodifiable list of all measurements. This provides a snapshot of the current measurements, and should not be affected by changes to the list.- Returns:
-
getByIndex
Get an immutable representation of a single measurement. This provides a snapshot of the current measurement, and should not be affected by changes to the list.- Returns:
-
getOrDefault
Get the specified measurement, or the provided default value if it is not contained in the list.This provides an alternative to
get(String)
which always uses a default ofDouble.NaN
.- Parameters:
name
-defaultValue
-- Returns:
- Since:
- v0.4.0
-
values
double[] values()Get a snapshot of all measurement values as a double array. Changes to the array will not impact the measurement list.- Returns:
- Since:
- v0.4.0
-
remove
Remove a named measurement- Parameters:
name
-- Returns:
- the value that was removed, or Double.NaN if the value was not in the list
- Since:
- v0.4.0
-
putAll
Put all the values from the specified map into this list- Parameters:
map
-- Since:
- v0.4.0
-
putAll
Put all the measurements from the specified list into this one- Parameters:
list
-- Since:
- v0.4.0
-
putAll
Put all the measurements from the specified list into this one- Parameters:
list
-- Since:
- v0.4.0
-
keySet
Get all available names as a set.- Returns:
- Implementation Note
- the current implementation is much less efficient than
getNames()
, but is included to more closely resemble Map behavior. The list of names and size of the returned set here should be identical; if they aren't, duplicate names seem to be present and a warning is logged. This shouldn't be possible with new code, but could conceivably occur if a list from a pre-v0.4.0 QuPath version is deserialized (or there is a bad bug somewhere here - if so, please report it!).
-
getNames
Get the names of all measurements currently in the list. Note that this method should return an unmodifiable snapshot of the current names, and not be affected by changes to the list.- Returns:
-
getMeasurementNames
Deprecated.v0.6.0 usegetNames()
insteadGet the names of all measurements currently in the list. Note that this method should return an unmodifiable snapshot of the current names, and not be affected by changes to the list.- Returns:
-
get
Get value for the measurement with the specified name.- Parameters:
name
-- Returns:
- the measurement value, or Double.NaN if the measurement is not available
- Since:
- v0.4.0
- See Also:
-
containsKey
Returns true if this list contains a measurement with the specified name.- Parameters:
name
-- Returns:
- Since:
- v0.4.0
-
isEmpty
default boolean isEmpty()Returns true if the list does not contain any measurements.- Returns:
-
size
default int size()Returns the number of measurements in the list.- Returns:
-
close
default void close()Close the list. Depending on the implementation, the list may then adjust its internal storage to be more efficient.- Specified by:
close
in interfaceAutoCloseable
-
removeAll
Remove all the measurements with the specified names.- Parameters:
measurementNames
-
-
removeMeasurements
Deprecated.v0.6.0 useremoveAll(String...)
insteadRemove all the measurements with the specified names.- Parameters:
measurementNames
-
-
clear
void clear()Remove all the measurements from the list. -
asMap
Get a map view of this measurements list. This is a map that is backed by the list, which means that putting or retrieving elements modifies the list. It also means that there can be some loss of precision if the list does not support Double (e.g. it uses a float array for storage).- Returns:
- a map view of this measurement list
- Implementation Requirements
- The returned map should already be synchronized.
-
getNames()
instead