Class ConstantScaleFactor


public class ConstantScaleFactor extends ScaleCalculator
Scale X and Y dimension by a constant floating-point number.

e.g. Applying 0.5 to an image of size (width=50, height=10) would produce a scaled image with (width=25, height=5).

The constant floating-point number is equal across both dimensions.

Author:
Owen Feehan
  • Constructor Details

    • ConstantScaleFactor

      public ConstantScaleFactor()
    • ConstantScaleFactor

      public ConstantScaleFactor(double value)
      Creates a new ConstantScaleFactor instance.
      Parameters:
      value - The constant floating-point value to scale each dimension by.
  • Method Details

    • calculate

      public ScaleFactor calculate(Optional<Dimensions> dimensionsToBeScaled, Optional<ImageSizeSuggestion> suggestedSize) throws OperationFailedException
      Description copied from class: ScaleCalculator
      Calculates a scaling-factor for a source image/entity of particular dimensions.
      Specified by:
      calculate in class ScaleCalculator
      Parameters:
      dimensionsToBeScaled - dimensions of the source image/entity that will be scaled, if they are known.
      suggestedSize - a string suggesting dimensions to resize to or a scaling-factor.
      Returns:
      the scaling-factor to use.
      Throws:
      OperationFailedException - if a scale-factor cannot be successfully calculated.
    • getValue

      public double getValue()
      The constant floating-point value to scale each dimension by.
    • setValue

      public void setValue(double value)
      The constant floating-point value to scale each dimension by.