Class HTMLHeader
java.lang.Object
com.amalgamasimulation.desktop.html.HTMLTag
com.amalgamasimulation.desktop.html.text.HTMLHeader
- All Implemented Interfaces:
HTMLConvertable
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 Summary
ConstructorsConstructorDescriptionHTMLHeader(String text, int level) Constructs a new HTMLHeader instance with the specified text and level. -
Method Summary
Modifier and TypeMethodDescriptionCreates a deep copy of this HTMLConvertable element, preserving the element's structure while substituting text content using the provided translation mapping.font(org.eclipse.swt.graphics.Font font) Sets the font of the header.Sets the font color of the header.intlevel()lineHeight(double lineHeight) Sets the line height of the header as a multiple of the font size.marginInPx(javafx.geometry.Side side, int margin) Sets the margin of the header for the specified side in pixels.maxWidthInPx(int maxWidth) Sets the maximum width of the header in pixels.paddingInPx(javafx.geometry.Side side, int margin) Sets the padding of the header for the specified side in pixels.relativeHeight(double height) Sets the relative height of the header as a percentage.relativeWidth(double width) Sets the relative width of the header as a percentage.textAlignment(javafx.scene.text.TextAlignment textAlignment) Sets the text alignment of the header.Methods inherited from class com.amalgamasimulation.desktop.html.HTMLTag
append, attr, backgroundColor, colorToRGBA, fillCopy, fontFamily, fontSizeInPx, fontStyle, fontWeight, getAttributes, getChildren, maxHeightInPx, removeChildren, style, tag, tag, toCSS, toHTMLMethods 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
-
HTMLHeader
Constructs a new HTMLHeader instance with the specified text and level.- Parameters:
text- the text content of the headerlevel- 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
Sets the text alignment of the header.- Overrides:
textAlignmentin classHTMLTag- Parameters:
textAlignment- the text alignment to apply- Returns:
- this HTMLHeader instance for method chaining
-
relativeWidth
Sets the relative width of the header as a percentage.- Overrides:
relativeWidthin classHTMLTag- Parameters:
width- the width as a percentage (e.g., 0.5 for 50%)- Returns:
- this HTMLHeader instance for method chaining
-
relativeHeight
Sets the relative height of the header as a percentage.- Overrides:
relativeHeightin classHTMLTag- Parameters:
height- the height as a percentage (e.g., 0.5 for 50%)- Returns:
- this HTMLHeader instance for method chaining
-
font
Sets the font of the header. -
fontColor
Sets the font color of the header. -
marginInPx
Sets the margin of the header for the specified side in pixels.- Overrides:
marginInPxin classHTMLTag- Parameters:
side- the side to set the margin formargin- the margin in pixels- Returns:
- this HTMLHeader instance for method chaining
-
paddingInPx
Sets the padding of the header for the specified side in pixels.- Overrides:
paddingInPxin classHTMLTag- Parameters:
side- the side to set the padding formargin- the padding in pixels- Returns:
- this HTMLHeader instance for method chaining
-
maxWidthInPx
Sets the maximum width of the header in pixels.- Overrides:
maxWidthInPxin classHTMLTag- Parameters:
maxWidth- the maximum width in pixels- Returns:
- this HTMLHeader instance for method chaining
-
lineHeight
Sets the line height of the header as a multiple of the font size.- Overrides:
lineHeightin classHTMLTag- 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
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- Overrides:
copyin classHTMLTag- 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
-
toHTML
-