SMACS

smacs.xngr.browser.editor
Class XmlContext

java.lang.Object
  extended byjavax.swing.text.StyleContext
      extended bysmacs.xngr.browser.editor.XmlContext
All Implemented Interfaces:
AbstractDocument.AttributeContext, Serializable

public class XmlContext
extends StyleContext

A list of styles used to render syntx-highlighted XML text.

Note: The XML Editor package is based on the JavaEditorKit example as described in the article 'Customizing a Text Editor' by Timothy Prinzing. See: http://java.sun.com/products/jfc/tsc/articles/text/editor_kit/

Author:
Edwin Dankert
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.text.StyleContext
StyleContext.NamedStyle, StyleContext.SmallAttributeSet
 
Field Summary
 
Fields inherited from class javax.swing.text.StyleContext
DEFAULT_STYLE
 
Constructor Summary
XmlContext()
          Constructs a set of style objects to represent XML lexical tokens and initialises these tokens with a font style and color.
 
Method Summary
 Font getFont(int token)
          Fetch the font to use for a lexical token with the given scan value.
 Font getFont(Style style)
           
 Color getForeground(int token)
          Gets the foreground color to use for a lexical token with the given value.
 Color getForeground(Style style)
           
 Style getStyle(int token)
          Fetches the attribute set to use for the given scan code.
 void setAttributes(int token, Color foreground, int style)
          Sets the token attributes, like foreground color and Font style.
 void setDefaultValues()
           
 void setFont(Font font)
           
 void setFontStyle(int token, int style)
          Sets the font to use for a lexical token with the given value.
 void setForeground(int token, Color color)
          Sets the foreground color to use for a lexical token with the given value.
 
Methods inherited from class javax.swing.text.StyleContext
addAttribute, addAttributes, addChangeListener, addStyle, createLargeAttributeSet, createSmallAttributeSet, getBackground, getChangeListeners, getCompressionThreshold, getDefaultStyleContext, getEmptySet, getFont, getFont, getFontMetrics, getForeground, getStaticAttribute, getStaticAttributeKey, getStyle, getStyleNames, readAttributes, readAttributeSet, reclaim, registerStaticAttributeKey, removeAttribute, removeAttributes, removeAttributes, removeChangeListener, removeStyle, toString, writeAttributes, writeAttributeSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XmlContext

public XmlContext()
Constructs a set of style objects to represent XML lexical tokens and initialises these tokens with a font style and color.

Method Detail

setFont

public void setFont(Font font)

setDefaultValues

public void setDefaultValues()

setAttributes

public void setAttributes(int token,
                          Color foreground,
                          int style)
Sets the token attributes, like foreground color and Font style.

Parameters:
token - the token to set the font for.
foreground - the foreground color for the token.
style - the font-style value for the token.

setFontStyle

public void setFontStyle(int token,
                         int style)
Sets the font to use for a lexical token with the given value.

Parameters:
token - the token to set the font for.
style - the font-style value for the token.

setForeground

public void setForeground(int token,
                          Color color)
Sets the foreground color to use for a lexical token with the given value.

Parameters:
token - the token to set the foreground for.
color - the foreground color value for the token.

getForeground

public Color getForeground(int token)
Gets the foreground color to use for a lexical token with the given value.

Returns:
the foreground color value for the token.

getFont

public Font getFont(int token)
Fetch the font to use for a lexical token with the given scan value.


getFont

public Font getFont(Style style)

getForeground

public Color getForeground(Style style)

getStyle

public Style getStyle(int token)
Fetches the attribute set to use for the given scan code. The set is stored in a table to facilitate relatively fast access to use in conjunction with the scanner.


SMACS