Class Redaction

java.lang.Object
is.galia.operation.redaction.Redaction
All Implemented Interfaces:
Operation

public class Redaction extends Object implements Operation

Encapsulates a rectangle overlaid onto an image.

Instances should be obtained from the RedactionService.

  • Constructor Details

    • Redaction

      public Redaction()
      No-op constructor.
    • Redaction

      public Redaction(Region region, Color color)
  • Method Details

    • equals

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

      public void freeze()
      Description copied from interface: Operation
      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.)
      Specified by:
      freeze in interface Operation
    • getColor

      public Color getColor()
      Returns:
      Color with alpha.
    • getRegion

      public Region getRegion()
      Returns:
      Redacted region in source image pixel coordinates.
    • getResultingRegion

      public Region getResultingRegion(Size fullSize, ScaleConstraint scaleConstraint, Crop appliedCrop)
      Parameters:
      fullSize - Size of the source image.
      scaleConstraint - Scale constraint.
      appliedCrop - Crop that has been applied to the source image.
      Returns:
      Region of the cropped image to be redacted, or an empty rectangle if none.
    • hasEffect

      public boolean hasEffect()
      Description copied from interface: Operation
      Simpler but less-accurate counterpart of Operation.hasEffect(Size, OperationList).
      Specified by:
      hasEffect in interface Operation
      Returns:
      Whether applying the operation on its own would result in a changed image.
    • hasEffect

      public boolean hasEffect(Size fullSize, OperationList opList)
      Description copied from interface: Operation
      Context-aware counterpart to Operation.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.
      Specified by:
      hasEffect in interface Operation
      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.
    • hashCode

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

      public void setColor(Color color)
    • setRegion

      public void setRegion(Region region)
      Parameters:
      region - Redacted region in source image pixel coordinates.
      Throws:
      IllegalStateException - If the instance is frozen.
    • toMap

      public Map<String,Object> toMap(Size fullSize, ScaleConstraint scaleConstraint)
      Specified by:
      toMap in interface Operation
      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:
      Map with x, y, width, and height keys.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      String representation of the instance, in the format [x],[y]/[width]x[height].