Class Watermark

java.lang.Object
io.keikai.model.Watermark
All Implemented Interfaces:
Serializable

public class Watermark extends Object implements Serializable
Represents a watermark that can be rendered over a sheet. A watermark can be text-based or image-based, with configurable opacity, rotation, and positioning.
Since:
7.0.0
See Also:
  • Constructor Details

    • Watermark

      public Watermark()
      Creates a watermark with default settings: opacity 0.3, rotation -45 degrees, color #C0C0C0, centered position.
  • Method Details

    • getText

      public String getText()
      Returns the watermark text. Null if this is an image watermark.
      Returns:
      the text, or null
    • setText

      public void setText(String text)
      Sets the watermark text.
      Parameters:
      text - the watermark text
    • getImageData

      public byte[] getImageData()
      Returns the image data for an image-based watermark. Null if text-based.
      Returns:
      the image bytes, or null
    • setImageData

      public void setImageData(byte[] imageData)
      Sets the image data for an image-based watermark.
      Parameters:
      imageData - the image bytes
    • getOpacity

      public double getOpacity()
      Returns the opacity (0.0 = fully transparent, 1.0 = fully opaque). Default: 0.3.
      Returns:
      the opacity
    • setOpacity

      public void setOpacity(double opacity)
      Sets the opacity.
      Parameters:
      opacity - a value between 0.0 and 1.0
      Throws:
      IllegalArgumentException - if opacity is NaN or outside [0.0, 1.0]
    • getRotationAngle

      public double getRotationAngle()
      Returns the rotation angle in degrees. Negative values rotate counter-clockwise. Default: -45.0.
      Returns:
      the rotation angle
    • setRotationAngle

      public void setRotationAngle(double rotationAngle)
      Sets the rotation angle in degrees.
      Parameters:
      rotationAngle - the rotation angle, within [-360.0, 360.0]
      Throws:
      IllegalArgumentException - if rotationAngle is NaN or outside [-360.0, 360.0]
    • getFont

      public SFont getFont()
      Returns the font used for text watermarks.
      Returns:
      the font, or null
    • setFont

      public void setFont(SFont font)
      Sets the font for text watermarks.
      Parameters:
      font - the font
    • getColor

      public String getColor()
      Returns the color as an HTML color string (e.g., "#C0C0C0"). Default: "#C0C0C0".
      Returns:
      the color string
    • setColor

      public void setColor(String color)
      Sets the color as an HTML color string.
      Parameters:
      color - the color string
    • getPosition

      public Watermark.Position getPosition()
      Returns the watermark position. Default: Watermark.Position.CENTER.
      Returns:
      the position
    • setPosition

      public void setPosition(Watermark.Position position)
      Sets the watermark position.
      Parameters:
      position - the position
    • builder

      public static Watermark.Builder builder()
      Returns a new Watermark.Builder for constructing a Watermark.
      Returns:
      a new builder