APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.swing.text.rtf

pack-priv Class RTFGenerator

extends Object
Class Inheritance
Imports
java.lang.*, java.util.*, java.awt.Color, java.io.OutputStream, .IOException, javax.swing.text.*

Generates an RTF output stream (java.io.OutputStream) from rich text (handed off through a series of LTTextAcceptor calls). Can be used to generate RTF from any object which knows how to write to a text acceptor (e.g., LTAttributedText and LTRTFFilter).

Note that this is a lossy conversion since RTF's model of text does not exactly correspond with LightText's.

See Also
java.io.OutputStream

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv int
pack-priv Dictionary<Object, Integer>
public static final String
public static final float
public static final Color
defaultRTFColor

The default color, used for text without an explicit color attribute.

pack-priv int
pack-priv Dictionary<String, Integer>
pack-priv static final char[]
private static final Object
pack-priv MutableAttributeSet
pack-priv int[]
pack-priv OutputStream
pack-priv int
pack-priv Dictionary<AttributeSet, Integer>
protected static RTFGenerator.CharacterKeywordPair[]
pack-priv int
private Segment

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv String
private static Object
attrDiff(MutableAttributeSet oldAttrs, AttributeSet newAttrs, Object key, Object dfl)

protected void
checkControlWord(MutableAttributeSet currentAttributes, AttributeSet newAttributes, RTFAttribute word)

protected void
checkControlWords(MutableAttributeSet currentAttributes, AttributeSet newAttributes, RTFAttribute[] words, int domain)

protected void
checkNumericControlWord(MutableAttributeSet currentAttributes, AttributeSet newAttributes, Object attrName, String controlWord, float dflt, float scale)

protected static int
convertCharacter(int[] conversion, char ch)

Takes a char and a conversion table (an int[] in the current implementation, but conversion tables should be treated as an opaque type) and returns the corresponding byte value (as an int, since bytes are signed).

private static boolean
public void
private Style
private Integer
pack-priv static int[]
pack-priv static int[]
outputConversionFromTranslationTable(char[] table)

Takes a translation table (a 256-element array of characters) and creates an output conversion table for use by convertCharacter().

protected void
protected void
protected void
private void
pack-priv void
updateCharacterAttributes(MutableAttributeSet current, AttributeSet newAttributes, boolean updateStyleChanges)

pack-priv void
updateParagraphAttributes(MutableAttributeSet current, AttributeSet newAttributes, boolean emitStyleChanges)

pack-priv void
updateSectionAttributes(MutableAttributeSet current, AttributeSet newAttributes, boolean emitStyleChanges)

public void
public void
writeCharacter(char ch)

public void
public void
writeControlWord(String keyword, int arg)

public static void
pack-priv void
public void
public void
public void
public void
public void
public void
public void
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

afterKeywordback to summary
pack-priv boolean afterKeyword
colorCountback to summary
pack-priv int colorCount
colorTableback to summary
pack-priv Dictionary<Object, Integer> colorTable
defaultFontFamilyback to summary
public static final String defaultFontFamily
defaultFontSizeback to summary
public static final float defaultFontSize
defaultRTFColorback to summary
public static final Color defaultRTFColor

The default color, used for text without an explicit color attribute.

fontCountback to summary
pack-priv int fontCount
fontTableback to summary
pack-priv Dictionary<String, Integer> fontTable
hexdigitsback to summary
pack-priv static final char[] hexdigits
MagicTokenback to summary
private static final Object MagicToken
outputAttributesback to summary
pack-priv MutableAttributeSet outputAttributes
outputConversionback to summary
pack-priv int[] outputConversion
outputStreamback to summary
pack-priv OutputStream outputStream
styleCountback to summary
pack-priv int styleCount
styleTableback to summary
pack-priv Dictionary<AttributeSet, Integer> styleTable
textKeywordsback to summary
protected static RTFGenerator.CharacterKeywordPair[] textKeywords
unicodeCountback to summary
pack-priv int unicodeCount
workingSegmentback to summary
private Segment workingSegment

Constructor Detail

RTFGeneratorback to summary
public RTFGenerator(OutputStream to)

Method Detail

