Record Class TextStyle

java.lang.Object
java.lang.Record
io.leandev.appfuse.report.node.TextStyle
Record Components:
fontFamily - 邏輯字型家族名稱(例如 "sans"),對應的字型檔由 renderer 決定
size - 字級
weight - 字重
italic - 是否斜體
color - 文字顏色

public record TextStyle(String fontFamily, Length size, FontWeight weight, Boolean italic, ReportColor color) extends Record

文字樣式覆寫值

每個欄位為 null 時繼承上一層;FontWeight.REGULAR、Boolean.FALSE 等是明確覆寫。 本 record 沒有預設值,完整樣式由 DocumentStyles 提供。

TextStyle emphasis = TextStyle.inherit().withWeight(FontWeight.BOLD);   // 只改粗體,其餘沿用
Since:
4.0.0
  • Constructor Details

    • TextStyle

      public TextStyle(String fontFamily, Length size, FontWeight weight, Boolean italic, ReportColor color)
      Creates an instance of a TextStyle record class.
      Parameters:
      fontFamily - the value for the fontFamily record component
      size - the value for the size record component
      weight - the value for the weight record component
      italic - the value for the italic record component
      color - the value for the color record component
  • Method Details

    • inherit

      public static TextStyle inherit()
      全部欄位繼承的空覆寫
      Returns:
      空覆寫
    • withFontFamily

      public TextStyle withFontFamily(String fontFamily)
    • withSize

      public TextStyle withSize(Length size)
    • withWeight

      public TextStyle withWeight(FontWeight weight)
    • withItalic

      public TextStyle withItalic(Boolean italic)
    • withColor

      public TextStyle withColor(ReportColor color)
    • overlay

      public TextStyle overlay(TextStyle override)
      以 override 的非 null 欄位覆寫本樣式
      Parameters:
      override - 覆寫值;null 視同空覆寫
      Returns:
      合併後的新樣式
    • 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.
    • fontFamily

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

      public Length size()
      Returns the value of the size record component.
      Returns:
      the value of the size record component
    • weight

      public FontWeight weight()
      Returns the value of the weight record component.
      Returns:
      the value of the weight record component
    • italic

      public Boolean italic()
      Returns the value of the italic record component.
      Returns:
      the value of the italic record component
    • color

      public ReportColor color()
      Returns the value of the color record component.
      Returns:
      the value of the color record component