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
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | |
| private class | |
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private static final StringConverter | |
| private static final StringConverter | |
| public static final DataFormat | DATA_FORMAT
The data format identifier |
| private static final boolean | |
| private static final StringConverter | |
| private static final DoubleStringConverter | |
| private final HashMap | |
| private static final RichTextFormatHandler | |
| private static final StringConverter | |
| private static final StringConverter |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private <T> void | |
| private <T> void | |
| private void | |
| private void | |
| public Object | copy(StyledTextModel
source model m, StyleResolver view-specific style resolver r, TextPos start text position start, TextPos end text position end)Implements abstract jfx. Creates an object to be put into the Clipboard for the given text range. |
| public StyledInput | createStyledInput(String
the input string input, StyleAttributeMap the style attributes (can be null) attr)Implements abstract jfx. Creates a StyledInput for the given input string. |
| private StyledOutput | |
| public static final RichTextFormatHandler | Returns: the singleton instance ofRtfFormatHandlerReturns the singleton instance of |
| private static void | |
| private static boolean | |
| private static void | |
| public void | save(StyledTextModel
source model m, StyleResolver view-specific style resolver r, TextPos start text position start, TextPos end text position end, OutputStream target out)OutputStreamImplements abstract jfx. Save the text range in the handler's format to the output stream (e.g. save to file). |
| BOOLEAN_CONVERTER | back to summary |
|---|---|
| private static final StringConverter<Boolean> BOOLEAN_CONVERTER | |
| COLOR_CONVERTER | back to summary |
|---|---|
| private static final StringConverter<Color> COLOR_CONVERTER | |
| DATA_FORMAT | back to summary |
|---|---|
| public static final DataFormat DATA_FORMAT The data format identifier | |
| DEBUG | back to summary |
|---|---|
| private static final boolean DEBUG | |
| DIRECTION_CONVERTER | back to summary |
|---|---|
| private static final StringConverter<ParagraphDirection> DIRECTION_CONVERTER | |
| DOUBLE_CONVERTER | back to summary |
|---|---|
| private static final DoubleStringConverter DOUBLE_CONVERTER | |
| handlers | back to summary |
|---|---|
| private final HashMap<Object, RichTextFormatHandler. | |
| instance | back to summary |
|---|---|
| private static final RichTextFormatHandler instance | |
| STRING_CONVERTER | back to summary |
|---|---|
| private static final StringConverter<String> STRING_CONVERTER | |
| TEXT_ALIGNMENT_CONVERTER | back to summary |
|---|---|
| private static final StringConverter<TextAlignment> TEXT_ALIGNMENT_CONVERTER | |
| RichTextFormatHandler | back to summary |
|---|---|
| private RichTextFormatHandler() Constructor. | |
| addHandler | back to summary |
|---|---|
| private <T> void addHandler(StyleAttribute<T> a, String id, StringConverter<T> converter) | |
| addHandler | back to summary |
|---|---|
| private <T> void addHandler(RichTextFormatHandler. | |
| addHandlerBoolean | back to summary |
|---|---|
| private void addHandlerBoolean(StyleAttribute<Boolean> a, String id) | |
| addHandlerString | back to summary |
|---|---|
| private void addHandlerString(StyleAttribute<String> a, String id) | |
| copy | back to summary |
|---|---|
| public Object copy(StyledTextModel m, StyleResolver r, TextPos start, TextPos end) throws IOException Implements abstract jfx. Doc from jfx. Creates an object to be put into the Clipboard for the given text range.
The caller must guarantee that the
Typically, the implementation creates an instance of
| |
| createStyledInput | back to summary |
|---|---|
| public StyledInput createStyledInput(String input, StyleAttributeMap attr) Implements abstract jfx. Doc from jfx. Creates a StyledInput for the given input string. When pasting, the caller may pass
the style attributes
| |
| createStyledOutput | back to summary |
|---|---|
| private StyledOutput createStyledOutput(StyleResolver r, Writer wr) | |
| getInstance | back to summary |
|---|---|
| public static final RichTextFormatHandler getInstance() Returns the singleton instance of
| |
| initAccessor | back to summary |
|---|---|
| private static void initAccessor() | |
| isBuffered | back to summary |
|---|---|
| private static boolean isBuffered(Writer x) | |
| log | back to summary |
|---|---|
| private static void log(Object x) | |
| save | back to summary |
|---|---|
| public void save(StyledTextModel m, StyleResolver r, TextPos start, TextPos end, OutputStream out) throws IOException Implements abstract jfx. Doc from jfx. Save the text range in the handler's format to the output stream (e.g. save to file).
The caller must guarantee that the
Typically, the implementation creates an instance of
| |
| Modifier and Type | Field and Description |
|---|---|
| private final StyleAttribute | |
| private final StringConverter | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public StyleAttribute | |
| public boolean | |
| public T | |
| public String |
| attribute | back to summary |
|---|---|
| private final StyleAttribute<T> attribute | |
| converter | back to summary |
|---|---|
| private final StringConverter<T> converter | |
| id | back to summary |
|---|---|
| private final String id | |
| Handler | back to summary |
|---|---|
| public Handler(StyleAttribute<T> attribute, String id, StringConverter<T> converter) | |
| getId | back to summary |
|---|---|
| public String getId() | |
| getStyleAttribute | back to summary |
|---|---|
| public StyleAttribute | |
| isAllowed | back to summary |
|---|---|
| public boolean isAllowed(T value) | |
| read | back to summary |
|---|---|
| public T read(String s) | |
| write | back to summary |
|---|---|
| public String write(T value) | |
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private int | |
| private StringBuilder | |
| private final ArrayList | |
| private final String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private int | |
| public void | close()
Implements java. Closes this stream and releases any system resources associated with it. |
| private static int | |
| private int | |
| private String | |
| private String | |
| private IOException | |
| public StyledSegment | nextSegment()
Implements jfx. Returns the next segment, or null if no more segments. |
| private StyleAttributeMap | |
| private int |
| index | back to summary |
|---|---|
| private int index | |
| line | back to summary |
|---|---|
| private int line | |
| sb | back to summary |
|---|---|
| private StringBuilder sb | |
| styles | back to summary |
|---|---|
| private final ArrayList<StyleAttributeMap> styles | |
| text | back to summary |
|---|---|
| private final String text | |
| RichStyledInput | back to summary |
|---|---|
| public RichStyledInput(String text) | |
| charAt | back to summary |
|---|---|
| private int charAt(int delta) | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements java. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| decodeHex | back to summary |
|---|---|
| private static int decodeHex(int ch) throws IOException | |
| decodeHexByte | back to summary |
|---|---|
| private int decodeHexByte() throws IOException | |
| decodeText | back to summary |
|---|---|
| private String decodeText() throws IOException | |
| decodeText | back to summary |
|---|---|
| private String decodeText(int start, int ix) throws IOException | |
| err | back to summary |
|---|---|
| private IOException err(Object text) | |
| nextSegment | back to summary |
|---|---|
| public StyledSegment nextSegment() Implements jfx. Doc from jfx. Returns the next segment, or null if no more segments.
| |
| parseAttributes | back to summary |
|---|---|
| private StyleAttributeMap parseAttributes(boolean forParagraph) throws IOException | |
| parseStyleNumber | back to summary |
|---|---|
| private int parseStyleNumber(String s) throws IOException | |
| Modifier and Type | Field and Description |
|---|---|
| private final StyleResolver | |
| private HashMap | |
| private final Writer |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Implements java. Closes this stream and releases any system resources associated with it. |
| public void | consume(StyledSegment
the segment to output seg)Implements jfx. Consumes the next styled segment. |
| private void | |
| private static String | |
| public void | flush()
Implements jfx. Flushes this output stream. |
| private static int | |
| private static boolean |
| resolver | back to summary |
|---|---|
| private final StyleResolver resolver | |
| styles | back to summary |
|---|---|
| private HashMap<StyleAttributeMap, Integer> styles | |
| wr | back to summary |
|---|---|
| private final Writer wr | |
| RichStyledOutput | back to summary |
|---|---|
| public RichStyledOutput(StyleResolver r, Writer wr) | |
| close | back to summary |
|---|---|
| public void close() throws IOException Implements java. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| consume | back to summary |
|---|---|
| public void consume(StyledSegment seg) throws IOException Implements jfx. Doc from jfx. Consumes the next styled segment.
| |
| emitAttributes | back to summary |
|---|---|
| private void emitAttributes(StyleAttributeMap attrs, boolean forParagraph) throws IOException | |
| encode | back to summary |
|---|---|
| private static String encode(String text) | |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Implements jfx. Doc from jfx. Flushes this output stream.
| |
| indexOfSpecialChar | back to summary |
|---|---|
| private static int indexOfSpecialChar(String text) | |
| isSpecialChar | back to summary |
|---|---|
| private static boolean isSpecialChar(char c) | |