Class RelativeCrop
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.image.transformer.crop.AbstractCropAlgorithm
-
- adams.data.image.transformer.crop.RelativeCrop
-
- All Implemented Interfaces:
Destroyable,GlobalInfoSupporter,LoggingLevelHandler,LoggingSupporter,OptionHandler,SizeOfHandler,CropAlgorithm<BufferedImage>,Serializable
public class RelativeCrop extends AbstractCropAlgorithm
Crops the image to specified width and height. Where the crop rectangle starts is defined by the X and Y position and the anchor.
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-x <double> (property: X) The horizontal pixel position (0-1: percent; >1: pixels). default: 0.0 minimum: 0.0
-y <double> (property: Y) The vertical pixel position (0-1: percent; >1: pixels). default: 0.0 minimum: 0.0
-width <double> (property: width) The width of the crop rectangle (0-1: percent; >1: pixels). default: 1.0 minimum: 1.0E-5
-height <double> (property: height) The height of the crop rectangle (0-1: percent; >1: pixels). default: 1.0 minimum: 1.0E-5
-anchor <TOP_LEFT|TOP_CENTER|TOP_RIGHT|MIDDLE_LEFT|MIDDLE_CENTER|MIDDLE_RIGHT|BOTTOM_LEFT|BOTTOM_CENTER|BOTTOM_RIGHT> (property: anchor) Defines where to anchor the position on the crop rectangle. default: TOP_LEFT
-use-anchor-at-pos <boolean> (property: useAnchorAtPos) If enabled, the anchor gets placed at the x/y positiion and the corners of the crop are calculated accordingly; eg 'MIDDLE_CENTER' then refers to the center of the crop rectangle, with the center located at x/y. default: false
- Version:
- $Revision: 8950 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ImageAnchorm_Anchorwhere to anchor the position on the rectangle.protected doublem_Heightthe height of the crop rectangle.protected booleanm_UseAnchorAtPoswhether to use the anchor at the specified to position rather than using image.protected doublem_Widththe width of the crop rectangle.protected doublem_Xthe X position of the crop rectangle.protected doublem_Ythe Y position of the crop rectangle.-
Fields inherited from class adams.data.image.transformer.crop.AbstractCropAlgorithm
m_BottomRight, m_TopLeft
-
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 RelativeCrop()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringanchorTipText()Returns the tip text for this property.voiddefineOptions()Adds options to the internal list of options.protected BufferedImagedoCrop(BufferedImage img)Performs the actual cropping.ImageAnchorgetAnchor()Returns where to anchor the position on the rectangle.doublegetHeight()Returns the height of the crop rectangle (0-1: percent; >1: pixels).booleangetUseAnchorAtPos()Returns whether to place the anchor at the position or use it relative to image.doublegetWidth()Returns the width of the crop rectangle (0-1: percent; >1: pixels).doublegetX()Returns the X position (0-1: percent; >1: pixels).doublegetY()Returns the Y position (0-1: percent; >1: pixels).StringglobalInfo()Returns a string describing the object.StringheightTipText()Returns the tip text for this property.voidsetAnchor(ImageAnchor value)Sets where to anchor the position on the rectangle.voidsetHeight(double value)Sets the height of the crop rectangle (0-1: percent; >1: pixels).voidsetUseAnchorAtPos(boolean value)Sets whether to place the anchor at the position or use it relative to image.voidsetWidth(double value)Sets the width of the crop rectangle (0-1: percent; >1: pixels).voidsetX(double value)Sets the X position (0-1: percent; >1: pixels).voidsetY(double value)Sets the Y position (0-1: percent; >1: pixels).StringuseAnchorAtPosTipText()Returns the tip text for this property.StringwidthTipText()Returns the tip text for this property.StringXTipText()Returns the tip text for this property.StringYTipText()Returns the tip text for this property.-
Methods inherited from class adams.data.image.transformer.crop.AbstractCropAlgorithm
check, crop, getBottomRight, getTopLeft, postCrop, preCrop
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, 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
-
-
-
-
Field Detail
-
m_X
protected double m_X
the X position of the crop rectangle.
-
m_Y
protected double m_Y
the Y position of the crop rectangle.
-
m_Width
protected double m_Width
the width of the crop rectangle.
-
m_Height
protected double m_Height
the height of the crop rectangle.
-
m_Anchor
protected ImageAnchor m_Anchor
where to anchor the position on the rectangle.
-
m_UseAnchorAtPos
protected boolean m_UseAnchorAtPos
whether to use the anchor at the specified to position rather than using image.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceGlobalInfoSupporter- Specified by:
globalInfoin classAbstractOptionHandler- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptionsin interfaceOptionHandler- Overrides:
defineOptionsin classAbstractOptionHandler
-
setX
public void setX(double value)
Sets the X position (0-1: percent; >1: pixels).- Parameters:
value- the position
-
getX
public double getX()
Returns the X position (0-1: percent; >1: pixels).- Returns:
- the position
-
XTipText
public String XTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setY
public void setY(double value)
Sets the Y position (0-1: percent; >1: pixels).- Parameters:
value- the position
-
getY
public double getY()
Returns the Y position (0-1: percent; >1: pixels).- Returns:
- the position
-
YTipText
public String YTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setWidth
public void setWidth(double value)
Sets the width of the crop rectangle (0-1: percent; >1: pixels).- Parameters:
value- the width
-
getWidth
public double getWidth()
Returns the width of the crop rectangle (0-1: percent; >1: pixels).- Returns:
- the width
-
widthTipText
public String widthTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setHeight
public void setHeight(double value)
Sets the height of the crop rectangle (0-1: percent; >1: pixels).- Parameters:
value- the height
-
getHeight
public double getHeight()
Returns the height of the crop rectangle (0-1: percent; >1: pixels).- Returns:
- the height
-
heightTipText
public String heightTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setAnchor
public void setAnchor(ImageAnchor value)
Sets where to anchor the position on the rectangle.- Parameters:
value- the anchor
-
getAnchor
public ImageAnchor getAnchor()
Returns where to anchor the position on the rectangle.- Returns:
- the anchor
-
anchorTipText
public String anchorTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
setUseAnchorAtPos
public void setUseAnchorAtPos(boolean value)
Sets whether to place the anchor at the position or use it relative to image.- Parameters:
value- true if anchor at pos
-
getUseAnchorAtPos
public boolean getUseAnchorAtPos()
Returns whether to place the anchor at the position or use it relative to image.- Returns:
- true if anchor at pos
-
useAnchorAtPosTipText
public String useAnchorAtPosTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
doCrop
protected BufferedImage doCrop(BufferedImage img)
Performs the actual cropping.- Specified by:
doCropin classAbstractCropAlgorithm- Parameters:
img- the image to crop- Returns:
- the (potentially) cropped image
-
-