Package org.fife.ui.rsyntaxtextarea
Class Theme
- java.lang.Object
-
- org.fife.ui.rsyntaxtextarea.Theme
-
public class Theme extends java.lang.Object
A theme is a set of fonts and colors to use to style RSyntaxTextArea and RTextScrollPane. Themes are defined in XML files that are validated againstorg/fife/ui/rsyntaxtextarea/themes/theme.dtd
. This provides applications and other consumers with an easy way to style RSyntaxTextArea without having to use the API.Sample themes are included in the source tree in the
org.fife.ui.rsyntaxtextarea.themes
package, and can be loaded viagetClass().getResourceAsStream(...)
.All fields are public to facilitate programmatic manipulation, but typically you won't need to reference any fields directly, rather using the
load()
,save()
, andapply()
methods for various tasks.Note that to save a
Theme
viasave(OutputStream)
, you must currently create aTheme
from a text area wrapped in anRTextScrollPane
, so that the color information for the gutter can be retrieved.- Version:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Theme.XmlHandler
Loads aSyntaxScheme
from an XML file.
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description private
Theme(java.awt.Font baseFont)
Private constructor, used when loading from a stream.Theme(RSyntaxTextArea textArea)
Creates a theme from an RSyntaxTextArea.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
apply(RSyntaxTextArea textArea)
Applies this theme to a text area.private static java.lang.String
colorToString(java.awt.Color c)
private static java.awt.Color
getDefaultBG()
Returns the default selection background color to use if "default" is specified in a theme.private static java.awt.Color
getDefaultSelectionBG()
Returns the default selection background color to use if "default" is specified in a theme.private static java.awt.Color
getDefaultSelectionFG()
Returns the default "selected text" color to use if "default" is specified in a theme.private static java.awt.Font
getFont(java.lang.String family, int style, int size)
Returns the specified font.static Theme
load(java.io.InputStream in)
Loads a theme.static Theme
load(java.io.InputStream in, java.awt.Font baseFont)
Loads a theme.void
save(java.io.OutputStream out)
Saves this theme to an output stream.private static java.awt.Color
stringToColor(java.lang.String s)
Returns the color represented by a string.private static java.awt.Color
stringToColor(java.lang.String s, java.awt.Color defaultVal)
Returns the color represented by a string.
-
-
-
Field Detail
-
baseFont
public java.awt.Font baseFont
-
bgColor
public java.awt.Color bgColor
-
caretColor
public java.awt.Color caretColor
-
useSelectionFG
public boolean useSelectionFG
-
selectionFG
public java.awt.Color selectionFG
-
selectionBG
public java.awt.Color selectionBG
-
selectionRoundedEdges
public boolean selectionRoundedEdges
-
currentLineHighlight
public java.awt.Color currentLineHighlight
-
fadeCurrentLineHighlight
public boolean fadeCurrentLineHighlight
-
tabLineColor
public java.awt.Color tabLineColor
-
marginLineColor
public java.awt.Color marginLineColor
-
markAllHighlightColor
public java.awt.Color markAllHighlightColor
-
markOccurrencesColor
public java.awt.Color markOccurrencesColor
-
markOccurrencesBorder
public boolean markOccurrencesBorder
-
matchedBracketFG
public java.awt.Color matchedBracketFG
-
matchedBracketBG
public java.awt.Color matchedBracketBG
-
matchedBracketHighlightBoth
public boolean matchedBracketHighlightBoth
-
matchedBracketAnimate
public boolean matchedBracketAnimate
-
hyperlinkFG
public java.awt.Color hyperlinkFG
-
secondaryLanguages
public java.awt.Color[] secondaryLanguages
-
scheme
public SyntaxScheme scheme
-
gutterBackgroundColor
public java.awt.Color gutterBackgroundColor
-
gutterBorderColor
public java.awt.Color gutterBorderColor
-
activeLineRangeColor
public java.awt.Color activeLineRangeColor
-
iconRowHeaderInheritsGutterBG
public boolean iconRowHeaderInheritsGutterBG
-
lineNumberColor
public java.awt.Color lineNumberColor
-
currentLineNumberColor
public java.awt.Color currentLineNumberColor
-
lineNumberFont
public java.lang.String lineNumberFont
-
lineNumberFontSize
public int lineNumberFontSize
-
foldIndicatorFG
public java.awt.Color foldIndicatorFG
-
foldIndicatorArmedFG
public java.awt.Color foldIndicatorArmedFG
-
foldBG
public java.awt.Color foldBG
-
armedFoldBG
public java.awt.Color armedFoldBG
-
-
Constructor Detail
-
Theme
private Theme(java.awt.Font baseFont)
Private constructor, used when loading from a stream.- Parameters:
baseFont
- The default font to use for any "base font" properties not specified in the theme XML. If this isnull
, a default monospaced font will be used.
-
Theme
public Theme(RSyntaxTextArea textArea)
Creates a theme from an RSyntaxTextArea. It should be contained in anRTextScrollPane
to get all gutter color information.- Parameters:
textArea
- The text area.
-
-
Method Detail
-
apply
public void apply(RSyntaxTextArea textArea)
Applies this theme to a text area.- Parameters:
textArea
- The text area to apply this theme to.
-
colorToString
private static java.lang.String colorToString(java.awt.Color c)
-
getDefaultBG
private static java.awt.Color getDefaultBG()
Returns the default selection background color to use if "default" is specified in a theme.- Returns:
- The default selection background to use.
- See Also:
getDefaultSelectionFG()
-
getDefaultSelectionBG
private static java.awt.Color getDefaultSelectionBG()
Returns the default selection background color to use if "default" is specified in a theme.- Returns:
- The default selection background to use.
- See Also:
getDefaultSelectionFG()
-
getDefaultSelectionFG
private static java.awt.Color getDefaultSelectionFG()
Returns the default "selected text" color to use if "default" is specified in a theme.- Returns:
- The default selection foreground color to use.
- See Also:
getDefaultSelectionBG()
-
getFont
private static java.awt.Font getFont(java.lang.String family, int style, int size)
Returns the specified font.- Parameters:
family
- The font family.style
- The style of font.size
- The size of the font.- Returns:
- The font.
-
load
public static Theme load(java.io.InputStream in) throws java.io.IOException
Loads a theme.- Parameters:
in
- The input stream to read from. This will be closed when this method returns.- Returns:
- The theme.
- Throws:
java.io.IOException
- If an IO error occurs.- See Also:
save(OutputStream)
-
load
public static Theme load(java.io.InputStream in, java.awt.Font baseFont) throws java.io.IOException
Loads a theme.- Parameters:
in
- The input stream to read from. This will be closed when this method returns.baseFont
- The default font to use for any "base font" properties not specified in the theme XML. If this isnull
, a default monospaced font will be used.- Returns:
- The theme.
- Throws:
java.io.IOException
- If an IO error occurs.- See Also:
save(OutputStream)
-
save
public void save(java.io.OutputStream out) throws java.io.IOException
Saves this theme to an output stream.- Parameters:
out
- The output stream to write to.- Throws:
java.io.IOException
- If an IO error occurs.- See Also:
load(InputStream)
-
stringToColor
private static java.awt.Color stringToColor(java.lang.String s)
Returns the color represented by a string. The input is expected to be a 6-digit hex string, optionally prefixed by a '$'. For example, either of the following:"$00ff00" "00ff00"
will returnnew Color(0, 255, 0)
.- Parameters:
s
- The string to evaluate.- Returns:
- The color.
-
stringToColor
private static java.awt.Color stringToColor(java.lang.String s, java.awt.Color defaultVal)
Returns the color represented by a string. The input is expected to be a 6-digit hex string, optionally prefixed by a '$'. For example, either of the following:"$00ff00" "00ff00"
will returnnew Color(0, 255, 0)
.- Parameters:
s
- The string to evaluate.defaultVal
- The color to use ifs
is "default
".- Returns:
- The color.
-
-