Package io.keikai.model
Class Watermark
java.lang.Object
io.keikai.model.Watermark
- All Implemented Interfaces:
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder for constructingWatermarkinstances.static enumWatermark positioning strategy. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a watermark with default settings: opacity 0.3, rotation -45 degrees, color #C0C0C0, centered position. -
Method Summary
Modifier and TypeMethodDescriptionstatic Watermark.Builderbuilder()Returns a newWatermark.Builderfor constructing a Watermark.getColor()Returns the color as an HTML color string (e.g., "#C0C0C0").getFont()Returns the font used for text watermarks.byte[]Returns the image data for an image-based watermark.doubleReturns the opacity (0.0 = fully transparent, 1.0 = fully opaque).Returns the watermark position.doubleReturns the rotation angle in degrees.getText()Returns the watermark text.voidSets the color as an HTML color string.voidSets the font for text watermarks.voidsetImageData(byte[] imageData) Sets the image data for an image-based watermark.voidsetOpacity(double opacity) Sets the opacity.voidsetPosition(Watermark.Position position) Sets the watermark position.voidsetRotationAngle(double rotationAngle) Sets the rotation angle in degrees.voidSets the watermark text.
-
Constructor Details
-
Watermark
public Watermark()Creates a watermark with default settings: opacity 0.3, rotation -45 degrees, color #C0C0C0, centered position.
-
-
Method Details
-
getText
Returns the watermark text. Null if this is an image watermark.- Returns:
- the text, or null
-
setText
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- ifopacityis 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- ifrotationAngleis NaN or outside [-360.0, 360.0]
-
getFont
Returns the font used for text watermarks.- Returns:
- the font, or null
-
setFont
Sets the font for text watermarks.- Parameters:
font- the font
-
getColor
Returns the color as an HTML color string (e.g., "#C0C0C0"). Default: "#C0C0C0".- Returns:
- the color string
-
setColor
Sets the color as an HTML color string.- Parameters:
color- the color string
-
getPosition
Returns the watermark position. Default:Watermark.Position.CENTER.- Returns:
- the position
-
setPosition
Sets the watermark position.- Parameters:
position- the position
-
builder
Returns a newWatermark.Builderfor constructing a Watermark.- Returns:
- a new builder
-