Class ToDimensions
Object
AnchorBean<ScaleCalculator>
InitializableBean<ScaleCalculator, ImageInitialization>
ImageBean<ScaleCalculator>
ScaleCalculator
ToDimensions
public class ToDimensions
extends ScaleCalculator
Calculates a scaling-factor to make the source image have identical dimensions as
dimensionsTarget.
If preserveAspectRatio is true, then the aspect ratio is preserved, and both
dimensions may not be identical to dimensionsTarget, but at least one will be, and the
other will not be exceed that of dimensionsTarget.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionToDimensions(int sizeX, int sizeY) Create with specific lengths for X and Y dimensions.ToDimensions(int sizeX, int sizeY, boolean preserveAspectRatio) Create with specific lengths for X and Y dimensions andpreserveAspectRatio.ToDimensions(DimensionsProvider dimensions) Create with specificdimensions.ToDimensions(DimensionsProvider dimensions, boolean preserveAspectRatio) Create with specificdimensionsandpreserveAspectRatio. -
Method Summary
Modifier and TypeMethodDescriptionScaleFactorDimensionsProviderThe dimensions the source image/entity is desired to be scaled to.DimensionsProviderSource dimensions used as a fallback, if they are not passed as parameter tocalculate(java.util.Optional<org.anchoranalysis.image.core.dimensions.Dimensions>, java.util.Optional<org.anchoranalysis.image.core.dimensions.size.suggestion.ImageSizeSuggestion>).booleanIf true, the ratio between x and y is kept constant when scaling.voidsetDimensions(DimensionsProvider dimensions) The dimensions the source image/entity is desired to be scaled to.voidsetDimensionsSourceFallback(DimensionsProvider dimensionsSourceFallback) Source dimensions used as a fallback, if they are not passed as parameter tocalculate(java.util.Optional<org.anchoranalysis.image.core.dimensions.Dimensions>, java.util.Optional<org.anchoranalysis.image.core.dimensions.size.suggestion.ImageSizeSuggestion>).voidsetPreserveAspectRatio(boolean preserveAspectRatio) If true, the ratio between x and y is kept constant when scaling.Methods inherited from class org.anchoranalysis.bean.initializable.InitializableBean
getInitialization, getLogger, getPropertyInitializer, initialize, initializeRecursive, initRecursiveWithInitializer, isInitialized, onInitializationMethods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
ToDimensions
public ToDimensions(int sizeX, int sizeY) Create with specific lengths for X and Y dimensions.- Parameters:
sizeX- the size of the X-dimension.sizeY- the size of the X-dimension.
-
ToDimensions
public ToDimensions(DimensionsProvider dimensions) Create with specificdimensions.- Parameters:
dimensions- the dimensions the source image/entity is desired to be scaled to.
-
ToDimensions
public ToDimensions(int sizeX, int sizeY, boolean preserveAspectRatio) Create with specific lengths for X and Y dimensions andpreserveAspectRatio.- Parameters:
sizeX- the size of the X-dimension.sizeY- the size of the X-dimension.preserveAspectRatio- if true, the ratio between x and y is kept constant when scaling.
-
ToDimensions
public ToDimensions(DimensionsProvider dimensions, boolean preserveAspectRatio) Create with specificdimensionsandpreserveAspectRatio.- Parameters:
dimensions- the dimensions the source image/entity is desired to be scaled to.preserveAspectRatio- if true, the ratio between x and y is kept constant when scaling.
-
ToDimensions
public ToDimensions()
-
-
Method Details
-
calculate
-
getDimensions
public DimensionsProvider getDimensions()The dimensions the source image/entity is desired to be scaled to. -
setDimensions
public void setDimensions(DimensionsProvider dimensions) The dimensions the source image/entity is desired to be scaled to. -
getDimensionsSourceFallback
public DimensionsProvider getDimensionsSourceFallback()Source dimensions used as a fallback, if they are not passed as parameter tocalculate(java.util.Optional<org.anchoranalysis.image.core.dimensions.Dimensions>, java.util.Optional<org.anchoranalysis.image.core.dimensions.size.suggestion.ImageSizeSuggestion>). -
setDimensionsSourceFallback
public void setDimensionsSourceFallback(DimensionsProvider dimensionsSourceFallback) Source dimensions used as a fallback, if they are not passed as parameter tocalculate(java.util.Optional<org.anchoranalysis.image.core.dimensions.Dimensions>, java.util.Optional<org.anchoranalysis.image.core.dimensions.size.suggestion.ImageSizeSuggestion>). -
isPreserveAspectRatio
public boolean isPreserveAspectRatio()If true, the ratio between x and y is kept constant when scaling.The larger dimension is will be scaled to be the same as
dimensionsTargetand the the smaller dimension is guaranteed to be equal to or lesser than its equivalent indimensionsTarget. -
setPreserveAspectRatio
public void setPreserveAspectRatio(boolean preserveAspectRatio) If true, the ratio between x and y is kept constant when scaling.The larger dimension is will be scaled to be the same as
dimensionsTargetand the the smaller dimension is guaranteed to be equal to or lesser than its equivalent indimensionsTarget.
-