Class HTMLHeader

java.lang.Object
com.amalgamasimulation.desktop.html.HTMLTag
com.amalgamasimulation.desktop.html.text.HTMLHeader
All Implemented Interfaces:
HTMLConvertable

public class HTMLHeader extends HTMLTag
Represents an HTML header element (e.g., h1, h2, etc.). It extends HTMLTag and provides methods for configuring and rendering headers with custom text, alignment, fonts, colors, and spacing.
Author:
Alexey Glazyrin
  • Constructor Details

    • HTMLHeader

      public HTMLHeader(String text, int level)
      Constructs a new HTMLHeader instance with the specified text and level.
      Parameters:
      text - the text content of the header
      level - the level of the header (1 for h1, 2 for h2, etc.)
      Throws:
      IllegalArgumentException - if the level is outside the range 1-6
  • Method Details

    • textAlignment

      public HTMLHeader textAlignment(javafx.scene.text.TextAlignment textAlignment)
      Sets the text alignment of the header.
      Overrides:
      textAlignment in class HTMLTag
      Parameters:
      textAlignment - the text alignment to apply
      Returns:
      this HTMLHeader instance for method chaining
    • relativeWidth

      public HTMLHeader relativeWidth(double width)
      Sets the relative width of the header as a percentage.
      Overrides:
      relativeWidth in class HTMLTag
      Parameters:
      width - the width as a percentage (e.g., 0.5 for 50%)
      Returns:
      this HTMLHeader instance for method chaining
    • relativeHeight

      public HTMLHeader relativeHeight(double height)
      Sets the relative height of the header as a percentage.
      Overrides:
      relativeHeight in class HTMLTag
      Parameters:
      height - the height as a percentage (e.g., 0.5 for 50%)
      Returns:
      this HTMLHeader instance for method chaining
    • font

      public HTMLHeader font(org.eclipse.swt.graphics.Font font)
      Sets the font of the header.
      Overrides:
      font in class HTMLTag
      Parameters:
      font - the font to apply
      Returns:
      this HTMLHeader instance for method chaining
    • fontColor

      public HTMLHeader fontColor(Color color)
      Sets the font color of the header.
      Overrides:
      fontColor in class HTMLTag
      Parameters:
      color - the color to apply
      Returns:
      this HTMLHeader instance for method chaining
    • marginInPx

      public HTMLHeader marginInPx(javafx.geometry.Side side, int margin)
      Sets the margin of the header for the specified side in pixels.
      Overrides:
      marginInPx in class HTMLTag
      Parameters:
      side - the side to set the margin for
      margin - the margin in pixels
      Returns:
      this HTMLHeader instance for method chaining
    • paddingInPx

      public HTMLHeader paddingInPx(javafx.geometry.Side side, int margin)
      Sets the padding of the header for the specified side in pixels.
      Overrides:
      paddingInPx in class HTMLTag
      Parameters:
      side - the side to set the padding for
      margin - the padding in pixels
      Returns:
      this HTMLHeader instance for method chaining
    • maxWidthInPx

      public HTMLHeader maxWidthInPx(int maxWidth)
      Sets the maximum width of the header in pixels.
      Overrides:
      maxWidthInPx in class HTMLTag
      Parameters:
      maxWidth - the maximum width in pixels
      Returns:
      this HTMLHeader instance for method chaining
    • lineHeight

      public HTMLHeader lineHeight(double lineHeight)
      Sets the line height of the header as a multiple of the font size.
      Overrides:
      lineHeight in class HTMLTag
      Parameters:
      lineHeight - the line height as a double (e.g., 1.5 for 150% of the font size)
      Returns:
      this HTMLHeader instance for method chaining
    • level

      public int level()
    • copy

      public HTMLHeader copy(Map<String,String> stringsSubstitutionMap)
      Description copied from interface: HTMLConvertable
      Creates a deep copy of this HTMLConvertable element, preserving the element's structure while substituting text content using the provided translation mapping.
      Specified by:
      copy in interface HTMLConvertable
      Overrides:
      copy in class HTMLTag
      Parameters:
      stringsSubstitutionMap - a map where keys are original text strings (as collected by HTMLConvertable.toHTML(Set)) and values are their translations. During copying, any encountered text content present in this map will be replaced with its translated version.
      Returns:
      a new independent copy of this HTMLConvertable instance with translated content
    • toHTML

      public String toHTML(int level, String textPrefix, Set<String> outStrings)