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 TypeMethodDescriptionvoid
freeze()
Makes the instance unmodifiable.abstract ReductionFactor
getReductionFactor
(Size reducedSize, ScaleConstraint scaleConstraint, int maxFactor) abstract double[]
getResultingScales
(Size fullSize, ScaleConstraint scaleConstraint) abstract Size
getResultingSize
(Size imageSize, ReductionFactor reductionFactor, ScaleConstraint scaleConstraint) getResultingSize
(Size fullSize, ScaleConstraint scaleConstraint) This default implementation returns thefullSize
argument.boolean
isHeightUp
(Size comparedToSize, ScaleConstraint comparedToScaleConstraint) boolean
isLinear()
boolean
isUp
(Size comparedToSize, ScaleConstraint comparedToScaleConstraint) boolean
isWidthUp
(Size comparedToSize, ScaleConstraint comparedToScaleConstraint) void
setFilter
(Scale.Filter filter) void
setLinear
(boolean isLinear) toMap
(Size fullSize, ScaleConstraint scaleConstraint)
-
Constructor Details
-
Scale
public Scale()
-
-
Method Details
-
freeze
public void freeze()Description copied from interface:Operation
Makes the instance unmodifiable. When frozen, mutation methods should throw anIllegalStateException
and 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:Operation
This default implementation returns thefullSize
argument. It will need to be overridden by operations that could change the image's resulting size.- Specified by:
getResultingSize
in 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.factor
times.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
-