Class ReductionFactor

java.lang.Object
is.galia.image.ReductionFactor

public final class ReductionFactor extends Object

Represents a scale-reduction multiple with a corresponding scale of (1/2)^rf. For example, a factor of 0 represents full scale; 1 represents 50% reduction; 2 represents 75% reduction; etc.

This class is mutable, as one of its uses is to be passed to a Decoder, which may change it.

  • Field Details

    • DEFAULT_TOLERANCE

      public static final double DEFAULT_TOLERANCE
      Set to a value that will allow one pixel of leeway in an image up to 99999x99999.
      See Also:
    • factor

      public int factor
  • Constructor Details

    • ReductionFactor

      public ReductionFactor()
      No-op constructor.
    • ReductionFactor

      public ReductionFactor(int factor)
  • Method Details

    • forScale

      public static ReductionFactor forScale(double scalePercent)
      Factory method. Uses DEFAULT_TOLERANCE.
      Parameters:
      scalePercent - Scale percentage.
      Returns:
      Instance corresponding to the given scale.
    • forScale

      public static ReductionFactor forScale(double scalePercent, double tolerance)
      Factory method.
      Parameters:
      scalePercent - Scale percentage.
      tolerance - Leeway that could allow a larger factor to be selected.
      Returns:
      Instance corresponding to the given scale. If the given scale is greater than 1, the factor will be 0.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • findDifferentialScale

      public double findDifferentialScale(double scale)
      Parameters:
      scale - Amount to scale an image (or one of its axes).
      Returns:
      Amount that the image will need to be scaled relative to the instance's factor.
    • getScale

      public double getScale()
      Returns:
      Scale corresponding to the instance.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object