Package org.anchoranalysis.spatial.scale
Class RelativeScaleCalculator
Object
RelativeScaleCalculator
- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic ScaleFactor
relativeScale
(Extent source, Extent target) Calculates a scaling factor so as to scalesource
totarget
.static ScaleFactor
relativeScale
(Extent source, Extent target, boolean preserveAspectRatio) Multiplexes betweenrelativeScalePreserveAspectRatio(Extent, Extent)
andrelativeScale(Extent, Extent)
.static ScaleFactor
relativeScalePreserveAspectRatio
(Extent source, Extent target) Calculates a scaling factor so as to maximally scalesource
totarget
- while preserving the aspect ratio.
-
Method Details
-
relativeScale
Multiplexes betweenrelativeScalePreserveAspectRatio(Extent, Extent)
andrelativeScale(Extent, Extent)
.- Parameters:
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, andrelativeScalePreserveAspectRatio(Extent, Extent)
is called, otherwiserelativeScale(Extent, Extent)
.- Returns:
- the scaling-factor to scale the source to be the same size as the target.
-
relativeScalePreserveAspectRatio
Calculates a scaling factor so as to maximally scalesource
totarget
- 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 oftarget
.- Parameters:
source
- source extent (only X and Y dimensions are considered).target
- target extent (only X and Y dimensions are considered).- Returns:
- the scaling-factor to scale the source to be the same size as the target.
-
relativeScale
Calculates a scaling factor so as to scalesource
totarget
.i.e. the scale-factor is
target / source
for each XY dimension.- Parameters:
source
- source extent (only X and Y dimensions are considered).target
- target extent (only X and Y dimensions are considered).- Returns:
- the scaling-factor to scale the source to be the same size as the target.
-