Class MarkupTextSegmentRenderer
java.lang.Object
uno.anahata.asi.swing.agi.message.part.text.AbstractTextSegmentRenderer
uno.anahata.asi.swing.agi.message.part.text.MarkupTextSegmentRenderer
Renders a markdown text segment into a
WrappingEditorPane.
This class extends AbstractTextSegmentRenderer and handles the
conversion of markdown to HTML and applying appropriate styling.- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final com.vladsch.flexmark.html.HtmlRendererThe Flexmark HTML renderer.private WrappingEditorPaneThe inner text component.private final booleanWhether this segment represents a model thought.private final com.vladsch.flexmark.parser.ParserThe Flexmark markdown parser.Fields inherited from class AbstractTextSegmentRenderer
agiConfig, agiPanel, closed, component, currentContent, lastRenderedContentModifier and TypeFieldDescriptionprotected final SwingAgiConfigThe agi configuration.protected final AgiPanelThe parent agi panel.protected booleanWhether the segment is fully closed/complete.protected JComponentThe actual Swing component being rendered.protected StringThe raw content for this segment.protected StringThe content that was last rendered into the component. -
Constructor Summary
ConstructorsConstructorDescriptionMarkupTextSegmentRenderer(AgiPanel agiPanel, String initialContent, boolean isThought) Constructs a new MarkupTextSegmentRenderer. -
Method Summary
Modifier and TypeMethodDescriptionbooleanmatches(TextSegmentDescriptor descriptor) Determines if this renderer can handle the given segment descriptor.booleanrender()Renders or updates the segment's JComponent based on the current content.private voidupdateStyleSheet(StyleSheet sheet) voidForces the renderer to refresh its visual styling (e.g., colors, fonts) to align with the active Look and Feel.Methods inherited from class AbstractTextSegmentRenderer
contentRendered, hasContentChanged, updateComponentContent, updateContentModifier and TypeMethodDescriptionprotected voidSets the last rendered content to the current content.protected booleanChecks if the current content is different from the last rendered content.protected voidupdateComponentContent(String content) Pushes incremental content updates to the visual component.voidupdateContent(String newContent) Updates the current content of this segment.
-
Field Details
-
markdownParser
private final com.vladsch.flexmark.parser.Parser markdownParserThe Flexmark markdown parser. -
htmlRenderer
private final com.vladsch.flexmark.html.HtmlRenderer htmlRendererThe Flexmark HTML renderer. -
isThought
private final boolean isThoughtWhether this segment represents a model thought. -
innerComponent
The inner text component.
-
-
Constructor Details
-
MarkupTextSegmentRenderer
Constructs a new MarkupTextSegmentRenderer.- Parameters:
agiPanel- The agi panel instance.initialContent- The initial markdown content for this segment.isThought- True if the text represents a model thought, false otherwise.
-
-
Method Details
-
render
public boolean render()Renders or updates the segment's JComponent based on the current content. This method should be called to ensure the component reflects the latest content. It should handle diffing internally to avoid unnecessary re-creation of components. It reuses the existingWrappingEditorPaneif available and updates its content only if the markdown text has changed.- Specified by:
renderin classAbstractTextSegmentRenderer- Returns:
- True if a visual update occurred, false otherwise.
-
updateStyleSheet
-
updateTheme
public void updateTheme()Forces the renderer to refresh its visual styling (e.g., colors, fonts) to align with the active Look and Feel.Overridden to clear the render cache and force a complete HTML text rebuild with the fresh theme colors.
- Overrides:
updateThemein classAbstractTextSegmentRenderer
-
matches
Determines if this renderer can handle the given segment descriptor. Subclasses must implement this to specify their compatibility. AMarkupTextSegmentRendererhandlesTextSegmentType.TEXTdescriptors.- Specified by:
matchesin classAbstractTextSegmentRenderer- Parameters:
descriptor- TheTextSegmentDescriptorto check.- Returns:
- True if this renderer can handle the descriptor, false otherwise.
-

