Record Class TextWatermark

java.lang.Object
java.lang.Record
com.nsdev.lettergenerator.model.watermark.TextWatermark
Record Components:
text - literal watermark text, required and nonblank during generation
fontFamily - built-in or registered regular font family; required during generation
fontSizePt - font size in points (1/72 inch); required and positive during generation
color - six-digit hexadecimal RGB text color, required during generation
pages - page selection, required during generation
opacity - finite paint opacity between zero and one, required during generation
rotationDegrees - finite counterclockwise angle in degrees, required during generation
All Implemented Interfaces:
Watermark

public record TextWatermark(String text, String fontFamily, Double fontSizePt, String color, PageSelector pages, Double opacity, Double rotationDegrees) extends Record implements Watermark
Text centered behind selected pages using a built-in or registered regular font. Positioning uses the physical page center, independently of margins and reserved zones. Text size uses points; rotation is about the page center and positive angles rotate counterclockwise in PDF coordinates. Opacity ranges from zero (invisible) to one (opaque).

The canonical constructor stores every value unchanged; nulls do not select defaults. Generation requires nonblank XML-compatible text, a supported family, positive finite size, a #RRGGBB color, nonnull page selection, opacity in [0, 1], and finite rotation. Use of(String) for a complete set of default appearance values.

  • Constructor Details

    • TextWatermark

      public TextWatermark(String text, String fontFamily, Double fontSizePt, String color, PageSelector pages, Double opacity, Double rotationDegrees)
      Creates an instance of a TextWatermark record class.
      Parameters:
      text - the value for the text record component
      fontFamily - the value for the fontFamily record component
      fontSizePt - the value for the fontSizePt record component
      color - the value for the color record component
      pages - the value for the pages record component
      opacity - the value for the opacity record component
      rotationDegrees - the value for the rotationDegrees record component
  • Method Details

    • of

      public static TextWatermark of(String text)
      Creates a watermark for all pages using Helvetica, 50 pt, #B0B0B0, opacity 0.12, and a 45-degree counterclockwise rotation. Text is checked during generation.
      Parameters:
      text - literal watermark text
      Returns:
      watermark with default appearance and the supplied text
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • text

      public String text()
      Returns the value of the text record component.
      Returns:
      the value of the text record component
    • fontFamily

      public String fontFamily()
      Returns the value of the fontFamily record component.
      Returns:
      the value of the fontFamily record component
    • fontSizePt

      public Double fontSizePt()
      Returns the value of the fontSizePt record component.
      Returns:
      the value of the fontSizePt record component
    • color

      public String color()
      Returns the value of the color record component.
      Returns:
      the value of the color record component
    • pages

      public PageSelector pages()
      Returns the value of the pages record component.
      Specified by:
      pages in interface Watermark
      Returns:
      the value of the pages record component
    • opacity

      public Double opacity()
      Returns the value of the opacity record component.
      Specified by:
      opacity in interface Watermark
      Returns:
      the value of the opacity record component
    • rotationDegrees

      public Double rotationDegrees()
      Returns the value of the rotationDegrees record component.
      Specified by:
      rotationDegrees in interface Watermark
      Returns:
      the value of the rotationDegrees record component