Class Scale
java.lang.Object
is.galia.operation.Scale
- All Implemented Interfaces:
Operation
- Direct Known Subclasses:
ScaleByPercent,ScaleByPixels
Encapsulates a scaling operation. Subclasses implement absolute
(pixel-based) or relative (percentage-based) behavior.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfreeze()Makes the instance unmodifiable.abstract ReductionFactorgetReductionFactor(Size reducedSize, ScaleConstraint scaleConstraint, int maxFactor) abstract double[]getResultingScales(Size fullSize, ScaleConstraint scaleConstraint) abstract SizegetResultingSize(Size imageSize, ReductionFactor reductionFactor, ScaleConstraint scaleConstraint) getResultingSize(Size fullSize, ScaleConstraint scaleConstraint) This default implementation returns thefullSizeargument.booleanisHeightUp(Size comparedToSize, ScaleConstraint comparedToScaleConstraint) booleanisLinear()booleanisUp(Size comparedToSize, ScaleConstraint comparedToScaleConstraint) booleanisWidthUp(Size comparedToSize, ScaleConstraint comparedToScaleConstraint) voidsetFilter(Scale.Filter filter) voidsetLinear(boolean isLinear) toMap(Size fullSize, ScaleConstraint scaleConstraint)
-
Constructor Details
-
Scale
public Scale()
-
-
Method Details
-
freeze
public void freeze()Description copied from interface:OperationMakes the instance unmodifiable. When frozen, mutation methods should throw anIllegalStateExceptionand getters should return immutable values, if possible. (But they should do that anyway.) -
getFilter
- Returns:
- Resample filter to prefer. May be
null.
-
getReductionFactor
public abstract ReductionFactor getReductionFactor(Size reducedSize, ScaleConstraint scaleConstraint, int maxFactor) - Parameters:
reducedSize- Size of an image that has been halved n times.scaleConstraint- Scale constraint relative to the full source image dimensions.maxFactor- Maximum factor to return.- Returns:
- Reduction factor appropriate for the instance.
-
getResultingScales
- Parameters:
fullSize- Full source image dimensions.scaleConstraint- Scale constraint relative to the full source image dimensions. The instance is expressed relative to the constrainedfullSize.- Returns:
- Two-element array containing the resulting X and Y scales when the instance is applied to the given full size.
-
getResultingSize
Description copied from interface:OperationThis default implementation returns thefullSizeargument. It will need to be overridden by operations that could change the image's resulting size.- Specified by:
getResultingSizein interfaceOperation- Parameters:
fullSize- Full source image size.scaleConstraint- Scale constraint applied to the given full size.- Returns:
- Resulting dimensions when the scale is applied to the given full size.
-
getResultingSize
public abstract Size getResultingSize(Size imageSize, ReductionFactor reductionFactor, ScaleConstraint scaleConstraint) - Parameters:
imageSize- Image whose dimensions have been halvedReductionFactor.factortimes.reductionFactor- Number of times the given dimensions have been halved.scaleConstraint- Scale constraint relative to the full source image dimensions.- Returns:
- Resulting dimensions when the scale is applied to the constrained view of the given full size.
-
isHeightUp
- Returns:
- Whether the instance would effectively upscale the image it is applied to on the Y axis.
-
isLinear
public boolean isLinear()- Returns:
- Whether downscaling should happen in a linear color space.
-
isUp
- Returns:
- Whether the instance would effectively upscale the image it is applied to on both axes.
-
isWidthUp
- Returns:
- Whether the instance would effectively upscale the image it is applied to on the X axis.
-
setFilter
- Parameters:
filter- Resample filter to prefer.- Throws:
IllegalStateException- if the instance is frozen.
-
setLinear
public void setLinear(boolean isLinear) - Parameters:
isLinear- Whether downscaling should happen in a linear color space.
-
toMap
-