org.fife.ui.rsyntaxtextarea
Class RtfGenerator

java.lang.Object
  extended by org.fife.ui.rsyntaxtextarea.RtfGenerator

public class RtfGenerator
extends Object

Generates RTF text via a simple Java API.

The following RTF features are supported:

The RTF generated isn't really "optimized," but it will do, especially for small amounts of text, such as what's common when copy-and-pasting. It tries to be sufficient for the use case of copying syntax highlighted code:

Version:
1.0
Author:
Robert Futrell

Constructor Summary
RtfGenerator()
          Constructor.
 
Method Summary
 void appendNewline()
          Adds a newline to the RTF document.
 void appendToDoc(String text, Font f, Color fg, Color bg)
          Appends styled text to the RTF document being generated.
 void appendToDoc(String text, Font f, Color fg, Color bg, boolean underline)
          Appends styled text to the RTF document being generated.
 void appendToDoc(String text, Font f, Color fg, Color bg, boolean underline, boolean setFG)
          Appends styled text to the RTF document being generated.
 void appendToDocNoFG(String text, Font f, Color bg, boolean underline)
          Appends styled text to the RTF document being generated.
 String getRtf()
          Returns the RTF document created by this generator.
 void reset()
          Resets this generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RtfGenerator

public RtfGenerator()
Constructor.

Method Detail

appendNewline

public void appendNewline()
Adds a newline to the RTF document.

See Also:
appendToDoc(String, Font, Color, Color)

appendToDoc

public void appendToDoc(String text,
                        Font f,
                        Color fg,
                        Color bg)
Appends styled text to the RTF document being generated.

Parameters:
text - The text to append.
f - The font of the text. If this is null, the default font is used.
fg - The foreground of the text. If this is null, the default foreground color is used.
bg - The background color of the text. If this is null, the default background color is used.
See Also:
appendNewline()

appendToDocNoFG

public void appendToDocNoFG(String text,
                            Font f,
                            Color bg,
                            boolean underline)
Appends styled text to the RTF document being generated.

Parameters:
text - The text to append.
f - The font of the text. If this is null, the default font is used.
bg - The background color of the text. If this is null, the default background color is used.
underline - Whether the text should be underlined.
See Also:
appendNewline()

appendToDoc

public void appendToDoc(String text,
                        Font f,
                        Color fg,
                        Color bg,
                        boolean underline)
Appends styled text to the RTF document being generated.

Parameters:
text - The text to append.
f - The font of the text. If this is null, the default font is used.
fg - The foreground of the text. If this is null, the default foreground color is used.
bg - The background color of the text. If this is null, the default background color is used.
underline - Whether the text should be underlined.
See Also:
appendNewline()

appendToDoc

public void appendToDoc(String text,
                        Font f,
                        Color fg,
                        Color bg,
                        boolean underline,
                        boolean setFG)
Appends styled text to the RTF document being generated.

Parameters:
text - The text to append.
f - The font of the text. If this is null, the default font is used.
fg - The foreground of the text. If this is null, the default foreground color is used.
bg - The background color of the text. If this is null, the default background color is used.
underline - Whether the text should be underlined.
setFG - Whether the foreground specified by fg should be honored (if it is non-null).
See Also:
appendNewline()

getRtf

public String getRtf()
Returns the RTF document created by this generator.

Returns:
The RTF document, as a String.

reset

public void reset()
Resets this generator. All document information and content is cleared.



Copyright © 2003-2012. All Rights Reserved.