com.gif4j
Class Watermark

java.lang.Object
  extended bycom.gif4j.Watermark

public class Watermark
extends java.lang.Object

An instance of this class is used to prepare and apply (paint with the specified transparency) images as watermarks to GifFrame(s). Absolute and layout positioning are supported.

Version:
1.0
Author:
Gif4J Software
See Also:
GifImage, BufferedImage

Field Summary
static int LAYOUT_BOTTOM_CENTER
          The bottom-center layout constraint.
static int LAYOUT_BOTTOM_LEFT
          The bottom-left layout constraint.
static int LAYOUT_BOTTOM_RIGHT
          The bottom-right layout constraint.
static int LAYOUT_COVER_CONSECUTIVELY
          By providing this layout constraint an image will be covered by the watermark consecutively.
static int LAYOUT_MIDDLE_CENTER
          The middle-center layout constraint.
static int LAYOUT_MIDDLE_LEFT
          The middle-left layout constraint.
static int LAYOUT_MIDDLE_RIGHT
          The middle-right layout constraint.
static int LAYOUT_TOP_CENTER
          The top-center layout constraint
static int LAYOUT_TOP_LEFT
          The top-left layout constraint.
static int LAYOUT_TOP_RIGHT
          The top-right layout constraint.
 
Constructor Summary
Watermark(java.awt.image.BufferedImage watermarkImage, int layoutConstraint)
          Constructs Watermark from the specified BufferedImage with the specified layout position (final position is calculated according to the specified layout constraint before the applying process to the exact GifFrame starts), and 0.5 transparency (half-transparent).
Watermark(java.awt.image.BufferedImage watermarkImage, int layoutConstraint, float transparency)
          Constructs Watermark from the specified BufferedImage with the specified layout position (final position is calculated according to the specified layout constraint before the applying process to the exact GifFrame starts), and the specified transparency.
Watermark(java.awt.image.BufferedImage watermarkImage, java.awt.Point position)
          Constructs Watermark from the specified BufferedImage with the specified absolute position, and 0.5 transparency (half-transparent).
Watermark(java.awt.image.BufferedImage watermarkImage, java.awt.Point position, float transparency)
          Constructs Watermark from the specified BufferedImage with the specified absolute position and transparency parameter.
 
Method Summary
 java.awt.image.BufferedImage apply(java.awt.image.BufferedImage image)
          Apply (render the specified watermark image with the specified transparency at the specified position) this watermark to the specified image
 void setLayoutConstraint(int layoutConstraint)
          Set the relative position where this instance should paint itself (final position is calculated according to the specified layout constraint before the applying process to the exact GifFrame starts)
 void setPosition(java.awt.Point position)
          set absolute position where this instance should paint itself
 void setTransparency(float transparency)
          Set watermark transparency
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LAYOUT_TOP_LEFT

public static final int LAYOUT_TOP_LEFT
The top-left layout constraint.

See Also:
Constant Field Values

LAYOUT_TOP_CENTER

public static final int LAYOUT_TOP_CENTER
The top-center layout constraint

See Also:
Constant Field Values

LAYOUT_TOP_RIGHT

public static final int LAYOUT_TOP_RIGHT
The top-right layout constraint.

See Also:
Constant Field Values

LAYOUT_MIDDLE_LEFT

public static final int LAYOUT_MIDDLE_LEFT
The middle-left layout constraint.

See Also:
Constant Field Values

LAYOUT_MIDDLE_CENTER

public static final int LAYOUT_MIDDLE_CENTER
The middle-center layout constraint.

See Also:
Constant Field Values

LAYOUT_MIDDLE_RIGHT

public static final int LAYOUT_MIDDLE_RIGHT
The middle-right layout constraint.

See Also:
Constant Field Values

LAYOUT_BOTTOM_LEFT

public static final int LAYOUT_BOTTOM_LEFT
The bottom-left layout constraint.

See Also:
Constant Field Values

LAYOUT_BOTTOM_CENTER

public static final int LAYOUT_BOTTOM_CENTER
The bottom-center layout constraint.

See Also:
Constant Field Values

LAYOUT_BOTTOM_RIGHT

public static final int LAYOUT_BOTTOM_RIGHT
The bottom-right layout constraint.

See Also:
Constant Field Values

LAYOUT_COVER_CONSECUTIVELY

