Class HTMLTextBlock
java.lang.Object
com.amalgamasimulation.desktop.html.HTMLTag
com.amalgamasimulation.desktop.html.text.HTMLTextBlock
- All Implemented Interfaces:
HTMLConvertable
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 Summary
ConstructorsConstructorDescriptionHTMLTextBlock(Object... objects) Constructs a new HTMLTextBlock instance with the specified objects. -
Method Summary
Modifier and TypeMethodDescriptionappendParagraph(String text) Appends a paragraph to the text block.font(FontDescriptor fontDescriptor) Sets the font of the text block.Sets the font color of the text block.lineHeight(double lineHeight) Sets the line height of the text block as a multiple of the font size.marginInPx(Side side, int margin) Sets the margin of the text block for the specified side in pixels.maxWidthInPx(int maxWidth) Sets the maximum width of the text block in pixels.paddingInPx(Side side, int margin) Sets the padding of the text block for the specified side in pixels.relativeHeight(double height) Sets the relative height of the text block as a percentage.relativeWidth(double width) Sets the relative width of the text block as a percentage.textAlignment(TextAlignment textAlignment) Sets the text alignment of the text block.Methods inherited from class com.amalgamasimulation.desktop.html.HTMLTag
append, attr, backgroundColor, colorToRGBA, copy, 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
-
HTMLTextBlock
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
Appends a paragraph to the text block.- Parameters:
text- the text content of the paragraph- Returns:
- this HTMLTextBlock instance for method chaining
-
textAlignment
Sets the text alignment of the text block.- Overrides:
textAlignmentin classHTMLTag- Parameters:
textAlignment- the text alignment to apply- Returns:
- this HTMLTextBlock instance for method chaining
-
relativeWidth
Sets the relative width of the text block as a percentage.- Overrides:
relativeWidthin classHTMLTag- Parameters:
width- the width as a percentage (e.g., 0.5 for 50%)- Returns:
- this HTMLTextBlock instance for method chaining
-
relativeHeight
Sets the relative height of the text block as a percentage.- Overrides:
relativeHeightin classHTMLTag- Parameters:
height- the height as a percentage (e.g., 0.5 for 50%)- Returns:
- this HTMLTextBlock instance for method chaining
-
font
Sets the font of the text block. -
fontColor
Sets the font color of the text block. -
marginInPx
Sets the margin of the text block for the specified side in pixels.- Overrides:
marginInPxin classHTMLTag- Parameters:
side- the side to set the margin formargin- the margin in pixels- Returns:
- this HTMLTextBlock instance for method chaining
-
paddingInPx
Sets the padding of the text block for the specified side in pixels.- Overrides:
paddingInPxin classHTMLTag- Parameters:
side- the side to set the padding formargin- the padding in pixels- Returns:
- this HTMLTextBlock instance for method chaining
-
maxWidthInPx
Sets the maximum width of the text block in pixels.- Overrides:
maxWidthInPxin classHTMLTag- Parameters:
maxWidth- the maximum width in pixels- Returns:
- this HTMLTextBlock instance for method chaining
-
lineHeight
Sets the line height of the text block 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 HTMLTextBlock instance for method chaining
-