public class Scaler extends Object
If each object-mask is scaled independently, touching but non-overlapping objects can become overlapping when scaled. This provides a collective scaling procedure that avoids this using nearest-neighbor interpolation.
Modifier and Type | Method and Description |
---|---|
static <T> ScaledElements<T> |
scaleElements(List<T> elements,
ScaleFactor factor,
boolean overlappingObjects,
Extent clipTo,
AccessObjectMask<T> access)
Scales every element in a list collectively, ensuring the results remain inside a particular
region.
|
static ScaledElements<ObjectMask> |
scaleObjects(ObjectCollection objects,
ScaleFactor factor)
Scales every object-mask in a collection collectively.
|
static ScaledElements<ObjectMask> |
scaleObjects(ObjectCollection objects,
ScaleFactor factor,
boolean overlappingObjects,
Extent clipTo)
Scales every object-mask in a collection collectively, ensuring the results remain
inside a particular region.
|
static ScaledElements<ObjectMask> |
scaleObjects(ObjectCollection objects,
ScaleFactor factor,
boolean overlappingObjects,
Optional<java.util.function.UnaryOperator<ObjectMask>> preOperation,
Optional<java.util.function.UnaryOperator<ObjectMask>> postOperation)
Scales every object-mask in a collection collectively (if not overlappjng), allowing
for additional manipulation before and after scaling.
|
public static ScaledElements<ObjectMask> scaleObjects(ObjectCollection objects, ScaleFactor factor) throws OperationFailedException
It is desirable scale objects together, as interpolation can be done so that adjacent boundaries pre-scaling remain adjacent after scaling (only if there's no overlap among them).
This is an immutable operation.
objects
- objects to scale.factor
- scaling-factor.OperationFailedException
- if objects cannot be successfully scaled.public static ScaledElements<ObjectMask> scaleObjects(ObjectCollection objects, ScaleFactor factor, boolean overlappingObjects, Extent clipTo) throws OperationFailedException
This is an immutable operation.
Like scaleObjects(ObjectCollection,ScaleFactor)
but ensured the scaled-results
will always be inside a particular extent (clipping if necessary).
objects
- objects to scale.factor
- scaling-factor.overlappingObjects
- true if objects may overlap unscaled. false if this is never
allowed. This influences whether scaling occurs collectively (to preserve tight borders
between objects), or individually.clipTo
- clips any objects after scaling to make sure they fit inside this extent.OperationFailedException
- if objects cannot be successfully scaled.public static ScaledElements<ObjectMask> scaleObjects(ObjectCollection objects, ScaleFactor factor, boolean overlappingObjects, Optional<java.util.function.UnaryOperator<ObjectMask>> preOperation, Optional<java.util.function.UnaryOperator<ObjectMask>> postOperation) throws OperationFailedException
objects
- objects to scale.factor
- scaling-factor.overlappingObjects
- true if objects may overlap unscaled. false if this is never
allowed. This influences whether scaling occurs collectively (to preserve tight borders
between objects), or individually.preOperation
- applied to each-object before it is scaled (e.g. flattening).postOperation
- applied to each-object after it is scaled (e.g. clipping to an extent).OperationFailedException
- if objects cannot be successfully scaled.public static <T> ScaledElements<T> scaleElements(List<T> elements, ScaleFactor factor, boolean overlappingObjects, Extent clipTo, AccessObjectMask<T> access) throws OperationFailedException
This is similar to scaleObjects(ObjectCollection, ScaleFactor, boolean, Extent)
but accepts a parameterized type, rather than ObjectMask
.
T
- element-type.elements
- objects to scale.factor
- scaling-factor.overlappingObjects
- true if objects may overlap unscaled. false if this is never
allowed. This influences whether scaling occurs collectively (to preserve tight borders
between objects), or individually.clipTo
- clips any objects after scaling to make sure they fit inside this extent.access
- retrieves a corresponding bounding-box and ObjectMask
from an element.OperationFailedException
- if the scaled-elements cannot be created successfully.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.