public static final int LAYOUT_COVER_CONSECUTIVELY
By providing this layout constraint an image will be covered by the watermark consecutively.

See Also:
Constant Field Values
Constructor Detail

Watermark

public Watermark(java.awt.image.BufferedImage watermarkImage,
                 java.awt.Point position)
Constructs Watermark from the specified BufferedImage with the specified absolute position, and 0.5 transparency (half-transparent).

Parameters:
watermarkImage - the specified watermark image
position - absolute position where this watermark should be painted at
Throws:
java.lang.NullPointerException - watermarkImage is null

Watermark

public Watermark(java.awt.image.BufferedImage watermarkImage,
                 java.awt.Point position,
                 float transparency)
Constructs Watermark from the specified BufferedImage with the specified absolute position and transparency parameter.

Parameters:
watermarkImage - the specified watermark image
position - absolute position where this watermark should be painted at
transparency - the specified transparency, must be between 0 (absolutely transparent) and 1 (absolutely opaque).
Throws:
java.lang.NullPointerException - watermarkImage is null

Watermark

public Watermark(java.awt.image.BufferedImage watermarkImage,
                 int layoutConstraint)
Constructs Watermark from the specified BufferedImage with the specified layout position (final position is calculated according to the specified layout constraint before the applying process to the exact GifFrame starts), and 0.5 transparency (half-transparent).

Parameters:
watermarkImage - the specified watermark image
layoutConstraint - one of the next: LAYOUT_TOP_LEFT, LAYOUT_TOP_CENTER, LAYOUT_TOP_RIGHT, LAYOUT_MIDDLE_LEFT, LAYOUT_MIDDLE_CENTER, LAYOUT_MIDDLE_RIGHT, LAYOUT_BOTTOM_LEFT, LAYOUT_BOTTOM_CENTER, LAYOUT_BOTTOM_RIGHT
Throws:
java.lang.NullPointerException - watermarkImage is null
java.lang.IllegalArgumentException - unknown layout constraint

Watermark

public Watermark(java.awt.image.BufferedImage watermarkImage,
                 int layoutConstraint,
                 float transparency)
Constructs Watermark from the specified BufferedImage with the specified layout position (final position is calculated according to the specified layout constraint before the applying process to the exact GifFrame starts), and the specified transparency.

Parameters:
watermarkImage - the specified watermark image
layoutConstraint - one of the next: LAYOUT_TOP_LEFT, LAYOUT_TOP_CENTER, LAYOUT_TOP_RIGHT, LAYOUT_MIDDLE_LEFT, LAYOUT_MIDDLE_CENTER, LAYOUT_MIDDLE_RIGHT, LAYOUT_BOTTOM_LEFT, LAYOUT_BOTTOM_CENTER, LAYOUT_BOTTOM_RIGHT
transparency - transparency parameter, must be between 0 (absolutely transparent) and 1 (absolutely opaque).
Throws:
java.lang.NullPointerException - watermarkImage is null
java.lang.IllegalArgumentException - unknown layout constraint
Method Detail

setPosition

public void setPosition(java.awt.Point position)
set absolute position where this instance should paint itself

Parameters:
position - point instance with positive coordinates

setLayoutConstraint

public void setLayoutConstraint(int layoutConstraint)
Set the relative position where this instance should paint itself (final position is calculated according to the specified layout constraint before the applying process to the exact GifFrame starts)

Parameters:
layoutConstraint - one of the next: LAYOUT_TOP_LEFT, LAYOUT_TOP_CENTER, LAYOUT_TOP_RIGHT, LAYOUT_MIDDLE_LEFT, LAYOUT_MIDDLE_CENTER, LAYOUT_MIDDLE_RIGHT, LAYOUT_BOTTOM_LEFT, LAYOUT_BOTTOM_CENTER, LAYOUT_BOTTOM_RIGHT
Throws:
java.lang.IllegalArgumentException - unknown layout constraint

setTransparency

public void setTransparency(float transparency)
Set watermark transparency

Parameters:
transparency - transparency parameter, must be between 0 (absolutely transparent) and 1 (absolutely opaque).

apply

public java.awt.image.BufferedImage apply(java.awt.image.BufferedImage image)
Apply (render the specified watermark image with the specified transparency at the specified position) this watermark to the specified image

Parameters:
image - to apply watermark for
Returns:
new BufferedImage instance with rendered watermark