Class ScaleByPercent

java.lang.Object
is.galia.operation.Scale
is.galia.operation.ScaleByPercent
All Implemented Interfaces:
Operation

public class ScaleByPercent extends Scale implements Operation
  • 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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • 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 class Scale
      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

      public double[] getResultingScales(Size fullSize, ScaleConstraint scaleConstraint)
      Specified by:
      getResultingScales in class Scale
      Parameters:
      fullSize - Full source image dimensions.
      scaleConstraint - Scale constraint relative to the full source image dimensions. The instance is expressed relative to the constrained fullSize.
      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 class Scale
      Parameters:
      imageSize - Image whose dimensions have been halved ReductionFactor.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 of Operation.hasEffect(Size, OperationList).
      Specified by:
      hasEffect in interface Operation
      Returns:
      Whether applying the operation on its own would result in a changed image.
    • hasEffect

      public boolean hasEffect(Size fullSize, OperationList opList)
      Description copied from interface: Operation
      Context-aware counterpart to Operation.hasEffect(). For example, a scale operation specifying a scale to 300×200, when the given operation list contains a crop of 300×200, would return false.
      Specified by:
      hasEffect in interface Operation
      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

      public int hashCode()
      Overrides:
      hashCode in class Object
    • 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

      public String toString()

      Returns a string representation of the instance, guaranteed to uniquely represent the instance. The format is:

      No-op
      none
      Percent
      nnn%(,filter)
      Overrides:
      toString in class Object
      Returns:
      String representation of the instance.