java.lang.Object
com.amalgamasimulation.desktop.html.page.HTMLPage
All Implemented Interfaces:
HTMLConvertable

public class HTMLPage extends Object implements HTMLConvertable
The HTMLPage class represents an HTML page that can contain various HTML elements and CSS rules. It implements the HTMLConvertable interface, allowing it to be converted to an HTML string.
Author:
Alexey Glazyrin
  • Constructor Details

    • HTMLPage

      public HTMLPage(HTMLPage.Style style)
      Constructs a new HTMLPage instance with default settings. Initializes the HTML structure, including the head and body tags, and loads necessary resources.
      Parameters:
      style - style of page
  • Method Details

    • append

      public HTMLPage append(HTMLConvertable... children)
      Appends one or more HTML elements to the page body.
      Parameters:
      children - the HTML elements to append
      Returns:
      this HTMLPage instance for method chaining
    • append

      public HTMLPage append(List<? extends HTMLConvertable> children)
    • doAction

      public void doAction(String id)
      Executes an action associated with the specified ID. Used only by the Browser object.
      Parameters:
      id - the ID of the action to execute
    • toHTML

      public String toHTML(Set<String> outStrings)
      Converts the HTML page to an HTML string.
      Specified by:
      toHTML in interface HTMLConvertable
      Parameters:
      outStrings - set of unique strings of text content
      Returns:
      the HTML string representation of the page
    • copy

      public HTMLPage 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
      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
    • maxWidthInPx

      public HTMLPage maxWidthInPx(int maxWidth)
      Sets the maximum width of the page in pixels.
      Parameters:
      maxWidth - the maximum width in pixels
      Returns:
      this HTMLPage instance for method chaining
    • maxHeightInPx

      public HTMLPage maxHeightInPx(int maxHeightPx)
      Sets the maximum height of page in pixels.
      Parameters:
      maxHeightPx - the maximum height in pixels
      Returns:
      this HTMLPage instance for method chaining
    • paddingInPx

      public HTMLPage paddingInPx(Side side, int margin)
      Sets the padding of the page for the specified side in pixels.
      Parameters:
      side - the side to set the padding for
      margin - the padding in pixels
      Returns:
      this HTMLPage instance for method chaining
    • offMargin

      public HTMLPage offMargin()
      Removes margins from the document by setting the margin style to zero. This is commonly used to achieve full-page layouts without default browser margins.
      Returns:
      the current HTMLPage instance for method chaining
    • defaultFontColor

      public HTMLPage defaultFontColor(Color color)
      Sets the default font color for the page using the specified AWT color.
      Parameters:
      color - the AWT color to use
      Returns:
      this HTMLPage instance for method chaining
    • defaultFont

      public HTMLPage defaultFont(FontDescriptor fontDescriptor)
      Sets the default font for the page.
      Parameters:
      fontDescriptor - the font descriptor to use as the default
      Returns:
      this HTMLPage instance for method chaining
    • defaultFontWeight

      public HTMLPage defaultFontWeight(String weight)
      Sets the default font weight for the page.
      Parameters:
      weight - the font weight value (e.g., "normal", "bold", "bolder", "lighter", or numeric values like "100", "200", ..., "900")
      Returns:
      this HTMLPage instance for method chaining
    • defaultFontSizeInPx

      public HTMLPage defaultFontSizeInPx(int size)
      Sets the default font size for the page in pixels.
      Parameters:
      size - the font size in pixels
      Returns:
      this HTMLPage instance for method chaining
    • defaultFontFamily

      public HTMLPage defaultFontFamily(String fontFamily)
      Sets the default font family for the page.
      Parameters:
      fontFamily - the font family name(s) to use
      Returns:
      this HTMLPage instance for method chaining
    • defaultFontStyle

      public HTMLPage defaultFontStyle(FontPosture posture)
      Sets the default font style for the page using the specified FontPosture.
      Parameters:
      posture - the FontPosture to use
      Returns:
      this HTMLPage instance for method chaining
    • backgroundColor

      public HTMLPage backgroundColor(Color color)
      Sets the background color using AWT Color converted to RGBA format.
      Parameters:
      color - the background color to apply
      Returns:
      this HTMLPage instance for method chaining