Interface MeasurementList
- All Superinterfaces:
AutoCloseable
,Serializable
To help enable efficiency for large sets of PathObjects requiring measurement lists, only String keys and numeric values are included.
QuPath v0.4.0: MeasurementList was updated to have more map-like behavior,
while still using primitive values. In particular, addMeasurement(String, double)
was deprecated and now simply defers to put(String, double)
.
Additionally, the wordy putMeasurement(String, double)
and getMeasurementValue(String)
were deprecated in favor of put(String, double)
and get(String)
- which do the same thing,
but with more familiar syntax.
- Author:
- Pete Bankhead
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
Enum representing different types of measurement list, with different priorities regarding flexibility and efficiency. -
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
addMeasurement
(String name, double value) Deprecated.asMap()
Get a map view of this measurements list.void
clear()
Remove all the measurements from the list.void
close()
Close the list.boolean
containsKey
(String name) Returns true if this list contains a measurement with the specified name.default boolean
Deprecated.since v0.4.0; replaced bycontainsKey(String)
double
Get value for the measurement with the specified name.getMeasurementName
(int ind) Deprecated.since v0.4.0; using names is preferred over indexing butgetMeasurementNames()
can still be usedGet the names of all measurements currently in the list.double
getMeasurementValue
(int ind) Deprecated.since v0.4.0; usingget(String)
is preferred over using an indexdefault double
getMeasurementValue
(String name) Deprecated.since v0.4.0; useget(String)
insteaddefault double
getOrDefault
(String name, double defaultValue) Get the specified measurement, or the provided default value if it is not contained in the list.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
Put all the values from the specified map into this listdefault void
putAll
(MeasurementList list) Put all the values from the specified list into this onedefault void
putMeasurement
(String name, double value) Deprecated.since v0.4.0; replaced byput(String, double)
putMeasurement
(Measurement measurement) Deprecated.since v0.4.0, since there is no real need to create aMeasurement
object and we don't currently use dynamic measurementsdefault double
Remove a named measurementvoid
removeMeasurements
(String... measurementNames) Remove all the measurements with the specified names.int
size()
Returns the number of measurements in the list.boolean
Deprecated.since v0.4.0; the initial implementation of dynamic measurements was never useddefault double[]
values()
Get all measurement values as a double array
-
Method Details
-
addMeasurement
Deprecated.v0.4.0 useput(String, double)
insteadAdd a new measurement. No check is made to ensure the name is unique, and in generalput(String, double)
is to be preferred.- Parameters:
name
-value
-- Returns:
- See Also:
-
putMeasurement
Deprecated.since v0.4.0, since there is no real need to create aMeasurement
object and we don't currently use dynamic measurementsPut a measurement into the list, replacing any previous measurement with the same name.This is similar to add, 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).
While it's probably a good idea for measurements to always have unique names, for some implementations putMeasurement can be must slower than add or addMeasurement - so adding should be preferred if it is known that a measurement with the same name is not present.
- Parameters:
measurement
-- Returns:
-
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
-
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
-
containsNamedMeasurement
Deprecated.since v0.4.0; replaced bycontainsKey(String)
Query if a value with the specified name is in the list.- Parameters:
name
-- Returns:
-
values
default double[] values()Get all measurement values as a double array- Returns:
- Since:
- v0.4.0
-
getMeasurementValue
Deprecated.since v0.4.0; useget(String)
insteadGet the measurement with the specified name.- Parameters:
name
-- Returns:
- the value, or Double.NaN if no measurement is available with the specified name
-
putMeasurement
Deprecated.since v0.4.0; replaced byput(String, double)
Alternative method to callputMeasurement(String, double)
- Parameters:
name
-value
-
-
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 values from the specified list into this one- Parameters:
list
-- Since:
- v0.4.0
-
keySet
Get all available names as a set.- Returns:
-
getMeasurementNames
Get the names of all measurements currently in the list.- Returns:
-
getMeasurementName
Deprecated.since v0.4.0; using names is preferred over indexing butgetMeasurementNames()
can still be usedGet name for the measurement at the specified index in the list.- Parameters:
ind
-- Returns:
-
getMeasurementValue
Deprecated.since v0.4.0; usingget(String)
is preferred over using an indexGet value for the measurement at the specified index in the list.- Parameters:
ind
-- 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
boolean isEmpty()Returns true if the list does not contain any measurements.- Returns:
-
size
int size()Returns the number of measurements in the list.- Returns:
-
supportsDynamicMeasurements
Deprecated.since v0.4.0; the initial implementation of dynamic measurements was never usedReturns true if the list supports dynamic measurements. Dynamic measurements can change their values, and in the interests of efficiency are not supported by all MeasurementList implementations.Use of this is strongly discouraged.
- Returns:
-
close
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
-
removeMeasurements
Remove 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
-
put(String, double)
instead