Class RichTextFormatHandler
java.lang.Object
jfx.incubator.scene.control.richtext.model.DataFormatHandler
jfx.incubator.scene.control.richtext.model.RichTextFormatHandler
A DataFormatHandler for use with attribute-based rich text models.
The handler uses a simple text-based format:
(*) denotes an optional element.
PARAGRAPH[] PARAGRAPH: { PARAGRAPH_ATTRIBUTE[]*, TEXT_SEGMENT[], "\n" } PARAGRAPH_ATTRIBUTE: { "{!" (name) ATTRIBUTE_VALUE[]* "}" } ATTRIBUTE: { "{" (name) ATTRIBUTE_VALUE[]* "}" } ATTRIBUTE_VALUE: { | (value) } TEXT_SEGMENT: { ATTRIBUTE[]* (text string with escaped special characters) }Attribute sequences are further deduplicated, using a single {number} token which specifies the index into the list of unique sets of attributes. Paragraph attribute sets are treated as separate from the segment attrubite sets.
The following characters are escaped in text segments: {,%,} The escape format is %XX where XX is a hexadecimal value.
Example:
{c|ff00ff}text{b}bold{!rtl}\n {1}line 2{!0}\n
- Since:
- 24
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptioncopy
(StyledTextModel m, StyleResolver r, TextPos start, TextPos end) Creates an object to be put into the Clipboard for the given text range.createStyledInput
(String input, StyleAttributeMap attr) Creates a StyledInput for the given input string.static final RichTextFormatHandler
Returns the singleton instance ofRtfFormatHandler
.void
save
(StyledTextModel m, StyleResolver r, TextPos start, TextPos end, OutputStream out) Save the text range in the handler's format to the output stream (e.g.Methods declared in class jfx.incubator.scene.control.richtext.model.DataFormatHandler
getDataFormat
-
Field Details
-
DATA_FORMAT
The data format identifier
-
-
Method Details
-
getInstance
Returns the singleton instance ofRtfFormatHandler
.- Returns:
- the singleton instance of
RtfFormatHandler
-
createStyledInput
Description copied from class:DataFormatHandler
Creates a StyledInput for the given input string. When pasting, the caller may pass the style attributesattr
at the insertion point. This argument may be used by the implementation if the format contains no styles on its own (for example, in the plain text format case).- Specified by:
createStyledInput
in classDataFormatHandler
- Parameters:
input
- the input stringattr
- the style attributes (can be null)- Returns:
- the StyledInput
-
copy
public Object copy(StyledTextModel m, StyleResolver r, TextPos start, TextPos end) throws IOException Description copied from class:DataFormatHandler
Creates an object to be put into the Clipboard for the given text range. The caller must guarantee that thestart
precedes theend
position.Typically, the implementation creates an instance of
StyledOutput
and callsStyledTextModel.export(TextPos, TextPos, StyledOutput)
method.- Specified by:
copy
in classDataFormatHandler
- Parameters:
m
- source modelr
- view-specific style resolverstart
- start text positionend
- end text position- Returns:
- an object to be placed to the Clipboard
- Throws:
IOException
- when an I/O error occurs
-
save
public void save(StyledTextModel m, StyleResolver r, TextPos start, TextPos end, OutputStream out) throws IOException Description copied from class:DataFormatHandler
Save the text range in the handler's format to the output stream (e.g. save to file). The caller must guarantee that thestart
precedes theend
position. It is the responsibility of the caller to close theOutputStream
.Typically, the implementation creates an instance of
StyledOutput
and callsStyledTextModel.export(TextPos, TextPos, StyledOutput)
method.- Specified by:
save
in classDataFormatHandler
- Parameters:
m
- source modelr
- view-specific style resolverstart
- start text positionend
- end text positionout
- targetOutputStream
- Throws:
IOException
- when an I/O error occurs
-