Class FitTo
Scales an image to approximately similar in size to a
SizeXY
.
Optionally, the aspect-ratio is preserved between width and height.
Optionally, the eventual width, and height can be rounded to the nearest whole multiple of an integer.
- Author:
- Owen Feehan
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncalculate
(Optional<Dimensions> dimensionsToBeScaled, Optional<ImageSizeSuggestion> suggestedSize) Calculates a scaling-factor for a source image/entity of particular dimensions.int
The eventual width and height of the image must be a multiple of this number.The target size.boolean
If true, the aspect-ratio is preserved between width and height.void
setMultipleOf
(int multipleOf) The eventual width and height of the image must be a multiple of this number.void
setPreserveAspectRatio
(boolean preserveAspectRatio) If true, the aspect-ratio is preserved between width and height.void
setTargetSize
(SizeXY targetSize) The target size.Methods inherited from class org.anchoranalysis.bean.initializable.InitializableBean
getInitialization, getLogger, getPropertyInitializer, initialize, initializeRecursive, initRecursiveWithInitializer, isInitialized, onInitialization
Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
FitTo
public FitTo()
-
-
Method Details
-
calculate
public ScaleFactor calculate(Optional<Dimensions> dimensionsToBeScaled, Optional<ImageSizeSuggestion> suggestedSize) throws OperationFailedException Description copied from class:ScaleCalculator
Calculates a scaling-factor for a source image/entity of particular dimensions.- Specified by:
calculate
in classScaleCalculator
- Parameters:
dimensionsToBeScaled
- dimensions of the source image/entity that will be scaled, if they are known.suggestedSize
- a string suggesting dimensions to resize to or a scaling-factor.- Returns:
- the scaling-factor to use.
- Throws:
OperationFailedException
- if a scale-factor cannot be successfully calculated.
-
getTargetSize
The target size. The image will be scaled to be as similar to this as possible, preserving aspect ratio. -
setTargetSize
The target size. The image will be scaled to be as similar to this as possible, preserving aspect ratio. -
isPreserveAspectRatio
public boolean isPreserveAspectRatio()If true, the aspect-ratio is preserved between width and height. Otherwise, they are treated independently. -
setPreserveAspectRatio
public void setPreserveAspectRatio(boolean preserveAspectRatio) If true, the aspect-ratio is preserved between width and height. Otherwise, they are treated independently. -
getMultipleOf
public int getMultipleOf()The eventual width and height of the image must be a multiple of this number. Effecitvely disabled when== 1
-
setMultipleOf
public void setMultipleOf(int multipleOf) The eventual width and height of the image must be a multiple of this number. Effecitvely disabled when== 1
-