Class HTMLPage
java.lang.Object
com.amalgamasimulation.desktop.html.page.HTMLPage
- All Implemented Interfaces:
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
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionHTMLPage(HTMLPage.Style style) Constructs a new HTMLPage instance with default settings. -
Method Summary
Modifier and TypeMethodDescriptionappend(HTMLConvertable... children) Appends one or more HTML elements to the page body.append(List<? extends HTMLConvertable> children) backgroundColor(Color color) Sets the background color using AWT Color converted to RGBA format.Creates a deep copy of this HTMLConvertable element, preserving the element's structure while substituting text content using the provided translation mapping.defaultFont(FontDescriptor fontDescriptor) Sets the default font for the page.defaultFontColor(Color color) Sets the default font color for the page using the specified AWT color.defaultFontFamily(String fontFamily) Sets the default font family for the page.defaultFontSizeInPx(int size) Sets the default font size for the page in pixels.defaultFontStyle(FontPosture posture) Sets the default font style for the page using the specified FontPosture.defaultFontWeight(String weight) Sets the default font weight for the page.voidExecutes an action associated with the specified ID.maxHeightInPx(int maxHeightPx) Sets the maximum height of page in pixels.maxWidthInPx(int maxWidth) Sets the maximum width of the page in pixels.Removes margins from the document by setting the margin style to zero.paddingInPx(Side side, int margin) Sets the padding of the page for the specified side in pixels.Converts the HTML page to an HTML string.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.amalgamasimulation.desktop.html.HTMLConvertable
copy, toHTML
-
Constructor Details
-
HTMLPage
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
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
-
doAction
Executes an action associated with the specified ID. Used only by the Browser object.- Parameters:
id- the ID of the action to execute
-
toHTML
Converts the HTML page to an HTML string.- Specified by:
toHTMLin interfaceHTMLConvertable- Parameters:
outStrings- set of unique strings of text content- Returns:
- the HTML string representation of the page
-
copy
Description copied from interface:HTMLConvertableCreates a deep copy of this HTMLConvertable element, preserving the element's structure while substituting text content using the provided translation mapping.- Specified by:
copyin interfaceHTMLConvertable- Parameters:
stringsSubstitutionMap- a map where keys are original text strings (as collected byHTMLConvertable.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
Sets the maximum width of the page in pixels.- Parameters:
maxWidth- the maximum width in pixels- Returns:
- this HTMLPage instance for method chaining
-
maxHeightInPx
Sets the maximum height of page in pixels.- Parameters:
maxHeightPx- the maximum height in pixels- Returns:
- this HTMLPage instance for method chaining
-
paddingInPx
Sets the padding of the page for the specified side in pixels.- Parameters:
side- the side to set the padding formargin- the padding in pixels- Returns:
- this HTMLPage instance for method chaining
-
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
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
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
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
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
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
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
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
-