Class ObjectWithProperties

Object
ObjectWithProperties

public class ObjectWithProperties extends Object
An ObjectMask with associated key-value properties.
Author:
Owen Feehan
  • Constructor Details

    • ObjectWithProperties

      public ObjectWithProperties(BoundingBox box)
      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

      public ObjectWithProperties(ObjectMask object)
      Creates with an existing ObjectMask and empty properties.
      Parameters:
      object - the object.
    • ObjectWithProperties

      public ObjectWithProperties(ObjectMask object, Map<String,Object> properties)
      Creates a new ObjectWithProperties instance.
      Parameters:
      object -
      properties - A mapping between keys and corresponding values.
  • Method Details

    • setProperty

      public <T> void setProperty(String name, T value)
      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

      public <T> T getProperty(String name)
      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 or null if no such value exists.
    • hasProperty

      public boolean hasProperty(String name)
      Whether a particular property exists with a particular name.
      Parameters:
      name - the name.
      Returns:
      true iff the property exists.
    • forEachProperty

      public void forEachProperty(BiConsumer<String,Object> consumer)
      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

      public ObjectWithProperties duplicate()
      Deep copies the current instance.
      Returns:
      a deep copy.
    • boundingBox

      public BoundingBox boundingBox()
      The bounding-box which gives a location for the object-mask on an image.
      Returns:
      the bounding-box.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • asObjectMask

      public ObjectMask asObjectMask()
      Exposes the underlying ObjectMask ignoring any properties.
      Returns:
      the underlying ObjectMask reusing the existing data object.
    • sliceBufferLocal

      public UnsignedByteBuffer sliceBufferLocal(int sliceIndexRelative)
      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

      public Map<String,Object> getProperties()
      A mapping between keys and corresponding values.