Class BBCodeHandler.Default<T extends javafx.scene.layout.Pane>

java.lang.Object
atlantafx.base.util.BBCodeHandler.Default<T>
All Implemented Interfaces:
BBCodeHandler
Enclosing interface:
BBCodeHandler

public static class BBCodeHandler.Default<T extends javafx.scene.layout.Pane> extends Object implements BBCodeHandler
A basic BBCodeHandler implementation.

While parsing all created nodes will be added to the given root container. The container choice depends on the actual markup. Default constructor accepts any Pane or its descendant. Using theTextFlow for text-only markup (no block nodes) and VBox otherwise, is recommended.

Supported tags


 Bold Text          : text  : [b]{text}[/b]
 Italic Text        : text  : [i]{text}[/i]
 Underlined Text    : text  : [u]{text}[/u]
 Strikethrough Text : text  : [s]{text}[/s]
 Font Color         : text  : [color={color}]{text}[/color]
 Font Family        : text  : [font={monospace}]{text}[/font]
 Font Size          : text  : [size={size}]{text}[/size]
 Link               : text  : [url={url}]{text}[/url]
                              [url url={url} class={class}]{text}[/url]
 Email              : text  : [email]{text}[/email]
                              [email email={url} class={class}]{text}[/email]
 Style              : text  : [style={style}]{text}[/style]
 Subscript          : text  : [sub]{text}[/sub]
 Superscript        : text  : [sup]{text}[/sup]
 Heading            : text  : [heading]{text}[/heading]
                              [heading={level}]{text}[/heading]
 Code               : text  : [code]{text}[/code]
                              [code={class}]{text}[/code]
 Span               : text  : [span]{text}[/span]
                              [span={class}]{text}[/span]
                              [span style={style} class={class}]{text}[/span]
 Label              : text  : [label]{text}[/label]
                              [label={class}]{text}[/label]
                              [label style={style} class={class}]{text}[/label]
 Caption Text       : text  : [caption]{text}[/caption]
 Small Text         : text  : [small]{text}[/small]
 Abbreviation       : text  : [abbr="tooltip text"]{text}[/abbr]
 Unordered List     : block : [ul]
                              [li]Entry 1[/li]
                              [li]Entry 2[/li]
                              [/ul]
                              [ul={bullet character}]
                              [li]Entry 1[/li]
                              [li]Entry 2[/li]
                              [/ul]
 Ordered List       : block : [ol]
                              [li]Entry 1[/li]
                              [li]Entry 2[/li]
                              [/ol]
                              [ol={start number or letter}]
                              [li]Entry 1[/li]
                              [li]Entry 2[/li]
                              [/ol]
 Alignment          : block : [left]{content}[/left]
                              [center]{content}[/center]
                              [right]{content}[/right]
                              [align={javafx.geometry.Pos}]{content}[/align]
 Indentation        : block : [indent]{content}[/indent]
                              [indent=level]{content}[/indent]
 Horizontal Rule    : block : [hr/]
                              [hr=thickness/]
 
  • If a tag param contains whitespaces or trailing slash is must be enclosed in double or single quotes.
  • If a tag only has a single param, it can be shortened to the [name=value]{text}[/name]. In this case the tag param name considered to be equal to the tag name.
  • Unknown tag params will be ignored.

Action Events


Some nodes, e.g. Hyperlink require action handlers. To avoid traversing the root container's node graph you can add an event filter.

 var input = "Visit the [url=https://example.com]website[/url].";
 var textFlow = BBCodeParser.createLayout(input);
 textFlow.addEventFilter(ActionEvent.ACTION, e-> {
     if (e.getTarget() instanceof Hyperlink link) {
         openURL(link.getUserData());
     }
     e.consume();
 });