Class ScaleByPercent
java.lang.Object
is.galia.operation.Scale
is.galia.operation.ScaleByPercent
- All Implemented Interfaces:
Operation
N.B.:
getPercent()
should not be used when figuring out how to
apply an instance to an image. For that, getResultingSize(is.galia.image.Size, is.galia.image.ReductionFactor, is.galia.image.ScaleConstraint)
and
getResultingScales(is.galia.image.Size, is.galia.image.ScaleConstraint)
should be used instead.-
Nested Class Summary
Nested classes/interfaces inherited from class is.galia.operation.Scale
Scale.Filter
-
Constructor Summary
ConstructorsConstructorDescriptionNo-op constructor for a 100% instance.ScaleByPercent
(double percent) Percent-based constructor. -
Method Summary
Modifier and TypeMethodDescriptionboolean
double
getReductionFactor
(Size reducedSize, ScaleConstraint scaleConstraint, int maxFactor) double[]
getResultingScales
(Size fullSize, ScaleConstraint scaleConstraint) getResultingSize
(Size imageSize, ReductionFactor reductionFactor, ScaleConstraint scaleConstraint) boolean
Simpler but less-accurate counterpart ofOperation.hasEffect(Size, OperationList)
.boolean
hasEffect
(Size fullSize, OperationList opList) Context-aware counterpart toOperation.hasEffect()
.int
hashCode()
void
setPercent
(double percent) toString()
Returns a string representation of the instance, guaranteed to uniquely represent the instance.Methods inherited from class is.galia.operation.Scale
freeze, getFilter, getResultingSize, isHeightUp, isLinear, isUp, isWidthUp, setFilter, setLinear, toMap
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface is.galia.operation.Operation
freeze, getResultingSize, toMap, validate
-
Constructor Details
-
ScaleByPercent
public ScaleByPercent()No-op constructor for a 100% instance. -
ScaleByPercent
public ScaleByPercent(double percent) Percent-based constructor.- Parameters:
percent
- Value between 0 and 1 to represent a downscale, or above 1 to represent an upscale.
-
-
Method Details
-
equals
-
getPercent
public double getPercent()- Returns:
- Double from 0 to 1. May be null.
-
getReductionFactor
public ReductionFactor getReductionFactor(Size reducedSize, ScaleConstraint scaleConstraint, int maxFactor) - Specified by:
getReductionFactor
in classScale
- 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
- Specified by:
getResultingScales
in classScale
- 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
public Size getResultingSize(Size imageSize, ReductionFactor reductionFactor, ScaleConstraint scaleConstraint) - Specified by:
getResultingSize
in classScale
- 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.
-
hasEffect
public boolean hasEffect()Description copied from interface:Operation
Simpler but less-accurate counterpart ofOperation.hasEffect(Size, OperationList)
. -
hasEffect
Description copied from interface:Operation
Context-aware counterpart toOperation.hasEffect()
. For example, a scale operation specifying a scale to 300×200, when the given operation list contains a crop of 300×200, would returnfalse
.- Specified by:
hasEffect
in interfaceOperation
- Parameters:
fullSize
- Full size of the source image.opList
- Operation list of which the operation may or may not be a member.- Returns:
- Whether applying the operation in the context of the given full size and operation list would result in a changed image.
-
hashCode
-
setPercent
public void setPercent(double percent) - Parameters:
percent
- Double > 0 and ≤ 1.- Throws:
IllegalArgumentException
- If the given percent is invalid.IllegalStateException
- If the instance is frozen.
-
toString
-