Class AbstractCropAlgorithm
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.image.transformer.crop.AbstractCropAlgorithm
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,CropAlgorithm<BufferedImage>,Serializable
- Direct Known Subclasses:
BinaryCrop,CropBackground,NoCrop,RectangleCrop,RelativeCrop,SimpleCrop,ThresholdedCrop
public abstract class AbstractCropAlgorithm extends AbstractOptionHandler implements CropAlgorithm<BufferedImage>
Ancestor to cropping algorithms.- Version:
- $Revision: 6675 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Pointm_BottomRightthe bottom-right corner.protected Pointm_TopLeftthe top-left corner.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from interface adams.data.image.CropAlgorithm
CROP_BOTTOM, CROP_LEFT, CROP_RIGHT, CROP_TOP
-
-
Constructor Summary
Constructors Constructor Description AbstractCropAlgorithm()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected voidcheck(BufferedImage img)Checks whether the image can be cropped.BufferedImagecrop(BufferedImage img)Crops the image.protected abstract BufferedImagedoCrop(BufferedImage img)Performs the actual crop.PointgetBottomRight()Returns the bottom-right coordinates of the cropped image in the original image.PointgetTopLeft()Returns the top-left coordinates of the cropped image in the original image.protected voidpostCrop(BufferedImage img)Hook method after the crop happened.protected voidpreCrop(BufferedImage img)Hook method before the crop happens.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, defineOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
-
-
-
Method Detail
-
check
protected void check(BufferedImage img)
Checks whether the image can be cropped.
Default implementation only checks whether an image was supplied.- Parameters:
img- the image to check- Throws:
IllegalStateException- if image fails check
-
preCrop
protected void preCrop(BufferedImage img)
Hook method before the crop happens.
Default method initializes the top-left and bottom-right corners to image dimensions.- Parameters:
img- the image to crop
-
doCrop
protected abstract BufferedImage doCrop(BufferedImage img)
Performs the actual crop.- Parameters:
img- the image to crop- Returns:
- the (potentially) cropped image
-
postCrop
protected void postCrop(BufferedImage img)
Hook method after the crop happened.
Default method does nothing.- Parameters:
img- the cropped
-
crop
public BufferedImage crop(BufferedImage img)
Crops the image.- Specified by:
cropin interfaceCropAlgorithm<BufferedImage>- Parameters:
img- the image to crop- Returns:
- the (potentially) cropped image
-
getTopLeft
public Point getTopLeft()
Returns the top-left coordinates of the cropped image in the original image.- Specified by:
getTopLeftin interfaceCropAlgorithm<BufferedImage>- Returns:
- the top-left corner
-
getBottomRight
public Point getBottomRight()
Returns the bottom-right coordinates of the cropped image in the original image.- Specified by:
getBottomRightin interfaceCropAlgorithm<BufferedImage>- Returns:
- the bottom-right corner
-
-