Class ScaledElements<T>

Object
ScaledElements<T>
Type Parameters:
T - element-type.

public class ScaledElements<T> extends Object
A list of elements, with an ObjectMask representation, that have been scaled.

When scaling ObjectMasks, so as to keep boundaries between objects exact, objects need to be scaled collectively using a particular interpolation procedure rather than independently.

If any elements overlap with other elements, they are scaled separately independently of the others.

Author:
Owen Feehan
  • Constructor Details

    • ScaledElements

      public ScaledElements(List<T> elements, ScaleFactor scaleFactor, ObjectScalingMethod scalingMethod, Optional<UnaryOperator<T>> preOperation, Optional<UnaryOperator<T>> postOperation, AccessObjectMask<T> access) throws CreateException
      Creates elements to be scaled.
      Parameters:
      elements - element to be scaled (after possibly a preoperation).
      scaleFactor - how much to scale the elements by.
      scalingMethod - how the scaling is performed.
      preOperation - operation applied to each element before it is scaled (e.g. flattening).
      postOperation - operation applied to each element after it is scaled (e.g. flattening).
      access - means of retrieving the ObjectMask that is associated with T and to create new derived elements.
      Throws:
      CreateException - if the internally needed data-structures cannot be successfully created.
  • Method Details

    • scaledObjectFor

      public T scaledObjectFor(T unscaledElement) throws GetOperationFailedException
      Gets the scaled version of an element given the unscaled element.

      The unscaled element must be an identical to that passed into the constructor.

      Parameters:
      unscaledElement - the unscaled-element.
      Returns:
      the corresponding scaled element.
      Throws:
      GetOperationFailedException - if the unscaled element was never passed to the constructor.
    • asCollectionOrderNotPreserved

      public Collection<T> asCollectionOrderNotPreserved()
      Returns the scaled-elements as a collection but without preserving the original element order.

      The total number of objects is identical to the unscaled objects, just the order may differ.

      Returns:
      a collection with the scaled-objects.
    • asListOrderPreserved

      public List<T> asListOrderPreserved(List<T> unscaledElements)
      Returns a list of scaled-elements corresponding to a list of unscaled-elements.
      Parameters:
      unscaledElements - the list of unscaled-elements (all items must have been previously passed to the constructor, but the order need not be identical).
      Returns:
      a newly created list where each elements is respectively the scaled-element for the corresponding input element.
    • asMap

      public Map<T,T> asMap()
      The underlying map used to map an unscaled object to its scaled counterpart.
      Returns:
      the underlying map, as used in this data-structure.
    • size

      public int size()
      Number of scaled-elements.
      Returns:
      the number of elements.