Class ObjectWithProperties
Object
ObjectWithProperties
An
ObjectMask
with associated key-value properties.- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionObjectWithProperties
(ObjectMask object) Creates with an existingObjectMask
and empty properties.ObjectWithProperties
(ObjectMask object, Map<String, Object> properties) Creates a newObjectWithProperties
instance.Creates as a bounding-box with all corresponding mask voxels set to off. -
Method Summary
Modifier and TypeMethodDescriptionExposes the underlyingObjectMask
ignoring any properties.The bounding-box which gives a location for the object-mask on an image.Deep copies the current instance.boolean
void
forEachProperty
(BiConsumer<String, Object> consumer) Executes a consumer on each property.A mapping between keys and corresponding values.<T> T
getProperty
(String name) Retrieves the value of a property corresponding to a particular name.int
hashCode()
boolean
hasProperty
(String name) Whether a particular property exists with a particular name.map
(UnaryOperator<ObjectMask> operator) Maps the underlying object-mask to another object-mask, reusing the same properties object.<T> void
setProperty
(String name, T value) Assigns a value to a property with a particular name.sliceBufferLocal
(int sliceIndexRelative) A slice buffer with local coordinates.toString()
-
Constructor Details
-
ObjectWithProperties
Creates as a bounding-box with all corresponding mask voxels set to off.Default
BinaryValuesInt
of (off=0, on=255) are used for the mask.- Parameters:
box
- bounding-box.
-
ObjectWithProperties
Creates with an existingObjectMask
and empty properties.- Parameters:
object
- the object.
-
ObjectWithProperties
Creates a newObjectWithProperties
instance.- Parameters:
object
-properties
- A mapping between keys and corresponding values.
-
-
Method Details
-
setProperty
Assigns a value to a property with a particular name.Any existing value with the same name is replaced.
- Type Parameters:
T
- type of property-value.- Parameters:
name
- the name of the property.value
- the value of the property.
-
getProperty
Retrieves the value of a property corresponding to a particular name.Note that the user must be careful to retreieve this property with the correct-type as it is cast to
<T>
without any checks.- Type Parameters:
T
- type of property-value.- Parameters:
name
- the name of the property.- Returns:
- the corresponding property-value to
name
ornull
if no such value exists.
-
hasProperty
Whether a particular property exists with a particular name.- Parameters:
name
- the name.- Returns:
- true iff the property exists.
-
forEachProperty
Executes a consumer on each property.- Parameters:
consumer
- a consumer accepting the name and the value of the property.
-
map
Maps the underlying object-mask to another object-mask, reusing the same properties object.Note the properties are not duplicated, and the new object will reference the same properties.
This is an immutable operation.
- Parameters:
operator
- the operator that performs the mapping.- Returns:
- the mapped object (with identical properties) to previously.
-
duplicate
Deep copies the current instance.- Returns:
- a deep copy.
-
boundingBox
The bounding-box which gives a location for the object-mask on an image.- Returns:
- the bounding-box.
-
equals
-
hashCode
public int hashCode() -
toString
-
asObjectMask
Exposes the underlyingObjectMask
ignoring any properties.- Returns:
- the underlying
ObjectMask
reusing the existing data object.
-
sliceBufferLocal
A slice buffer with local coordinates.i.e. with coordinates relative to the bounding-box corner.
- Parameters:
sliceIndexRelative
- sliceIndex (z) relative to the bounding-box of the object-mask.- Returns:
- the buffer.
-
getProperties
A mapping between keys and corresponding values.
-