Package org.anchoranalysis.spatial.scale
Class RelativeScaleCalculator
Object
org.anchoranalysis.spatial.scale.RelativeScaleCalculator
public class RelativeScaleCalculator extends Object
- Author:
- Owen Feehan
-
Method Summary
Modifier and Type Method Description static ScaleFactorrelativeScale(Extent source, Extent target)Calculates a scaling factor so as to scalesourcetotarget.static ScaleFactorrelativeScale(Extent source, Extent target, boolean preserveAspectRatio)Multiplexes betweenrelativeScalePreserveAspectRatio(Extent, Extent)andrelativeScale(Extent, Extent).static ScaleFactorrelativeScalePreserveAspectRatio(Extent source, Extent target)Calculates a scaling factor so as to maximally scalesourcetotarget- 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 scalesourcetotarget- 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 scalesourcetotarget.i.e. the scale-factor is
target / sourcefor 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.
-