SubstanceTrait
, SubstanceWatermark
public class SubstanceImageWatermark extends Object implements SubstanceWatermark
SubstanceWatermark
, drawing specified image as
watermark. This class is part of officially supported API.Modifier and Type | Field | Description |
---|---|---|
protected BufferedImage |
origImage |
The original image (as read from the disk / HTTP connection).
|
protected String |
origImageLocation |
The original image location.
|
protected Image |
watermarkImage |
Watermark image (screen-sized).
|
Constructor | Description |
---|---|
SubstanceImageWatermark(InputStream inputStream) |
Creates an instance from the specified input stream.
|
SubstanceImageWatermark(String imageLocation) |
Creates an instance with specified image.
|
Modifier and Type | Method | Description |
---|---|---|
void |
dispose() |
Disposes the memory associated with
this watermark. |
void |
drawWatermarkImage(Graphics graphics,
Component c,
int x,
int y,
int width,
int height) |
Draws the watermark on the specified graphics context in the specified
region.
|
String |
getDisplayName() |
Returns the display name of
this trait. |
SubstanceConstants.ImageWatermarkKind |
getKind() |
Returns the image watermark kind.
|
float |
getOpacity() |
Returns the image watermark opacity.
|
String |
getOrigImageLocation() |
Returns the location of the original image.
|
void |
previewWatermark(Graphics g,
SubstanceSkin skin,
int x,
int y,
int width,
int height) |
Draws the preview of the watermark image.
|
void |
setKind(SubstanceConstants.ImageWatermarkKind kind) |
Sets image watermark kind.
|
void |
setOpacity(float opacity) |
Sets image watermark opacity.
|
boolean |
updateWatermarkImage(SubstanceSkin skin) |
Updates the current watermark image.
|
protected Image watermarkImage
protected BufferedImage origImage
protected String origImageLocation
public SubstanceImageWatermark(String imageLocation)
imageLocation
- Image location. Can point to a local file or HTTP URL (needs
to start with http
in the later case).public SubstanceImageWatermark(InputStream inputStream)
inputStream
- Input stream.public void drawWatermarkImage(Graphics graphics, Component c, int x, int y, int width, int height)
SubstanceWatermark
drawWatermarkImage
in interface SubstanceWatermark
graphics
- Graphics context.c
- Component that is painted.x
- Left X of the region.y
- Top Y of the region.width
- Region width.height
- Region height.public void previewWatermark(Graphics g, SubstanceSkin skin, int x, int y, int width, int height)
SubstanceWatermark
previewWatermark
in interface SubstanceWatermark
g
- Graphic context.skin
- Optional skin to use for the preview. Can be ignored by the
implementation.x
- the x coordinate of the watermark to be drawn.y
- The y coordinate of the watermark to be drawn.width
- The width of the watermark to be drawn.height
- The height of the watermark to be drawn.public boolean updateWatermarkImage(SubstanceSkin skin)
SubstanceWatermark
updateWatermarkImage
in interface SubstanceWatermark
skin
- Skin for the watermark.true
if the watermark has been updated successfully,
false
otherwise.public String getDisplayName()
SubstanceTrait
this
trait. This method is part
of officially supported API.getDisplayName
in interface SubstanceTrait
this
trait.public void dispose()
SubstanceWatermark
this
watermark.dispose
in interface SubstanceWatermark
public String getOrigImageLocation()
public void setKind(SubstanceConstants.ImageWatermarkKind kind)
kind
- Image watermark kind.public SubstanceConstants.ImageWatermarkKind getKind()
public float getOpacity()
public void setOpacity(float opacity)
opacity
- Image watermark opacity.IllegalArgumentException
- if the argument is not in 0.0-1.0 range.