syntaxhighlight
Class Theme

java.lang.Object
  extended by syntaxhighlight.Theme
Direct Known Subclasses:
ThemeDefault, ThemeDesert, ThemeSonsOfObsidian, ThemeSunburst

public class Theme
extends java.lang.Object

Theme for the SyntaxHighlighterPane and JTextComponentRowHeader. To make a new theme, either extending this class or initiate this class and set parameters using setters. For the default value, find the comment of the constructor.

Author:
Chan Wai Shing

Field Summary
protected  java.awt.Color background
          The background color of the script text area.
protected  java.awt.Font font
          The font of the script text.
protected  java.awt.Color gutterBorderColor
          The color of the border that joint the gutter and the script text area.
protected  int gutterBorderWidth
          The width of the border that joint the gutter and the script text area.
protected  java.awt.Color gutterText
          The color of the gutter text.
protected  java.awt.Font gutterTextFont
          The font of the gutter text.
protected  int gutterTextPaddingLeft
          The minimum padding from 'the leftmost of the line number text' to 'the left margin'.
protected  int gutterTextPaddingRight
          The minimum padding from 'the rightmost of the line number text' to 'the right margin' (not to the gutter border).
protected  java.awt.Color highlightedBackground
          The background color of the highlighted line of script text.
protected  Style plain
          The default style.
protected  java.util.Map<java.lang.String,Style> styles
          The styles of this theme.
 
Constructor Summary
Theme()
          Constructor.
 
Method Summary
 Style addStyle(java.lang.String styleKey, Style style)
          Add style.
 void clearStyles()
          Clear all styles.
 Theme clone()
          
 java.awt.Color getBackground()
          The background color of the script text area.
 java.awt.Font getFont()
          The font of the script text.
 java.awt.Color getGutterBorderColor()
          The color of the border that joint the gutter and the script text area.
 int getGutterBorderWidth()
          The width of the border that joint the gutter and the script text area.
 java.awt.Color getGutterText()
          The color of the gutter text.
 java.awt.Font getGutterTextFont()
          The font of the gutter text.
 int getGutterTextPaddingLeft()
          The minimum padding from 'the leftmost of the line number text' to 'the left margin'.
 int getGutterTextPaddingRight()
          The minimum padding from 'the rightmost of the line number text' to 'the right margin' (not to the gutter border).
 java.awt.Color getHighlightedBackground()
          The background color of the highlighted line of script text.
 Style getPlain()
          Get the default style.
 Style getStyle(java.lang.String key)
          Get the style by keyword.
 java.util.Map<java.lang.String,Style> getStyles()
          Get all styles.
 javax.swing.text.SimpleAttributeSet getStylesAttributeSet(java.lang.String styleKeys)
          Get the AttributeSet of styleKeys.
 Style removeStyle(java.lang.String styleKey)
          Remove style by keyword.
 void setBackground(java.awt.Color background)
          The background color of the script text area.
 void setFont(java.awt.Font font)
          The font of the script text.
 void setGutterBorderColor(java.awt.Color gutterBorderColor)
          The color of the border that joint the gutter and the script text area.
 void setGutterBorderWidth(int gutterBorderWidth)
          The width of the border that joint the gutter and the script text area.
 void setGutterText(java.awt.Color gutterText)
          The color of the gutter text.
 void setGutterTextFont(java.awt.Font gutterTextFont)
          The font of the gutter text.
 void setGutterTextPaddingLeft(int gutterTextPaddingLeft)
          The minimum padding from 'the leftmost of the line number text' to 'the left margin'.
 void setGutterTextPaddingRight(int gutterTextPaddingRight)
          The minimum padding from 'the rightmost of the line number text' to 'the right margin' (not to the gutter border).
 void setHighlightedBackground(java.awt.Color highlightedBackground)
          The background color of the highlighted line of script text.
 void setPlain(Style plain)
          Set the default style.
 void setTheme(JTextComponentRowHeader rowHeader)
          Apply the theme to the row header panel.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

font

protected java.awt.Font font
The font of the script text.


background

protected java.awt.Color background
The background color of the script text area.


highlightedBackground

protected java.awt.Color highlightedBackground
The background color of the highlighted line of script text.


gutterText

protected java.awt.Color gutterText
The color of the gutter text.


gutterBorderColor

protected java.awt.Color gutterBorderColor
The color of the border that joint the gutter and the script text area.


gutterBorderWidth

protected int gutterBorderWidth
The width of the border that joint the gutter and the script text area.


gutterTextFont

protected java.awt.Font gutterTextFont
The font of the gutter text.


gutterTextPaddingLeft

protected int gutterTextPaddingLeft
The minimum padding from 'the leftmost of the line number text' to 'the left margin'.


