public class RelativeScaleCalculator extends Object
Modifier and Type | Method and Description |
---|---|
static ScaleFactor |
relativeScale(Extent source,
Extent target)
Calculates a scaling factor so as to scale
source to target . |
static ScaleFactor |
relativeScale(Extent source,
Extent target,
boolean preserveAspectRatio)
Multiplexes between
relativeScalePreserveAspectRatio(Extent, Extent) and relativeScale(Extent, Extent) . |
static ScaleFactor |
relativeScalePreserveAspectRatio(Extent source,
Extent target)
Calculates a scaling factor so as to maximally scale
source to target -
while preserving the aspect ratio. |
public static ScaleFactor relativeScale(Extent source, Extent target, boolean preserveAspectRatio)
relativeScalePreserveAspectRatio(Extent, Extent)
and relativeScale(Extent, Extent)
.source
- source extent (only X and Y dimensions are considered).target
- target extent (only X and Y dimensions are considered).preserveAspectRatio
- iff true, the aspect ratio is preserved, and relativeScalePreserveAspectRatio(Extent, Extent)
is called, otherwise relativeScale(Extent, Extent)
.public static ScaleFactor relativeScalePreserveAspectRatio(Extent source, Extent target)
source
to target
-
while preserving the aspect ratio.
Either the X or Y dimension is guaranteed to have a scale-factor target / source
,
and the other will scale so as not to exceed the size of target
.
source
- source extent (only X and Y dimensions are considered).target
- target extent (only X and Y dimensions are considered).public static ScaleFactor relativeScale(Extent source, Extent target)
source
to target
.
i.e. the scale-factor is target / source
for each XY dimension.
source
- source extent (only X and Y dimensions are considered).target
- target extent (only X and Y dimensions are considered).Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.