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 intTURN_0Neither turned nor flipped: this value simply copies the source image.static intTURN_0_FLIP_BOTHFlip both axes without turning (same asTURN_180).static intTURN_0_FLIP_HORZFlip horizontally without turning.static intTURN_0_FLIP_VERTFlip vertically without turning (same asTURN_180_FLIP).static intTURN_180Rotate 180 degrees.static intTURN_180_FLIP_BOTHRotate 180 degrees and flip both axes (same asTURN_0).static intTURN_180_FLIP_HORZRotate 180 degrees and flip horizontally.static intTURN_180_FLIP_VERTRotate 180 degrees and flip vertically (same asTURN_0_FLIP).static intTURN_90_LEFTRotate 90 degrees anticlockwise.static intTURN_90_LEFT_FLIP_BOTHRotate 90 degrees anticlockwise and flip both axes (same asTURN_90_RIGHT).static intTURN_90_LEFT_FLIP_HORZRotate 90 degrees anticlockwise and flip horizontally.static intTURN_90_LEFT_FLIP_VERTRotate 90 degrees anticlockwise and flip vertically (same asTURN_90_RIGHT_FLIP_HORZ).static intTURN_90_RIGHTRotate 90 degrees clockwise.static intTURN_90_RIGHT_FLIP_BOTHRotate 90 degrees clockwise and flip both axes (same asTURN_90_LEFT).static intTURN_90_RIGHT_FLIP_HORZRotate 90 degrees clockwise and flip horizontally.static intTURN_90_RIGHT_FLIP_VERTRotate 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_HORZorientation.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.BufferedImagecreateCompatibleDestImage(java.awt.image.BufferedImage source, java.awt.image.ColorModel destinationColorModel)java.awt.image.BufferedImagefilter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)java.awt.geom.Rectangle2DgetBounds2D(java.awt.image.BufferedImage source)intgetOrientation()Returns the current orientation setting that describes how output images should be turned and flipped relative to input images.voidsetOrientation(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_HORZorientation.
-
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:
createCompatibleDestImagein interfacejava.awt.image.BufferedImageOp- Overrides:
createCompatibleDestImagein classAbstractImageFilter
-
getBounds2D
public java.awt.geom.Rectangle2D getBounds2D(java.awt.image.BufferedImage source)
Description copied from class:AbstractImageFilterThe 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:
getBounds2Din interfacejava.awt.image.BufferedImageOp- Overrides:
getBounds2Din classAbstractImageFilter
-
filter
public java.awt.image.BufferedImage filter(java.awt.image.BufferedImage src, java.awt.image.BufferedImage dest)
-
-