public class FitTo extends ScaleCalculator
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.
Constructor and Description |
---|
FitTo() |
Modifier and Type | Method and Description |
---|---|
ScaleFactor |
calculate(Optional<Dimensions> dimensionsToBeScaled,
Optional<ImageSizeSuggestion> suggestedSize)
Calculates a scaling-factor for a source image/entity of particular dimensions.
|
int |
getMultipleOf()
The eventual width and height of the image must be a multiple of this number.
|
SizeXY |
getTargetSize()
The target size.
|
boolean |
isPreserveAspectRatio()
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.
|
getInitialization, getLogger, getPropertyInitializer, initialize, initializeRecursive, initRecursiveWithInitializer, isInitialized, onInitialization
checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
public ScaleFactor calculate(Optional<Dimensions> dimensionsToBeScaled, Optional<ImageSizeSuggestion> suggestedSize) throws OperationFailedException
ScaleCalculator
calculate
in class ScaleCalculator
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.OperationFailedException
- if a scale-factor cannot be successfully calculated.public SizeXY getTargetSize()
public void setTargetSize(SizeXY targetSize)
public boolean isPreserveAspectRatio()
public void setPreserveAspectRatio(boolean preserveAspectRatio)
public int getMultipleOf()
== 1
public void setMultipleOf(int multipleOf)
== 1
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.