Class FitTo

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

public class FitTo extends ScaleCalculator
Scales an image to approximately similar in size to a SizeXY.

Optionally, the aspect-ratio is preserved between width and height.

Optionally, the eventual width, and height can be rounded to the nearest whole multiple of an integer.

Author:
Owen Feehan
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    ScaleFactor
    calculate(Optional<Dimensions> dimensionsToBeScaled, Optional<ImageSizeSuggestion> suggestedSize)
     
    int
    The eventual width and height of the image must be a multiple of this number.
    SizeXY
    The target size.
    boolean
    If true, the aspect-ratio is preserved between width and height.
    void
    setMultipleOf(int multipleOf)
    The eventual width and height of the image must be a multiple of this number.
    void
    setPreserveAspectRatio(boolean preserveAspectRatio)
    If true, the aspect-ratio is preserved between width and height.
    void
    setTargetSize(SizeXY targetSize)
    The target size.

    Methods inherited from class org.anchoranalysis.bean.initializable.InitializableBean

    getInitialization, getLogger, getPropertyInitializer, initialize, initializeRecursive, initRecursiveWithInitializer, isInitialized, onInitialization

    Methods inherited from class org.anchoranalysis.bean.AnchorBean

    checkMisconfigured, describeBean, describeChildren, duplicateBean, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • FitTo

      public FitTo()
  • Method Details

    • calculate

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

      public SizeXY getTargetSize()
      The target size. The image will be scaled to be as similar to this as possible, preserving aspect ratio.
    • setTargetSize

      public void setTargetSize(SizeXY targetSize)
      The target size. The image will be scaled to be as similar to this as possible, preserving aspect ratio.
    • isPreserveAspectRatio

      public boolean isPreserveAspectRatio()
      If true, the aspect-ratio is preserved between width and height. Otherwise, they are treated independently.
    • setPreserveAspectRatio

      public void setPreserveAspectRatio(boolean preserveAspectRatio)
      If true, the aspect-ratio is preserved between width and height. Otherwise, they are treated independently.
    • getMultipleOf

      public int getMultipleOf()
      The eventual width and height of the image must be a multiple of this number. Effecitvely disabled when == 1
    • setMultipleOf

      public void setMultipleOf(int multipleOf)
      The eventual width and height of the image must be a multiple of this number. Effecitvely disabled when == 1