Bounce

org.bounce.text.xml
Class XMLContext

java.lang.Object
  extended by javax.swing.text.StyleContext
      extended by org.bounce.text.xml.XMLContext
All Implemented Interfaces:
Serializable, AbstractDocument.AttributeContext

public class XMLContext
extends StyleContext

A list of styles used to render syntax-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/

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces 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
 int getFontStyle(Style style)
          Fetch the font to use for a lexical token with the given scan value.
 Color getForeground(String token)
          Gets the foreground color to use for a lexical token with the given value.
 Color getForeground(Style style)
          Return the foreground color.
 Style getStyle(String token)
          Return the style for the token.
 void setFontStyle(String token, int style)
          Sets the font to use for a lexical token with the given value.
 void setForeground(String token, Color color)
          Sets the foreground color to use for a lexical token with the given value.
 void setStyle(String token, Color foreground, int style)
          Sets the styles, like foreground color and Font style.
 
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, 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

setStyle

public void setStyle(String token,
                     Color foreground,
                     int style)
Sets the styles, 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(String 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(String 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(String token)
Gets the foreground color to use for a lexical token with the given value.

Parameters:
token - the style value for the token.
Returns:
the foreground color value for the token.

getFontStyle

public int getFontStyle(Style style)
Fetch the font to use for a lexical token with the given scan value.

Parameters:
style - the style.
Returns:
the font style

getForeground

public Color getForeground(Style style)
Return the foreground color.

Parameters:
style - the style
Returns:
the foreground color

getStyle

public Style getStyle(String token)
Return the style for the token.

Overrides:
getStyle in class StyleContext
Parameters:
token - the style identifier.
Returns:
the style.

Bounce

Copyright © 2002 - 2007 Edwin Dankert. All Rights Reserved.