gutterTextPaddingRight

protected int gutterTextPaddingRight
The minimum padding from 'the rightmost of the line number text' to 'the right margin' (not to the gutter border).


plain

protected Style plain
The default style. When the style requested by getStyle(String) not exist, this will be returned.


styles

protected java.util.Map<java.lang.String,Style> styles
The styles of this theme.

Constructor Detail

Theme

public Theme()
Constructor.

Default value:

Method Detail

setTheme

public void setTheme(JTextComponentRowHeader rowHeader)
Apply the theme to the row header panel.

Parameters:
rowHeader - the row header to apply the theme on

setPlain

public void setPlain(Style plain)
Set the default style.

Parameters:
plain - the style

getPlain

public Style getPlain()
Get the default style.

Returns:
the style

getStylesAttributeSet

public javax.swing.text.SimpleAttributeSet getStylesAttributeSet(java.lang.String styleKeys)
Get the AttributeSet of styleKeys. For more than one styles, separate the styles by space, e.g. 'plain comments'.

Parameters:
styleKeys - the style keys with keys separated by space
Returns:
the combined AttributeSet

addStyle

public Style addStyle(java.lang.String styleKey,
                      Style style)
Add style.

Parameters:
styleKey - the keyword of the style
style - the style
Returns:
see the return value of Map.put(Object, Object)

removeStyle

public Style removeStyle(java.lang.String styleKey)
Remove style by keyword.

Parameters:
styleKey - the keyword of the style
Returns:
see the return value of Map.remove(Object)

getStyle

public Style getStyle(java.lang.String key)
Get the style by keyword.

Parameters:
key - the keyword
Returns:
the syntaxhighlighter.theme.Style related to the key; if the style related to the key not exist, the style of 'plain' will return.

getStyles

public java.util.Map<java.lang.String,Style> getStyles()
Get all styles.

Returns:
the styles

clearStyles

public void clearStyles()
Clear all styles.


getFont

public java.awt.Font getFont()
The font of the script text.

Returns:
the font

setFont

public void setFont(java.awt.Font font)
The font of the script text.

Parameters:
font - the font

getBackground

public java.awt.Color getBackground()
The background color of the script text area.

Returns:
the color

setBackground

public void setBackground(java.awt.Color background)
The background color of the script text area.

Parameters:
background - the color

getHighlightedBackground

public java.awt.Color getHighlightedBackground()
The background color of the highlighted line of script text.

Returns:
the color

setHighlightedBackground

public void setHighlightedBackground(java.awt.Color highlightedBackground)
The background color of the highlighted line of script text.

Parameters:
highlightedBackground - the color

getGutterText

public java.awt.Color getGutterText()
The color of the gutter text.

Returns:
the color

setGutterText

public void setGutterText(java.awt.Color gutterText)
The color of the gutter text.

Parameters:
gutterText - the color

getGutterBorderColor

public java.awt.Color getGutterBorderColor()
The color of the border that joint the gutter and the script text area.

Returns:
the color

setGutterBorderColor

public void setGutterBorderColor(java.awt.Color gutterBorderColor)
The color of the border that joint the gutter and the script text area.

Parameters:
gutterBorderColor - the color

getGutterBorderWidth

public int getGutterBorderWidth()
The width of the border that joint the gutter and the script text area.

Returns:
the width in pixel

setGutterBorderWidth

public void setGutterBorderWidth(int gutterBorderWidth)
The width of the border that joint the gutter and the script text area.

Parameters:
gutterBorderWidth - in pixel

getGutterTextFont

public java.awt.Font getGutterTextFont()
The font of the gutter text.

Returns:
the font

setGutterTextFont

public void setGutterTextFont(java.awt.Font gutterTextFont)
The font of the gutter text.

Parameters:
gutterTextFont - the font

getGutterTextPaddingLeft

public int getGutterTextPaddingLeft()
The minimum padding from 'the leftmost of the line number text' to 'the left margin'.

Returns:
the padding in pixel

setGutterTextPaddingLeft

public void setGutterTextPaddingLeft(int gutterTextPaddingLeft)
The minimum padding from 'the leftmost of the line number text' to 'the left margin'.

Parameters:
gutterTextPaddingLeft - in pixel

getGutterTextPaddingRight

public int getGutterTextPaddingRight()
The minimum padding from 'the rightmost of the line number text' to 'the right margin' (not to the gutter border).

Returns:
the padding in pixel

setGutterTextPaddingRight

public void setGutterTextPaddingRight(int gutterTextPaddingRight)
The minimum padding from 'the rightmost of the line number text' to 'the right margin' (not to the gutter border).

Parameters:
gutterTextPaddingRight - in pixel

clone

public Theme clone()

Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object