Class HTMLTextBlock

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

public class HTMLTextBlock extends HTMLTag
Represents a block of text in HTML, which can contain multiple elements such as text, paragraphs, and other HTML-convertible objects. It extends HTMLTag and provides methods for configuring and rendering text blocks with custom styles, alignment, and spacing.
Author:
Alexey Glazyrin
  • Constructor Details

    • HTMLTextBlock

      public HTMLTextBlock(Object... objects)
      Constructs a new HTMLTextBlock instance with the specified objects. Each object is converted to an HTML element or text content.
      Parameters:
      objects - the objects to include in the text block
  • Method Details

    • appendParagraph

      public HTMLTextBlock appendParagraph(String text)
      Appends a paragraph to the text block.
      Parameters:
      text - the text content of the paragraph
      Returns:
      this HTMLTextBlock instance for method chaining
    • textAlignment

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

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

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

      public HTMLTextBlock font(FontDescriptor fontDescriptor)
      Sets the font of the text block.
      Overrides:
      font in class HTMLTag
      Parameters:
      fontDescriptor - the font descriptor to apply
      Returns:
      this HTMLTextBlock instance for method chaining
    • fontColor

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

      public HTMLTextBlock marginInPx(Side side, int margin)
      Sets the margin of the text block 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 HTMLTextBlock instance for method chaining
    • paddingInPx

      public HTMLTextBlock paddingInPx(Side side, int margin)
      Sets the padding of the text block 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 HTMLTextBlock instance for method chaining
    • maxWidthInPx

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

      public HTMLTextBlock lineHeight(double lineHeight)
      Sets the line height of the text block 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 HTMLTextBlock instance for method chaining