Top Description Fields Constructors Methods
org.jabref.htmltonode.rich

public final Class RichTextRenderer

extends Object
Class Inheritance
Imports
java.util.List, javafx.scene.input.MouseButton, javafx.scene.layout.Region, javafx.scene.paint.Color, javafx.scene.text.Text, org.jabref.htmltonode.FxRenderer, .HtmlRenderOptions, org.jabref.htmltonode.internal.RenderSupport, org.jabref.htmltonode.model.Block, .Inline, .InlineStyle, jfx.incubator.scene.control.richtext.RichTextArea, .TextPos, jfx.incubator.scene.control.richtext.model.SimpleViewOnlyStyledModel, .StyleAttribute, .StyleAttributeMap, .StyledTextModel, org.jspecify.annotations.Nullable

Renders the block model into a RichTextArea (JavaFX incubator control) — the selection-, caret- and accessibility-capable alternative to FxRenderer.

Inline content maps to styled segments (StyleAttributeMap); <mark>/background runs map to native highlights; links carry the custom HREF attribute and are resolved on click via RichTextArea#getTextPosition. Tables and horizontal rules are embedded as node paragraphs rendered by FxRenderer; images are embedded as inline nodes. Known interim gaps (tracked upstream, see the project's issue #2): sub-/superscript lose their baseline shift and numeric font weights collapse to bold/normal.

Field Summary

Modifier and TypeField and Description
private final String
private final double
public static final StyleAttribute<String>
HREF

Character attribute carrying a link target; resolved on mouse click.

private double
indent

left indent (in px) applied to paragraphs, e.g. inside <blockquote>

private final SimpleViewOnlyStyledModel
private final HtmlRenderOptions
private boolean
paragraphOccupied

whether the model's last paragraph is occupied (text, node, or a preserved blank line)

private int
paragraphOffset

characters already added to the paragraph currently being built

private @Nullable String
pendingMarker

marker text (e.g. • , 3.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private void
private void
private StyleAttributeMap
attributes(InlineStyle style, double sizeFactor)

public static StyledTextModel

Returns:

a read-only model for RichTextArea#setModel
buildModel
(List<Block>
the blocks to render, typically from HtmlToNode.parse(...)
blocks
,
HtmlRenderOptions
rendering options
options
)

Builds the styled document model.

public static void
configure(RichTextArea area, HtmlRenderOptions options)

Applies the standard preview configuration (read-only, wrapping, link clicks) to area.

private void
embed(List<Block> blocks)

Embeds blocks as a self-contained node paragraph rendered by FxRenderer (tables, rules).

public static @Nullable String
hrefAt(StyledTextModel model, TextPos position)

Returns the link target at position, or null if there is none.

private void
paragraph(List<Inline> inlines, double scale, int minWeight, double spaceAbove)

public static RichTextArea

Returns:

the configured control
render
(List<Block>
the blocks to render
blocks
,
HtmlRenderOptions
rendering options
options
)

Renders the blocks into a ready-to-use, read-only RichTextArea with wrapping and link-click handling.

private void
private void
startParagraph(double spaceAbove)

Ends the previous paragraph (if occupied) and applies attributes/markers to the new one.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseFamilyback to summary
private final String baseFamily
baseSizeback to summary
private final double baseSize
HREFback to summary
public static final StyleAttribute<String> HREF

Character attribute carrying a link target; resolved on mouse click.

indentback to summary
private double indent

left indent (in px) applied to paragraphs, e.g. inside <blockquote>

modelback to summary
private final SimpleViewOnlyStyledModel model
optionsback to summary
private final HtmlRenderOptions options
paragraphOccupiedback to summary
private boolean paragraphOccupied

whether the model's last paragraph is occupied (text, node, or a preserved blank line)

paragraphOffsetback to summary
private int paragraphOffset

characters already added to the paragraph currently being built

pendingMarkerback to summary
private @Nullable String pendingMarker

marker text (e.g. • , 3. ) to prepend to the next paragraph

Constructor Detail

RichTextRendererback to summary
private RichTextRenderer(HtmlRenderOptions options)

Method Detail

appendBlocksback to summary
private void appendBlocks(List<Block> blocks)
appendRunback to summary
private void appendRun(String text, InlineStyle style)
attributesback to summary
private StyleAttributeMap attributes(InlineStyle style, double sizeFactor)
buildModelback to summary
public static StyledTextModel buildModel(List<Block> blocks, HtmlRenderOptions options)

Builds the styled document model. Does not require the JavaFX toolkit.

Parameters
blocks:List<Block>

the blocks to render, typically from HtmlToNode.parse(...)

options:HtmlRenderOptions

rendering options

Returns:StyledTextModel

a read-only model for RichTextArea#setModel

configureback to summary
public static void configure(RichTextArea area, HtmlRenderOptions options)

Applies the standard preview configuration (read-only, wrapping, link clicks) to area.

embedback to summary
private void embed(List<Block> blocks)

Embeds blocks as a self-contained node paragraph rendered by FxRenderer (tables, rules).

hrefAtback to summary
public static @Nullable String hrefAt(StyledTextModel model, TextPos position)

Returns the link target at position, or null if there is none.

Node segments (embedded images, tables) carry no character attributes, so the model returns a null attribute map there — only text runs can hold an HREF. Clicking an image therefore lands on a null map, which this method tolerates.

paragraphback to summary
private void paragraph(List<Inline> inlines, double scale, int minWeight, double spaceAbove)
renderback to summary
public static RichTextArea render(List<Block> blocks, HtmlRenderOptions options)

Renders the blocks into a ready-to-use, read-only RichTextArea with wrapping and link-click handling. Must be used on the JavaFX application thread.

Parameters
blocks:List<Block>

the blocks to render

options:HtmlRenderOptions

rendering options

Returns:RichTextArea

the configured control

separateParagraphback to summary
private void separateParagraph()
startParagraphback to summary
private void startParagraph(double spaceAbove)

Ends the previous paragraph (if occupied) and applies attributes/markers to the new one.