Interface Operation

All Known Implementing Classes:
ColorTransform, Crop, CropByPercent, CropByPixels, CropToSquare, Encode, ImageOverlay, Overlay, Redaction, Rotate, Scale, Scale.Filter, ScaleByPercent, ScaleByPixels, Sharpen, StringOverlay, Transpose

public interface Operation
Interface to be implemented by all image-processing operations. Clients should check instances' type and recast.
  • Method Details

    • freeze

      void freeze()
      Makes the instance unmodifiable. When frozen, mutation methods should throw an IllegalStateException and getters should return immutable values, if possible. (But they should do that anyway.)
    • getResultingSize

      default Size getResultingSize(Size fullSize, ScaleConstraint scaleConstraint)
      This default implementation returns the fullSize argument. It will need to be overridden by operations that could change the image's resulting size.
      Parameters:
      fullSize - Full size of the source image on which the operation is being applied.
      scaleConstraint - Scale constraint applied to the given full size.
      Returns:
      Resulting dimensions when the operation is applied.
    • hasEffect

      boolean hasEffect()
      Simpler but less-accurate counterpart of hasEffect(Size, OperationList).
      Returns:
      Whether applying the operation on its own would result in a changed image.
    • hasEffect

      boolean hasEffect(Size fullSize, OperationList opList)
      Context-aware counterpart to 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.
      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.
    • toMap

      Map<String,Object> toMap(Size fullSize, ScaleConstraint scaleConstraint)
      Parameters:
      fullSize - Full size of the source image on which the operation is being applied.
      scaleConstraint - Scale constraint applied to the given full size.
      Returns:
      Unmodifiable representation of the operation for human consumption. The map includes a class key pointing to the operation's class name.
    • validate

      default void validate(Size fullSize, ScaleConstraint scaleConstraint) throws OperationException

      Validates the instance, throwing an exception if invalid.

      Implementations can also throw exceptions from property setters as an alternative to using this method.

      This default implementation does nothing.

      Parameters:
      fullSize - Full size of the source image on which the operation is being applied.
      scaleConstraint - Scale constraint applied to the given full size.
      Throws:
      OperationException - if the instance is invalid.