Package org.fife.ui.rsyntaxtextarea
Class Theme
java.lang.Object
org.fife.ui.rsyntaxtextarea.Theme
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 against
org/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
via getClass().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(), and apply() methods
for various tasks.
Note that to save a Theme via save(OutputStream),
you must currently create a Theme from a text area wrapped in
an RTextScrollPane, so that the color information for the
gutter can be retrieved.
- Version:
- 1.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classLoads aSyntaxSchemefrom an XML file. -
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanbooleanintbooleanbooleanbooleanColor[]booleanboolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePrivate constructor, used when loading from a stream.Theme(RSyntaxTextArea textArea) Creates a theme from an RSyntaxTextArea. -
Method Summary
Modifier and TypeMethodDescriptionvoidapply(RSyntaxTextArea textArea) Applies this theme to a text area.private static Stringprivate static ColorReturns the default selection background color to use if "default" is specified in a theme.private static ColorReturns the default selection background color to use if "default" is specified in a theme.private static ColorReturns the default "selected text" color to use if "default" is specified in a theme.private static FontReturns the specified font.static Themeload(InputStream in) Loads a theme.static Themeload(InputStream in, Font baseFont) Loads a theme.voidsave(OutputStream out) Saves this theme to an output stream.private static ColorReturns the color represented by a string.private static ColorstringToColor(String s, Color defaultVal) Returns the color represented by a string.
-
Field Details
-
baseFont
-
bgColor
-
caretColor
-
useSelectionFG
public boolean useSelectionFG -
selectionFG
-
selectionBG
-
selectionRoundedEdges
public boolean selectionRoundedEdges -
currentLineHighlight
-
fadeCurrentLineHighlight
public boolean fadeCurrentLineHighlight -
tabLineColor
-
marginLineColor
-
markAllHighlightColor
-
markOccurrencesColor
-
markOccurrencesBorder
public boolean markOccurrencesBorder -
matchedBracketFG
-
matchedBracketBG
-
matchedBracketHighlightBoth
public boolean matchedBracketHighlightBoth -
matchedBracketAnimate
public boolean matchedBracketAnimate -
hyperlinkFG
-
secondaryLanguages
-
scheme
-
gutterBackgroundColor
-
gutterBorderColor
-
activeLineRangeColor
-
iconRowHeaderInheritsGutterBG
public boolean iconRowHeaderInheritsGutterBG -
lineNumberColor
-
currentLineNumberColor
-
lineNumberFont
-
lineNumberFontSize
public int lineNumberFontSize -
foldIndicatorFG
-
foldIndicatorArmedFG
-
foldBG
-
armedFoldBG
-
-
Constructor Details
-
Theme
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
Creates a theme from an RSyntaxTextArea. It should be contained in anRTextScrollPaneto get all gutter color information.- Parameters:
textArea- The text area.
-
-
Method Details
-
apply
Applies this theme to a text area.- Parameters:
textArea- The text area to apply this theme to.
-
colorToString
-
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:
-
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
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:
-
getFont
Returns the specified font.- Parameters:
family- The font family.style- The style of font.size- The size of the font.- Returns:
- The font.
-
load
Loads a theme.- Parameters:
in- The input stream to read from. This will be closed when this method returns.- Returns:
- The theme.
- Throws:
IOException- If an IO error occurs.- See Also:
-
load
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:
IOException- If an IO error occurs.- See Also:
-
save
Saves this theme to an output stream.- Parameters:
out- The output stream to write to.- Throws:
IOException- If an IO error occurs.- See Also:
-
stringToColor
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
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 ifsis "default".- Returns:
- The color.
-