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 TypeMethodDescriptionbooleandoublegetReductionFactor(Size reducedSize, ScaleConstraint scaleConstraint, int maxFactor) double[]getResultingScales(Size fullSize, ScaleConstraint scaleConstraint) getResultingSize(Size imageSize, ReductionFactor reductionFactor, ScaleConstraint scaleConstraint) booleanSimpler but less-accurate counterpart ofOperation.hasEffect(Size, OperationList).booleanhasEffect(Size fullSize, OperationList opList) Context-aware counterpart toOperation.hasEffect().inthashCode()voidsetPercent(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, toMapMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:
getReductionFactorin 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:
getResultingScalesin 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:
getResultingSizein classScale- 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.
-
hasEffect
public boolean hasEffect()Description copied from interface:OperationSimpler but less-accurate counterpart ofOperation.hasEffect(Size, OperationList). -
hasEffect
Description copied from interface:OperationContext-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:
hasEffectin 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
-