Record Class Style

java.lang.Object
java.lang.Record
io.github.chkrishnatej.rp3200.Style
Record Components:
bold - emphasised (bold) text
underline - underlined text
invert - white text on a black background
size - character size, never null

public record Style(boolean bold, boolean underline, boolean invert, TextSize size) extends Record
Character style: bold, underline, reverse (white on black) and size.

Immutable; the with... methods return modified copies. Most code only needs the builder's EscPosBuilder.bold(boolean) / EscPosBuilder.size(TextSize) methods. This type is needed when passing styled Style.Segments to EscPosBuilder.row(Columns, java.util.List), or to set everything at once with EscPosBuilder.style(Style).


 Style boldTall = Style.PLAIN.withBold(true).withSize(TextSize.TALL);
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final record 
    A run of text printed in one style - the building block of mixed-style table cells.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Style
    Plain, normal-size text - the printer's power-on state.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Style(boolean bold, boolean underline, boolean invert, TextSize size)
    Creates a style.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns the value of the bold record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    boolean
    Returns the value of the invert record component.
    Returns the value of the size record component.
    final String
    Returns a string representation of this record class.
    boolean
    Returns the value of the underline record component.
    withBold(boolean on)
    Returns a copy with bold switched on or off.
    withInvert(boolean on)
    Returns a copy with reverse printing (white on black) switched on or off.
    Returns a copy with another character size.
    withUnderline(boolean on)
    Returns a copy with underline switched on or off.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • PLAIN

      public static final Style PLAIN
      Plain, normal-size text - the printer's power-on state.
  • Constructor Details

    • Style

      public Style(boolean bold, boolean underline, boolean invert, TextSize size)
      Creates a style.
      Parameters:
      bold - emphasised (bold) text
      underline - underlined text
      invert - white text on a black background
      size - character size
      Throws:
      NullPointerException - if size is null
  • Method Details

    • withBold

      public Style withBold(boolean on)
      Returns a copy with bold switched on or off.
      Parameters:
      on - true for bold
      Returns:
      the modified copy
    • withUnderline

      public Style withUnderline(boolean on)
      Returns a copy with underline switched on or off.
      Parameters:
      on - true to underline
      Returns:
      the modified copy
    • withInvert

      public Style withInvert(boolean on)
      Returns a copy with reverse printing (white on black) switched on or off.
      Parameters:
      on - true for white on black
      Returns:
      the modified copy
    • withSize

      public Style withSize(TextSize s)
      Returns a copy with another character size.
      Parameters:
      s - the new size
      Returns:
      the modified copy
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • bold

      public boolean bold()
      Returns the value of the bold record component.
      Returns:
      the value of the bold record component
    • underline

      public boolean underline()
      Returns the value of the underline record component.
      Returns:
      the value of the underline record component
    • invert

      public boolean invert()
      Returns the value of the invert record component.
      Returns:
      the value of the invert record component
    • size

      public TextSize size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component