Class ToDimensions

Object
AnchorBean<ScaleCalculator>
InitializableBean<ScaleCalculator, ImageInitialization>
ImageBean<ScaleCalculator>
ScaleCalculator
ToDimensions

public class ToDimensions extends ScaleCalculator
Calculates a scaling-factor to make the source image have identical dimensions as dimensionsTarget.

If preserveAspectRatio is true, then the aspect ratio is preserved, and both dimensions may not be identical to dimensionsTarget, but at least one will be, and the other will not be exceed that of dimensionsTarget.

Author:
Owen Feehan
  • Constructor Details

    • ToDimensions

      public ToDimensions(int sizeX, int sizeY)
      Create with specific lengths for X and Y dimensions.
      Parameters:
      sizeX - the size of the X-dimension.
      sizeY - the size of the X-dimension.
    • ToDimensions

      public ToDimensions(DimensionsProvider dimensions)
      Create with specific dimensions.
      Parameters:
      dimensions - the dimensions the source image/entity is desired to be scaled to.
    • ToDimensions

      public ToDimensions(int sizeX, int sizeY, boolean preserveAspectRatio)
      Create with specific lengths for X and Y dimensions and preserveAspectRatio.
      Parameters:
      sizeX - the size of the X-dimension.
      sizeY - the size of the X-dimension.
      preserveAspectRatio - if true, the ratio between x and y is kept constant when scaling.
    • ToDimensions

      public ToDimensions(DimensionsProvider dimensions, boolean preserveAspectRatio)
      Create with specific dimensions and preserveAspectRatio.
      Parameters:
      dimensions - the dimensions the source image/entity is desired to be scaled to.
      preserveAspectRatio - if true, the ratio between x and y is kept constant when scaling.
    • ToDimensions

      public ToDimensions()
  • Method Details

    • calculate

      public ScaleFactor calculate(Optional<Dimensions> dimensionsToBeScaled, Optional<ImageSizeSuggestion> suggestedSize) throws OperationFailedException
      Specified by:
      calculate in class ScaleCalculator
      Throws:
      OperationFailedException
    • getDimensions

      public DimensionsProvider getDimensions()
      The dimensions the source image/entity is desired to be scaled to.
    • setDimensions

      public void setDimensions(DimensionsProvider dimensions)
      The dimensions the source image/entity is desired to be scaled to.
    • getDimensionsSourceFallback

      public DimensionsProvider getDimensionsSourceFallback()
    • setDimensionsSourceFallback

      public void setDimensionsSourceFallback(DimensionsProvider dimensionsSourceFallback)
    • isPreserveAspectRatio

      public boolean isPreserveAspectRatio()
      If true, the ratio between x and y is kept constant when scaling.

      The larger dimension is will be scaled to be the same as dimensionsTarget and the the smaller dimension is guaranteed to be equal to or lesser than its equivalent in dimensionsTarget.

    • setPreserveAspectRatio

      public void setPreserveAspectRatio(boolean preserveAspectRatio)
      If true, the ratio between x and y is kept constant when scaling.

      The larger dimension is will be scaled to be the same as dimensionsTarget and the the smaller dimension is guaranteed to be equal to or lesser than its equivalent in dimensionsTarget.