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 SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic enumEnum representing different types of measurement list, with different priorities regarding flexibility and efficiency.
- 
Method SummaryModifier and TypeMethodDescriptionasMap()Get a map view of this measurements list.voidclear()Remove all the measurements from the list.default voidclose()Close the list.default booleancontainsKey(String name) Returns true if this list contains a measurement with the specified name.doubleGet 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 doublegetOrDefault(String name, double defaultValue) Get the specified measurement, or the provided default value if it is not contained in the list.default booleanisEmpty()Returns true if the list does not contain any measurements.keySet()Get all available names as a set.voidPut a measurement value into the list, replacing any previous measurement with the same name.default voidputAll(Collection<? extends Measurement> list) Put all the measurements from the specified list into this onedefault voidPut all the values from the specified map into this listdefault voidputAll(MeasurementList list) Put all the measurements from the specified list into this onedoubleRemove a named measurementvoidRemove all the measurements with the specified names.default voidremoveMeasurements(String... measurementNames) Deprecated.v0.6.0 useremoveAll(String...)insteaddefault intsize()Returns the number of measurements in the list.double[]values()Get a snapshot of all measurement values as a double array.
- 
Method Details- 
putPut 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
 
- 
getMeasurementsList<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:
 
- 
getByIndexGet 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:
 
- 
getOrDefaultGet 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
 
- 
valuesdouble[] 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
 
- 
removeRemove 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
 
- 
putAllPut all the values from the specified map into this list- Parameters:
- map-
- Since:
- v0.4.0
 
- 
putAllPut all the measurements from the specified list into this one- Parameters:
- list-
- Since:
- v0.4.0
 
- 
putAllPut all the measurements from the specified list into this one- Parameters:
- list-
- Since:
- v0.4.0
 
- 
keySetGet 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!).
 
- 
getNamesGet 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:
 
- 
getMeasurementNamesDeprecated.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:
 
- 
getGet 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:
 
- 
containsKeyReturns true if this list contains a measurement with the specified name.- Parameters:
- name-
- Returns:
- Since:
- v0.4.0
 
- 
isEmptydefault boolean isEmpty()Returns true if the list does not contain any measurements.- Returns:
 
- 
sizedefault int size()Returns the number of measurements in the list.- Returns:
 
- 
closedefault void close()Close the list. Depending on the implementation, the list may then adjust its internal storage to be more efficient.- Specified by:
- closein interface- AutoCloseable
 
- 
removeAllRemove all the measurements with the specified names.- Parameters:
- measurementNames-
 
- 
removeMeasurementsDeprecated.v0.6.0 useremoveAll(String...)insteadRemove all the measurements with the specified names.- Parameters:
- measurementNames-
 
- 
clearvoid clear()Remove all the measurements from the list.
- 
asMapGet 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