approximationForUnicodeback to summary
pack-priv String approximationForUnicode(char ch)
attrDiffback to summary
private static Object attrDiff(MutableAttributeSet oldAttrs, AttributeSet newAttrs, Object key, Object dfl)
checkControlWordback to summary
protected void checkControlWord(MutableAttributeSet currentAttributes, AttributeSet newAttributes, RTFAttribute word) throws IOException
checkControlWordsback to summary
protected void checkControlWords(MutableAttributeSet currentAttributes, AttributeSet newAttributes, RTFAttribute[] words, int domain) throws IOException
checkNumericControlWordback to summary
protected void checkNumericControlWord(MutableAttributeSet currentAttributes, AttributeSet newAttributes, Object attrName, String controlWord, float dflt, float scale) throws IOException
convertCharacterback to summary
protected static int convertCharacter(int[] conversion, char ch)

Takes a char and a conversion table (an int[] in the current implementation, but conversion tables should be treated as an opaque type) and returns the corresponding byte value (as an int, since bytes are signed).

equalArraysOKback to summary
private static boolean equalArraysOK(Object a, Object b)
examineElementback to summary
public void examineElement(Element el)
findStyleback to summary
private Style findStyle(AttributeSet a)
findStyleNumberback to summary
private Integer findStyleNumber(AttributeSet a, String domain)
outputConversionForNameback to summary
pack-priv static int[] outputConversionForName(String name) throws IOException
outputConversionFromTranslationTableback to summary
pack-priv static int[] outputConversionFromTranslationTable(char[] table)

Takes a translation table (a 256-element array of characters) and creates an output conversion table for use by convertCharacter().

resetCharacterAttributesback to summary
protected void resetCharacterAttributes(MutableAttributeSet currentAttributes) throws IOException
resetParagraphAttributesback to summary
protected void resetParagraphAttributes(MutableAttributeSet currentAttributes) throws IOException
resetSectionAttributesback to summary
protected void resetSectionAttributes(MutableAttributeSet currentAttributes) throws IOException
tallyStylesback to summary
private void tallyStyles(AttributeSet a)
updateCharacterAttributesback to summary
pack-priv void updateCharacterAttributes(MutableAttributeSet current, AttributeSet newAttributes, boolean updateStyleChanges) throws IOException
updateParagraphAttributesback to summary
pack-priv void updateParagraphAttributes(MutableAttributeSet current, AttributeSet newAttributes, boolean emitStyleChanges) throws IOException
updateSectionAttributesback to summary
pack-priv void updateSectionAttributes(MutableAttributeSet current, AttributeSet newAttributes, boolean emitStyleChanges) throws IOException
writeBegingroupback to summary
public void writeBegingroup() throws IOException
writeCharacterback to summary
public void writeCharacter(char ch) throws IOException
Annotations
@SuppressWarnings:fallthrough
writeControlWordback to summary
public void writeControlWord(String keyword) throws IOException
writeControlWordback to summary
public void writeControlWord(String keyword, int arg) throws IOException
writeDocumentback to summary
public static void writeDocument(Document d, OutputStream to) throws IOException
writeDocumentPropertiesback to summary
pack-priv void writeDocumentProperties(Document doc) throws IOException
writeEndgroupback to summary
public void writeEndgroup() throws IOException
writeLineBreakback to summary
public void writeLineBreak() throws IOException
writeParagraphElementback to summary
public void writeParagraphElement(Element el) throws IOException
writeRawStringback to summary
public void writeRawString(String str) throws IOException
writeRTFHeaderback to summary
public void writeRTFHeader() throws IOException
writeRTFTrailerback to summary
public void writeRTFTrailer() throws IOException
writeTextback to summary
public void writeText(Segment s) throws IOException
writeTextback to summary
public void writeText(String s) throws IOException
writeTextElementback to summary
public void writeTextElement(Element el) throws IOException
javax.swing.text.rtf back to summary

pack-priv Class RTFGenerator.CharacterKeywordPair

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public char
public String

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

characterback to summary
public char character
keywordback to summary
public String keyword

Constructor Detail

CharacterKeywordPairback to summary
pack-priv CharacterKeywordPair()