Package ca.cgjennings.graphics.filters
Class TurnAndFlipFilter
- java.lang.Object
-
- ca.cgjennings.graphics.filters.AbstractImageFilter
-
- ca.cgjennings.graphics.filters.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 Summary
Fields Modifier and Type Field Description static int
TURN_0
Neither turned nor flipped: this value simply copies the source image.static int
TURN_0_FLIP_BOTH
Flip both axes without turning (same asTURN_180
).static int
TURN_0_FLIP_HORZ
Flip horizontally without turning.static int
TURN_0_FLIP_VERT
Flip vertically without turning (same asTURN_180_FLIP
).static int
TURN_180
Rotate 180 degrees.static int
TURN_180_FLIP_BOTH
Rotate 180 degrees and flip both axes (same asTURN_0
).static int
TURN_180_FLIP_HORZ
Rotate 180 degrees and flip horizontally.static int
TURN_180_FLIP_VERT
Rotate 180 degrees and flip vertically (same asTURN_0_FLIP
).static int
TURN_90_LEFT
Rotate 90 degrees anticlockwise.static int
TURN_90_LEFT_FLIP_BOTH
Rotate 90 degrees anticlockwise and flip both axes (same asTURN_90_RIGHT
).static int
TURN_90_LEFT_FLIP_HORZ
Rotate 90 degrees anticlockwise and flip horizontally.static int
TURN_90_LEFT_FLIP_VERT
Rotate 90 degrees anticlockwise and flip vertically (same asTURN_90_RIGHT_FLIP_HORZ
).static int
TURN_90_RIGHT
Rotate 90 degrees clockwise.static int
TURN_90_RIGHT_FLIP_BOTH
Rotate 90 degrees clockwise and flip both axes (same asTURN_90_LEFT
).static int
TURN_90_RIGHT_FLIP_HORZ
Rotate 90 degrees clockwise and flip horizontally.static int
TURN_90_RIGHT_FLIP_VERT
Rotate 90 degrees clockwise and flip vertically (same asTURN_90_LEFT_FLIP_HORZ
).
-
Constructor Summary
Constructors Constructor Description TurnAndFlipFilter()
Creates a new filter that is initially set to theTURN_0_FLIP_HORZ
orientation.TurnAndFlipFilter(int orientation)
Creates a new filter that is initially set to the specified orientation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.image.BufferedImage
createCompatibleDestImage(java.awt.image.BufferedImage source, java.awt.image.ColorModel destinationColorModel)
java.awt.image.BufferedImage
filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
java.awt.geom.Rectangle2D
getBounds2D(java.awt.image.BufferedImage source)
int
getOrientation()
Returns the current orientation setting that describes how output images should be turned and flipped relative to input images.void
setOrientation(int orientation)
Sets the orientation of output images relative to source images.-
Methods inherited from class ca.cgjennings.graphics.filters.AbstractImageFilter
clamp, clamp, clamp, clampBoth, fA, fB, fG, fR, getARGB, getARGB, getARGBSynch, getPoint2D, getRenderingHints, iA, iB, iG, iR, setARGB, setARGB, setARGBSynch
-
-
-
-
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_180
public static final int TURN_180
Rotate 180 degrees.- 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 asTURN_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 asTURN_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 asTURN_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 asTURN_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 asTURN_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 asTURN_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 asTURN_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 asTURN_90_LEFT
).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TurnAndFlipFilter
public TurnAndFlipFilter()
Creates a new filter that is initially set to theTURN_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
- theTURN_*
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 interfacejava.awt.image.BufferedImageOp
- Overrides:
createCompatibleDestImage
in classAbstractImageFilter
-
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 interfacejava.awt.image.BufferedImageOp
- Overrides:
getBounds2D
in classAbstractImageFilter
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
-
-