Class TurnAndFlipFilter

  • All Implemented Interfaces:
    java.awt.image.BufferedImageOp

    public final class TurnAndFlipFilter
    extends AbstractImageFilter
    This filter performs 90 degree rotations and horizontal or vertical flips on an image.

    In-place filtering: This class does not support in-place filtering (the source and destination images must be different).

    Author:
    Chris Jennings
    • Field Detail

      • TURN_0

        public static final int TURN_0
        Neither turned nor flipped: this value simply copies the source image.
        See Also:
        Constant Field Values
      • TURN_90_LEFT

        public static final int TURN_90_LEFT
        Rotate 90 degrees anticlockwise.
        See Also:
        Constant Field Values
      • TURN_90_RIGHT

        public static final int TURN_90_RIGHT
        Rotate 90 degrees clockwise.
        See Also:
        Constant Field Values
      • TURN_0_FLIP_HORZ

        public static final int TURN_0_FLIP_HORZ
        Flip horizontally without turning.
        See Also:
        Constant Field Values
      • TURN_90_LEFT_FLIP_HORZ

        public static final int TURN_90_LEFT_FLIP_HORZ
        Rotate 90 degrees anticlockwise and flip horizontally.
        See Also:
        Constant Field Values
      • TURN_180_FLIP_HORZ

        public static final int TURN_180_FLIP_HORZ
        Rotate 180 degrees and flip horizontally. .
        See Also:
        Constant Field Values
      • TURN_90_RIGHT_FLIP_HORZ

        public static final int TURN_90_RIGHT_FLIP_HORZ
        Rotate 90 degrees clockwise and flip horizontally.
        See Also:
        Constant Field Values
      • TURN_0_FLIP_VERT

        public static final int TURN_0_FLIP_VERT
        Flip vertically without turning (same as TURN_180_FLIP).
        See Also:
        Constant Field Values
      • TURN_90_LEFT_FLIP_VERT

        public static final int TURN_90_LEFT_FLIP_VERT
        Rotate 90 degrees anticlockwise and flip vertically (same as TURN_90_RIGHT_FLIP_HORZ).
        See Also:
        Constant Field Values
      • TURN_180_FLIP_VERT

        public static final int TURN_180_FLIP_VERT
        Rotate 180 degrees and flip vertically (same as TURN_0_FLIP).
        See Also:
        Constant Field Values
      • TURN_90_RIGHT_FLIP_VERT

        public static final int TURN_90_RIGHT_FLIP_VERT
        Rotate 90 degrees clockwise and flip vertically (same as TURN_90_LEFT_FLIP_HORZ).
        See Also:
        Constant Field Values
      • TURN_0_FLIP_BOTH

        public static final int TURN_0_FLIP_BOTH
        Flip both axes without turning (same as TURN_180).
        See Also:
        Constant Field Values
      • TURN_90_LEFT_FLIP_BOTH

        public static final int TURN_90_LEFT_FLIP_BOTH
        Rotate 90 degrees anticlockwise and flip both axes (same as TURN_90_RIGHT).
        See Also:
        Constant Field Values
      • TURN_180_FLIP_BOTH

        public static final int TURN_180_FLIP_BOTH
        Rotate 180 degrees and flip both axes (same as TURN_0).
        See Also:
        Constant Field Values
      • TURN_90_RIGHT_FLIP_BOTH

        public static final int TURN_90_RIGHT_FLIP_BOTH
        Rotate 90 degrees clockwise and flip both axes (same as TURN_90_LEFT).
        See Also:
        Constant Field Values
    • Constructor Detail

      • TurnAndFlipFilter

        public TurnAndFlipFilter()
        Creates a new filter that is initially set to the TURN_0_FLIP_HORZ orientation.
      • TurnAndFlipFilter

        public TurnAndFlipFilter​(int orientation)
        Creates a new filter that is initially set to the specified orientation.
        Parameters:
        orientation - the initial orientation
    • Method Detail

      • getOrientation

        public int getOrientation()
        Returns the current orientation setting that describes how output images should be turned and flipped relative to input images.
        Returns:
        the TURN_* orientation value
      • setOrientation

        public void setOrientation​(int orientation)
        Sets the orientation of output images relative to source images.
        Parameters:
        orientation - the TURN_* value that encodes how the image should be rotated and flipped
      • createCompatibleDestImage

        public java.awt.image.BufferedImage createCompatibleDestImage​(java.awt.image.BufferedImage source,
                                                                      java.awt.image.ColorModel destinationColorModel)
        Description copied from class: AbstractImageFilter
        Specified by:
        createCompatibleDestImage in interface java.awt.image.BufferedImageOp
        Overrides:
        createCompatibleDestImage in class AbstractImageFilter
      • getBounds2D

        public java.awt.geom.Rectangle2D getBounds2D​(java.awt.image.BufferedImage source)
        Description copied from class: AbstractImageFilter

        The base implementation returns the bounds of the image in image space; that is, the rectangle defined by 0, 0, source.getWidth(), source.getHeight().

        Specified by:
        getBounds2D in interface java.awt.image.BufferedImageOp
        Overrides:
        getBounds2D in class AbstractImageFilter
      • filter

        public java.awt.image.BufferedImage filter​(java.awt.image.BufferedImage src,
                                                   java.awt.image.BufferedImage dest)