Class AbstractImageWatermark
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.gui.visualization.watermark.AbstractWatermark
-
- adams.gui.visualization.watermark.AbstractImageWatermark
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,SizeOfHandler
,Watermark
,Serializable
- Direct Known Subclasses:
ADAMS
,FromFile
,FromResource
public abstract class AbstractImageWatermark extends AbstractWatermark
Ancestor for image-based watermarks.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_Alpha
the alpha value to use for the overlay (0: transparent, 255: opaque).protected Image
m_Image
the image.protected boolean
m_Initialized
whether the image was initialized.protected Location
m_Location
the location.protected int
m_Padding
the padding to use.protected double
m_Scale
the scale to use (1 = 100%).protected int
m_X
the X position.protected int
m_Y
the Y position.-
Fields inherited from class adams.gui.visualization.watermark.AbstractWatermark
m_Enabled
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description AbstractImageWatermark()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
alphaTipText()
Returns the tip text for this property.protected boolean
canApplyWatermark(Graphics g, Dimension dimension)
Returns whether the watermark can be applied.void
defineOptions()
Adds options to the internal list of options.protected void
doApplyWatermark(Graphics g, Dimension dimension)
Applies the watermark in the specified graphics context.int
getAlpha()
Returns the alpha value to use for the overlay: 0=transparent, 255=opaque.protected int
getDefaultAlpha()
Returns the default alpha value: 0=transparent, 255=opaque.protected Location
getDefaultLocation()
Returns the default location.protected int
getDefaultPadding()
Returns the default padding around the image.protected double
getDefaultScale()
Returns the default scale factor to use.protected int
getDefaultX()
Returns the default X position (1-based).protected int
getDefaultY()
Returns the default Y position (1-based).Location
getLocation()
Returns the location of the image.int
getPadding()
Returns the padding around the image.double
getScale()
Returns the scale factor to apply.int
getX()
Returns the X position in pixels (1-based).int
getY()
Returns the Y position in pixels (1-based).protected void
initializeImage()
Loads the image if necessary.protected abstract Image
loadImage()
Loads the image.String
locationTipText()
Returns the tip text for this property.String
paddingTipText()
Returns the tip text for this property.protected void
reset()
Resets the scheme.String
scaleTipText()
Returns the tip text for this property.void
setAlpha(int value)
Sets the alpha value to use for the overlay: 0=transparent, 255=opaque.void
setLocation(Location value)
Sets the location of the image.void
setPadding(int value)
Sets the padding around the image.void
setScale(double value)
Sets the scale factor to apply.void
setX(int value)
Sets the X position in pixels (1-based).void
setY(int value)
Sets the Y position in pixels (1-based).String
XTipText()
Returns the tip text for this property.String
YTipText()
Returns the tip text for this property.-
Methods inherited from class adams.gui.visualization.watermark.AbstractWatermark
applyWatermark, enabledTipText, getEnabled, setEnabled
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, initialize, loggingLevelTipText, newOptionManager, 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_Location
protected Location m_Location
the location.
-
m_X
protected int m_X
the X position.
-
m_Y
protected int m_Y
the Y position.
-
m_Padding
protected int m_Padding
the padding to use.
-
m_Scale
protected double m_Scale
the scale to use (1 = 100%).
-
m_Alpha
protected int m_Alpha
the alpha value to use for the overlay (0: transparent, 255: opaque).
-
m_Initialized
protected transient boolean m_Initialized
whether the image was initialized.
-
m_Image
protected transient Image m_Image
the image.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractWatermark
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in classAbstractOptionHandler
-
getDefaultLocation
protected Location getDefaultLocation()
Returns the default location.- Returns:
- the default
-
setLocation
public void setLocation(Location value)
Sets the location of the image.- Parameters:
value
- the location
-
getLocation
public Location getLocation()
Returns the location of the image.- Returns:
- the location
-
locationTipText
public String locationTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultX
protected int getDefaultX()
Returns the default X position (1-based).- Returns:
- the default
-
setX
public void setX(int value)
Sets the X position in pixels (1-based).- Parameters:
value
- the position
-
getX
public int getX()
Returns the X position in pixels (1-based).- 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 or for listing the options.
-
getDefaultY
protected int getDefaultY()
Returns the default Y position (1-based).- Returns:
- the default
-
setY
public void setY(int value)
Sets the Y position in pixels (1-based).- Parameters:
value
- the position
-
getY
public int getY()
Returns the Y position in pixels (1-based).- 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 or for listing the options.
-
getDefaultPadding
protected int getDefaultPadding()
Returns the default padding around the image.- Returns:
- the default
-
setPadding
public void setPadding(int value)
Sets the padding around the image.- Parameters:
value
- the padding
-
getPadding
public int getPadding()
Returns the padding around the image.- Returns:
- the padding
-
paddingTipText
public String paddingTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultScale
protected double getDefaultScale()
Returns the default scale factor to use.- Returns:
- the default
-
setScale
public void setScale(double value)
Sets the scale factor to apply.- Parameters:
value
- the scale factor
-
getScale
public double getScale()
Returns the scale factor to apply.- Returns:
- the scale factor
-
scaleTipText
public String scaleTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getDefaultAlpha
protected int getDefaultAlpha()
Returns the default alpha value: 0=transparent, 255=opaque.- Returns:
- the default
-
setAlpha
public void setAlpha(int value)
Sets the alpha value to use for the overlay: 0=transparent, 255=opaque.- Parameters:
value
- the alpha value
-
getAlpha
public int getAlpha()
Returns the alpha value to use for the overlay: 0=transparent, 255=opaque.- Returns:
- the alpha value
-
alphaTipText
public String alphaTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the gui
-
loadImage
protected abstract Image loadImage()
Loads the image.- Returns:
- the image, null if failed to load
-
initializeImage
protected void initializeImage()
Loads the image if necessary.
-
canApplyWatermark
protected boolean canApplyWatermark(Graphics g, Dimension dimension)
Returns whether the watermark can be applied.- Overrides:
canApplyWatermark
in classAbstractWatermark
- Parameters:
g
- the graphics contextdimension
- the dimension of the drawing area- Returns:
- true if it can be applied
-
doApplyWatermark
protected void doApplyWatermark(Graphics g, Dimension dimension)
Applies the watermark in the specified graphics context.- Specified by:
doApplyWatermark
in classAbstractWatermark
- Parameters:
g
- the graphics contextdimension
- the dimension of the drawing area
-
-