de.hillenbrand.swing.text
Class JavaContext

java.lang.Object
  extended by javax.swing.text.StyleContext
      extended by de.hillenbrand.swing.text.JavaContext
All Implemented Interfaces:
java.io.Serializable, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.ViewFactory

public class JavaContext
extends javax.swing.text.StyleContext
implements javax.swing.text.ViewFactory

A collection of styles used to render java text. This class also acts as a factory for the views used to represent the java documents. Since the rendering styles are based upon view preferences, the views need a way to gain access to the style settings which is facilitated by implementing the factory in the style storage. Both functionalities can be widely shared across java document views.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.text.StyleContext
javax.swing.text.StyleContext.NamedStyle, javax.swing.text.StyleContext.SmallAttributeSet
 
Field Summary
 
Fields inherited from class javax.swing.text.StyleContext
DEFAULT_STYLE
 
Constructor Summary
JavaContext()
          Constructs a set of styles to represent java lexical tokens.
 
Method Summary
 javax.swing.text.View create(javax.swing.text.Element elem)
           
 java.awt.Font getFont(int code)
          Fetch the font to use for a lexical token with the given scan value.
 java.awt.Color getForeground(int code)
          Fetch the foreground color to use for a lexical token with the given value.
 javax.swing.text.Style getStyleForScanValue(int code)
          Fetches the attribute set to use for the given scan code.
 
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

JavaContext

public JavaContext()
Constructs a set of styles to represent java lexical tokens. By default there are no colors or fonts specified.

Method Detail

create

public javax.swing.text.View create(javax.swing.text.Element elem)
Specified by:
create in interface javax.swing.text.ViewFactory

getFont

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


getForeground

public java.awt.Color getForeground(int code)
Fetch the foreground color to use for a lexical token with the given value.


getStyleForScanValue

public javax.swing.text.Style getStyleForScanValue(int code)
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.