Class Rotate

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

public class Rotate extends Object implements Operation
Encapsulates a rotation operation.
  • Constructor Details

    • Rotate

      public Rotate()
      No-op constructor.
    • Rotate

      public Rotate(double degrees)
      Parameters:
      degrees - Degrees of rotation between 0 and 360.
  • 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
    • getDegrees

      public double getDegrees()
      Returns:
      Degrees.
    • getResultingSize

      public Size getResultingSize(Size fullSize, ScaleConstraint scaleConstraint)
      Description copied from interface: Operation
      This default implementation returns the fullSize argument. It will need to be overridden by operations that could change the image's resulting size.
      Specified by:
      getResultingSize 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:
      Resulting dimensions when the scale is applied to the given full size.
    • 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
    • setDegrees

      public void setDegrees(double degrees)
      Parameters:
      degrees - Degrees of rotation between 0 and 360
      Throws:
      IllegalArgumentException - If the given degrees are invalid.
      IllegalStateException - if the instance is frozen.
    • toMap

      public Map<String,Object> toMap(Size fullSize, ScaleConstraint scaleConstraint)

      Returns a map in the following format:

      {
           class: "Rotate",
           degrees: double
       }
      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:
      See above.
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      String representation of the instance, guaranteed to uniquely represent it.