javax.swing.text
Class StyleContext

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by javax.swing.text.StyleContext
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , AbstractDocument.AttributeContext sample code for javax.swing.text.AbstractDocument.AttributeContext definition code for javax.swing.text.AbstractDocument.AttributeContext
Direct Known Subclasses:
StyleSheet sample code for javax.swing.text.html.StyleSheet definition code for javax.swing.text.html.StyleSheet

public class StyleContext
extends Object sample code for java.lang.Object definition code for java.lang.Object
implements Serializable sample code for java.io.Serializable definition code for java.io.Serializable , AbstractDocument.AttributeContext sample code for javax.swing.text.AbstractDocument.AttributeContext definition code for javax.swing.text.AbstractDocument.AttributeContext

A pool of styles and their associated resources. This class determines the lifetime of a group of resources by being a container that holds caches for various resources such as font and color that get reused by the various style definitions. This can be shared by multiple documents if desired to maximize the sharing of related resources.

This class also provides efficient support for small sets of attributes and compresses them by sharing across uses and taking advantage of their immutable nature. Since many styles are replicated, the potential for sharing is significant, and copies can be extremely cheap. Larger sets reduce the possibility of sharing, and therefore revert automatically to a less space-efficient implementation.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see XMLEncoder sample code for java.beans.XMLEncoder definition code for java.beans.XMLEncoder .

See Also:
Serialized Form

Nested Class Summary
 class StyleContext.NamedStyle sample code for javax.swing.text.StyleContext.NamedStyle definition code for javax.swing.text.StyleContext.NamedStyle
          A collection of attributes, typically used to represent character and paragraph styles.
 class StyleContext.SmallAttributeSet sample code for javax.swing.text.StyleContext.SmallAttributeSet definition code for javax.swing.text.StyleContext.SmallAttributeSet
          This class holds a small number of attributes in an array.
 
Field Summary
static String sample code for java.lang.String definition code for java.lang.String DEFAULT_STYLE sample code for javax.swing.text.StyleContext.DEFAULT_STYLE definition code for javax.swing.text.StyleContext.DEFAULT_STYLE
          The name given to the default logical style attached to paragraphs.
 
Constructor Summary
StyleContext sample code for javax.swing.text.StyleContext.StyleContext() definition code for javax.swing.text.StyleContext.StyleContext() ()
          Creates a new StyleContext object.
 
Method Summary
 AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet addAttribute sample code for javax.swing.text.StyleContext.addAttribute(javax.swing.text.AttributeSet, java.lang.Object, java.lang.Object) definition code for javax.swing.text.StyleContext.addAttribute(javax.swing.text.AttributeSet, java.lang.Object, java.lang.Object) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  old, Object sample code for java.lang.Object definition code for java.lang.Object  name, Object sample code for java.lang.Object definition code for java.lang.Object  value)
          Adds an attribute to the given set, and returns the new representative set.
 AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet addAttributes sample code for javax.swing.text.StyleContext.addAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.addAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  old, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
          Adds a set of attributes to the element.
 void addChangeListener sample code for javax.swing.text.StyleContext.addChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.StyleContext.addChangeListener(javax.swing.event.ChangeListener) (ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener  l)
          Adds a listener to track when styles are added or removed.
 Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style addStyle sample code for javax.swing.text.StyleContext.addStyle(java.lang.String, javax.swing.text.Style) definition code for javax.swing.text.StyleContext.addStyle(java.lang.String, javax.swing.text.Style) (String sample code for java.lang.String definition code for java.lang.String  nm, Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  parent)
          Adds a new style into the style hierarchy.
protected  MutableAttributeSet sample code for javax.swing.text.MutableAttributeSet definition code for javax.swing.text.MutableAttributeSet createLargeAttributeSet sample code for javax.swing.text.StyleContext.createLargeAttributeSet(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.createLargeAttributeSet(javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
          Create a large set of attributes that should trade off space for time.
protected  StyleContext.SmallAttributeSet sample code for javax.swing.text.StyleContext.SmallAttributeSet definition code for javax.swing.text.StyleContext.SmallAttributeSet createSmallAttributeSet sample code for javax.swing.text.StyleContext.createSmallAttributeSet(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.createSmallAttributeSet(javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
          Create a compact set of attributes that might be shared.
 Color sample code for java.awt.Color definition code for java.awt.Color getBackground sample code for javax.swing.text.StyleContext.getBackground(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.getBackground(javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
          Takes a set of attributes and turn it into a background color specification.
 ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener [] getChangeListeners sample code for javax.swing.text.StyleContext.getChangeListeners() definition code for javax.swing.text.StyleContext.getChangeListeners() ()
          Returns an array of all the ChangeListeners added to this StyleContext with addChangeListener().
protected  int getCompressionThreshold sample code for javax.swing.text.StyleContext.getCompressionThreshold() definition code for javax.swing.text.StyleContext.getCompressionThreshold() ()
          Returns the maximum number of key/value pairs to try and compress into unique/immutable sets.
static StyleContext sample code for javax.swing.text.StyleContext definition code for javax.swing.text.StyleContext getDefaultStyleContext sample code for javax.swing.text.StyleContext.getDefaultStyleContext() definition code for javax.swing.text.StyleContext.getDefaultStyleContext() ()
          Returns default AttributeContext shared by all documents that don't bother to define/supply their own context.
 AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet getEmptySet sample code for javax.swing.text.StyleContext.getEmptySet() definition code for javax.swing.text.StyleContext.getEmptySet() ()
          Fetches an empty AttributeSet.
 Font sample code for java.awt.Font definition code for java.awt.Font getFont sample code for javax.swing.text.StyleContext.getFont(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.getFont(javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
          Gets the font from an attribute set.
 Font sample code for java.awt.Font definition code for java.awt.Font getFont sample code for javax.swing.text.StyleContext.getFont(java.lang.String, int, int) definition code for javax.swing.text.StyleContext.getFont(java.lang.String, int, int) (String sample code for java.lang.String definition code for java.lang.String  family, int style, int size)
          Gets a new font.
 FontMetrics sample code for java.awt.FontMetrics definition code for java.awt.FontMetrics getFontMetrics sample code for javax.swing.text.StyleContext.getFontMetrics(java.awt.Font) definition code for javax.swing.text.StyleContext.getFontMetrics(java.awt.Font) (Font sample code for java.awt.Font definition code for java.awt.Font  f)
          Returns font metrics for a font.
 Color sample code for java.awt.Color definition code for java.awt.Color getForeground sample code for javax.swing.text.StyleContext.getForeground(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.getForeground(javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
          Takes a set of attributes and turn it into a foreground color specification.
static Object sample code for java.lang.Object definition code for java.lang.Object getStaticAttribute sample code for javax.swing.text.StyleContext.getStaticAttribute(java.lang.Object) definition code for javax.swing.text.StyleContext.getStaticAttribute(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  key)
          Returns the object previously registered with registerStaticAttributeKey.
static Object sample code for java.lang.Object definition code for java.lang.Object getStaticAttributeKey sample code for javax.swing.text.StyleContext.getStaticAttributeKey(java.lang.Object) definition code for javax.swing.text.StyleContext.getStaticAttributeKey(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  key)
          Returns the String that key will be registered with
 Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style getStyle sample code for javax.swing.text.StyleContext.getStyle(java.lang.String) definition code for javax.swing.text.StyleContext.getStyle(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  nm)
          Fetches a named style previously added to the document
 Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <?> getStyleNames sample code for javax.swing.text.StyleContext.getStyleNames() definition code for javax.swing.text.StyleContext.getStyleNames() ()
          Fetches the names of the styles defined.
 void readAttributes sample code for javax.swing.text.StyleContext.readAttributes(java.io.ObjectInputStream, javax.swing.text.MutableAttributeSet) definition code for javax.swing.text.StyleContext.readAttributes(java.io.ObjectInputStream, javax.swing.text.MutableAttributeSet) (ObjectInputStream sample code for java.io.ObjectInputStream definition code for java.io.ObjectInputStream  in, MutableAttributeSet sample code for javax.swing.text.MutableAttributeSet definition code for javax.swing.text.MutableAttributeSet  a)
          Context-specific handling of reading in attributes
static void readAttributeSet sample code for javax.swing.text.StyleContext.readAttributeSet(java.io.ObjectInputStream, javax.swing.text.MutableAttributeSet) definition code for javax.swing.text.StyleContext.readAttributeSet(java.io.ObjectInputStream, javax.swing.text.MutableAttributeSet) (ObjectInputStream sample code for java.io.ObjectInputStream definition code for java.io.ObjectInputStream  in, MutableAttributeSet sample code for javax.swing.text.MutableAttributeSet definition code for javax.swing.text.MutableAttributeSet  a)
          Reads a set of attributes from the given object input stream that have been previously written out with writeAttributeSet.
 void reclaim sample code for javax.swing.text.StyleContext.reclaim(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.reclaim(javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
          Returns a set no longer needed by the MutableAttributeSet implmentation.
static void registerStaticAttributeKey sample code for javax.swing.text.StyleContext.registerStaticAttributeKey(java.lang.Object) definition code for javax.swing.text.StyleContext.registerStaticAttributeKey(java.lang.Object) (Object sample code for java.lang.Object definition code for java.lang.Object  key)
          Registers an object as a static object that is being used as a key in attribute sets.
 AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet removeAttribute sample code for javax.swing.text.StyleContext.removeAttribute(javax.swing.text.AttributeSet, java.lang.Object) definition code for javax.swing.text.StyleContext.removeAttribute(javax.swing.text.AttributeSet, java.lang.Object) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  old, Object sample code for java.lang.Object definition code for java.lang.Object  name)
          Removes an attribute from the set.
 AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet removeAttributes sample code for javax.swing.text.StyleContext.removeAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.removeAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  old, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attrs)
          Removes a set of attributes for the element.
 AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet removeAttributes sample code for javax.swing.text.StyleContext.removeAttributes(javax.swing.text.AttributeSet, java.util.Enumeration) definition code for javax.swing.text.StyleContext.removeAttributes(javax.swing.text.AttributeSet, java.util.Enumeration) (AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  old, Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <?> names)
          Removes a set of attributes for the element.
 void removeChangeListener sample code for javax.swing.text.StyleContext.removeChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.StyleContext.removeChangeListener(javax.swing.event.ChangeListener) (ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener  l)
          Removes a listener that was tracking styles being added or removed.
 void removeStyle sample code for javax.swing.text.StyleContext.removeStyle(java.lang.String) definition code for javax.swing.text.StyleContext.removeStyle(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  nm)
          Removes a named style previously added to the document.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for javax.swing.text.StyleContext.toString() definition code for javax.swing.text.StyleContext.toString() ()
          Converts a StyleContext to a String.
 void writeAttributes sample code for javax.swing.text.StyleContext.writeAttributes(java.io.ObjectOutputStream, javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.writeAttributes(java.io.ObjectOutputStream, javax.swing.text.AttributeSet) (ObjectOutputStream sample code for java.io.ObjectOutputStream definition code for java.io.ObjectOutputStream  out, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
          Context-specific handling of writing out attributes
static void writeAttributeSet sample code for javax.swing.text.StyleContext.writeAttributeSet(java.io.ObjectOutputStream, javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.writeAttributeSet(java.io.ObjectOutputStream, javax.swing.text.AttributeSet) (ObjectOutputStream sample code for java.io.ObjectOutputStream definition code for java.io.ObjectOutputStream  out, AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
          Writes a set of attributes to the given object stream for the purpose of serialization.
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
clone sample code for java.lang.Object.clone() definition code for java.lang.Object.clone() , equals sample code for java.lang.Object.equals(java.lang.Object) definition code for java.lang.Object.equals(java.lang.Object) , finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , hashCode sample code for java.lang.Object.hashCode() definition code for java.lang.Object.hashCode() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Field Detail

DEFAULT_STYLE sample code for javax.swing.text.StyleContext.DEFAULT_STYLE

public static final String sample code for java.lang.String definition code for java.lang.String  DEFAULT_STYLE
The name given to the default logical style attached to paragraphs.

See Also:
Constant Field Values
Constructor Detail

StyleContext sample code for javax.swing.text.StyleContext() definition code for javax.swing.text.StyleContext()

public StyleContext()
Creates a new StyleContext object.

Method Detail

getDefaultStyleContext sample code for javax.swing.text.StyleContext.getDefaultStyleContext() definition code for javax.swing.text.StyleContext.getDefaultStyleContext()

public static final StyleContext sample code for javax.swing.text.StyleContext definition code for javax.swing.text.StyleContext  getDefaultStyleContext()
Returns default AttributeContext shared by all documents that don't bother to define/supply their own context.

Returns:
the context

addStyle sample code for javax.swing.text.StyleContext.addStyle(java.lang.String, javax.swing.text.Style) definition code for javax.swing.text.StyleContext.addStyle(java.lang.String, javax.swing.text.Style)

public Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  addStyle(String sample code for java.lang.String definition code for java.lang.String  nm,
                      Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  parent)
Adds a new style into the style hierarchy. Style attributes resolve from bottom up so an attribute specified in a child will override an attribute specified in the parent.

Parameters:
nm - the name of the style (must be unique within the collection of named styles in the document). The name may be null if the style is unnamed, but the caller is responsible for managing the reference returned as an unnamed style can't be fetched by name. An unnamed style may be useful for things like character attribute overrides such as found in a style run.
parent - the parent style. This may be null if unspecified attributes need not be resolved in some other style.
Returns:
the created style

removeStyle sample code for javax.swing.text.StyleContext.removeStyle(java.lang.String) definition code for javax.swing.text.StyleContext.removeStyle(java.lang.String)

public void removeStyle(String sample code for java.lang.String definition code for java.lang.String  nm)
Removes a named style previously added to the document.

Parameters:
nm - the name of the style to remove

getStyle sample code for javax.swing.text.StyleContext.getStyle(java.lang.String) definition code for javax.swing.text.StyleContext.getStyle(java.lang.String)

public Style sample code for javax.swing.text.Style definition code for javax.swing.text.Style  getStyle(String sample code for java.lang.String definition code for java.lang.String  nm)
Fetches a named style previously added to the document

Parameters:
nm - the name of the style
Returns:
the style

getStyleNames sample code for javax.swing.text.StyleContext.getStyleNames() definition code for javax.swing.text.StyleContext.getStyleNames()

public Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <?> getStyleNames()
Fetches the names of the styles defined.

Returns:
the list of names as an enumeration

addChangeListener sample code for javax.swing.text.StyleContext.addChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.StyleContext.addChangeListener(javax.swing.event.ChangeListener)

public void addChangeListener(ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener  l)
Adds a listener to track when styles are added or removed.

Parameters:
l - the change listener

removeChangeListener sample code for javax.swing.text.StyleContext.removeChangeListener(javax.swing.event.ChangeListener) definition code for javax.swing.text.StyleContext.removeChangeListener(javax.swing.event.ChangeListener)

public void removeChangeListener(ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener  l)
Removes a listener that was tracking styles being added or removed.

Parameters:
l - the change listener

getChangeListeners sample code for javax.swing.text.StyleContext.getChangeListeners() definition code for javax.swing.text.StyleContext.getChangeListeners()

public ChangeListener sample code for javax.swing.event.ChangeListener definition code for javax.swing.event.ChangeListener [] getChangeListeners()
Returns an array of all the ChangeListeners added to this StyleContext with addChangeListener().

Returns:
all of the ChangeListeners added or an empty array if no listeners have been added
Since:
1.4

getFont sample code for javax.swing.text.StyleContext.getFont(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.getFont(javax.swing.text.AttributeSet)

public Font sample code for java.awt.Font definition code for java.awt.Font  getFont(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
Gets the font from an attribute set. This is implemented to try and fetch a cached font for the given AttributeSet, and if that fails the font features are resolved and the font is fetched from the low-level font cache.

Parameters:
attr - the attribute set
Returns:
the font

getForeground sample code for javax.swing.text.StyleContext.getForeground(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.getForeground(javax.swing.text.AttributeSet)

public Color sample code for java.awt.Color definition code for java.awt.Color  getForeground(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
Takes a set of attributes and turn it into a foreground color specification. This might be used to specify things like brighter, more hue, etc. By default it simply returns the value specified by the StyleConstants.Foreground attribute.

Parameters:
attr - the set of attributes
Returns:
the color

getBackground sample code for javax.swing.text.StyleContext.getBackground(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.getBackground(javax.swing.text.AttributeSet)

public Color sample code for java.awt.Color definition code for java.awt.Color  getBackground(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
Takes a set of attributes and turn it into a background color specification. This might be used to specify things like brighter, more hue, etc. By default it simply returns the value specified by the StyleConstants.Background attribute.

Parameters:
attr - the set of attributes
Returns:
the color

getFont sample code for javax.swing.text.StyleContext.getFont(java.lang.String, int, int) definition code for javax.swing.text.StyleContext.getFont(java.lang.String, int, int)

public Font sample code for java.awt.Font definition code for java.awt.Font  getFont(String sample code for java.lang.String definition code for java.lang.String  family,
                    int style,
                    int size)
Gets a new font. This returns a Font from a cache if a cached font exists. If not, a Font is added to the cache. This is basically a low-level cache for 1.1 font features.

Parameters:
family - the font family (such as "Monospaced")
style - the style of the font (such as Font.PLAIN)
size - the point size >= 1
Returns:
the new font

getFontMetrics sample code for javax.swing.text.StyleContext.getFontMetrics(java.awt.Font) definition code for javax.swing.text.StyleContext.getFontMetrics(java.awt.Font)

public FontMetrics sample code for java.awt.FontMetrics definition code for java.awt.FontMetrics  getFontMetrics(Font sample code for java.awt.Font definition code for java.awt.Font  f)
Returns font metrics for a font.

Parameters:
f - the font
Returns:
the metrics

addAttribute sample code for javax.swing.text.StyleContext.addAttribute(javax.swing.text.AttributeSet, java.lang.Object, java.lang.Object) definition code for javax.swing.text.StyleContext.addAttribute(javax.swing.text.AttributeSet, java.lang.Object, java.lang.Object)

public AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  addAttribute(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  old,
                                 Object sample code for java.lang.Object definition code for java.lang.Object  name,
                                 Object sample code for java.lang.Object definition code for java.lang.Object  value)
Adds an attribute to the given set, and returns the new representative set.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Specified by:
addAttribute sample code for javax.swing.text.AbstractDocument.AttributeContext.addAttribute(javax.swing.text.AttributeSet, java.lang.Object, java.lang.Object) definition code for javax.swing.text.AbstractDocument.AttributeContext.addAttribute(javax.swing.text.AttributeSet, java.lang.Object, java.lang.Object) in interface AbstractDocument.AttributeContext sample code for javax.swing.text.AbstractDocument.AttributeContext definition code for javax.swing.text.AbstractDocument.AttributeContext
Parameters:
old - the old attribute set
name - the non-null attribute name
value - the attribute value
Returns:
the updated attribute set
See Also:
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object) sample code for javax.swing.text.MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object) definition code for javax.swing.text.MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)

addAttributes sample code for javax.swing.text.StyleContext.addAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.addAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet)

public AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  addAttributes(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  old,
                                  AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attr)
Adds a set of attributes to the element.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Specified by:
addAttributes sample code for javax.swing.text.AbstractDocument.AttributeContext.addAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet) definition code for javax.swing.text.AbstractDocument.AttributeContext.addAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet) in interface AbstractDocument.AttributeContext sample code for javax.swing.text.AbstractDocument.AttributeContext definition code for javax.swing.text.AbstractDocument.AttributeContext
Parameters:
old - the old attribute set
attr - the attributes to add
Returns:
the updated attribute set
See Also:
MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object) sample code for javax.swing.text.MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object) definition code for javax.swing.text.MutableAttributeSet.addAttribute(java.lang.Object, java.lang.Object)

removeAttribute sample code for javax.swing.text.StyleContext.removeAttribute(javax.swing.text.AttributeSet, java.lang.Object) definition code for javax.swing.text.StyleContext.removeAttribute(javax.swing.text.AttributeSet, java.lang.Object)

public AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  removeAttribute(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  old,
                                    Object sample code for java.lang.Object definition code for java.lang.Object  name)
Removes an attribute from the set.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Specified by:
removeAttribute sample code for javax.swing.text.AbstractDocument.AttributeContext.removeAttribute(javax.swing.text.AttributeSet, java.lang.Object) definition code for javax.swing.text.AbstractDocument.AttributeContext.removeAttribute(javax.swing.text.AttributeSet, java.lang.Object) in interface AbstractDocument.AttributeContext sample code for javax.swing.text.AbstractDocument.AttributeContext definition code for javax.swing.text.AbstractDocument.AttributeContext
Parameters:
old - the old set of attributes
name - the non-null attribute name
Returns:
the updated attribute set
See Also:
MutableAttributeSet.removeAttribute(java.lang.Object) sample code for javax.swing.text.MutableAttributeSet.removeAttribute(java.lang.Object) definition code for javax.swing.text.MutableAttributeSet.removeAttribute(java.lang.Object)

removeAttributes sample code for javax.swing.text.StyleContext.removeAttributes(javax.swing.text.AttributeSet, java.util.Enumeration<?>) definition code for javax.swing.text.StyleContext.removeAttributes(javax.swing.text.AttributeSet, java.util.Enumeration<?>)

public AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  removeAttributes(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  old,
                                     Enumeration sample code for java.util.Enumeration definition code for java.util.Enumeration <?> names)
Removes a set of attributes for the element.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Specified by:
removeAttributes sample code for javax.swing.text.AbstractDocument.AttributeContext.removeAttributes(javax.swing.text.AttributeSet, java.util.Enumeration) definition code for javax.swing.text.AbstractDocument.AttributeContext.removeAttributes(javax.swing.text.AttributeSet, java.util.Enumeration) in interface AbstractDocument.AttributeContext sample code for javax.swing.text.AbstractDocument.AttributeContext definition code for javax.swing.text.AbstractDocument.AttributeContext
Parameters:
old - the old attribute set
names - the attribute names
Returns:
the updated attribute set
See Also:
MutableAttributeSet.removeAttributes(java.util.Enumeration) sample code for javax.swing.text.MutableAttributeSet.removeAttributes(java.util.Enumeration) definition code for javax.swing.text.MutableAttributeSet.removeAttributes(java.util.Enumeration)

removeAttributes sample code for javax.swing.text.StyleContext.removeAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.removeAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet)

public AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  removeAttributes(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  old,
                                     AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  attrs)
Removes a set of attributes for the element.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Specified by:
removeAttributes sample code for javax.swing.text.AbstractDocument.AttributeContext.removeAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet) definition code for javax.swing.text.AbstractDocument.AttributeContext.removeAttributes(javax.swing.text.AttributeSet, javax.swing.text.AttributeSet) in interface AbstractDocument.AttributeContext sample code for javax.swing.text.AbstractDocument.AttributeContext definition code for javax.swing.text.AbstractDocument.AttributeContext
Parameters:
old - the old attribute set
attrs - the attributes
Returns:
the updated attribute set
See Also:
MutableAttributeSet.removeAttributes(java.util.Enumeration) sample code for javax.swing.text.MutableAttributeSet.removeAttributes(java.util.Enumeration) definition code for javax.swing.text.MutableAttributeSet.removeAttributes(java.util.Enumeration)

getEmptySet sample code for javax.swing.text.StyleContext.getEmptySet() definition code for javax.swing.text.StyleContext.getEmptySet()

public AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  getEmptySet()
Fetches an empty AttributeSet.

Specified by:
getEmptySet sample code for javax.swing.text.AbstractDocument.AttributeContext.getEmptySet() definition code for javax.swing.text.AbstractDocument.AttributeContext.getEmptySet() in interface AbstractDocument.AttributeContext sample code for javax.swing.text.AbstractDocument.AttributeContext definition code for javax.swing.text.AbstractDocument.AttributeContext
Returns:
the set

reclaim sample code for javax.swing.text.StyleContext.reclaim(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.reclaim(javax.swing.text.AttributeSet)

public void reclaim(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
Returns a set no longer needed by the MutableAttributeSet implmentation. This is useful for operation under 1.1 where there are no weak references. This would typically be called by the finalize method of the MutableAttributeSet implementation.

This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.

Specified by:
reclaim sample code for javax.swing.text.AbstractDocument.AttributeContext.reclaim(javax.swing.text.AttributeSet) definition code for javax.swing.text.AbstractDocument.AttributeContext.reclaim(javax.swing.text.AttributeSet) in interface AbstractDocument.AttributeContext sample code for javax.swing.text.AbstractDocument.AttributeContext definition code for javax.swing.text.AbstractDocument.AttributeContext
Parameters:
a - the set to reclaim

getCompressionThreshold sample code for javax.swing.text.StyleContext.getCompressionThreshold() definition code for javax.swing.text.StyleContext.getCompressionThreshold()

protected int getCompressionThreshold()
Returns the maximum number of key/value pairs to try and compress into unique/immutable sets. Any sets above this limit will use hashtables and be a MutableAttributeSet.

Returns:
the threshold

createSmallAttributeSet sample code for javax.swing.text.StyleContext.createSmallAttributeSet(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.createSmallAttributeSet(javax.swing.text.AttributeSet)

protected StyleContext.SmallAttributeSet sample code for javax.swing.text.StyleContext.SmallAttributeSet definition code for javax.swing.text.StyleContext.SmallAttributeSet  createSmallAttributeSet(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
Create a compact set of attributes that might be shared. This is a hook for subclasses that want to alter the behavior of SmallAttributeSet. This can be reimplemented to return an AttributeSet that provides some sort of attribute conversion.

Parameters:
a - The set of attributes to be represented in the the compact form.

createLargeAttributeSet sample code for javax.swing.text.StyleContext.createLargeAttributeSet(javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.createLargeAttributeSet(javax.swing.text.AttributeSet)

protected MutableAttributeSet sample code for javax.swing.text.MutableAttributeSet definition code for javax.swing.text.MutableAttributeSet  createLargeAttributeSet(AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
Create a large set of attributes that should trade off space for time. This set will not be shared. This is a hook for subclasses that want to alter the behavior of the larger attribute storage format (which is SimpleAttributeSet by default). This can be reimplemented to return a MutableAttributeSet that provides some sort of attribute conversion.

Parameters:
a - The set of attributes to be represented in the the larger form.

toString sample code for javax.swing.text.StyleContext.toString() definition code for javax.swing.text.StyleContext.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Converts a StyleContext to a String.

Overrides:
toString sample code for java.lang.Object.toString() definition code for java.lang.Object.toString() in class Object sample code for java.lang.Object definition code for java.lang.Object
Returns:
the string

writeAttributes sample code for javax.swing.text.StyleContext.writeAttributes(java.io.ObjectOutputStream, javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.writeAttributes(java.io.ObjectOutputStream, javax.swing.text.AttributeSet)

public void writeAttributes(ObjectOutputStream sample code for java.io.ObjectOutputStream definition code for java.io.ObjectOutputStream  out,
                            AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
                     throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Context-specific handling of writing out attributes

Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException

readAttributes sample code for javax.swing.text.StyleContext.readAttributes(java.io.ObjectInputStream, javax.swing.text.MutableAttributeSet) definition code for javax.swing.text.StyleContext.readAttributes(java.io.ObjectInputStream, javax.swing.text.MutableAttributeSet)

public void readAttributes(ObjectInputStream sample code for java.io.ObjectInputStream definition code for java.io.ObjectInputStream  in,
                           MutableAttributeSet sample code for javax.swing.text.MutableAttributeSet definition code for javax.swing.text.MutableAttributeSet  a)
                    throws ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException ,
                           IOException sample code for java.io.IOException definition code for java.io.IOException 
Context-specific handling of reading in attributes

Throws:
ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException
IOException sample code for java.io.IOException definition code for java.io.IOException

writeAttributeSet sample code for javax.swing.text.StyleContext.writeAttributeSet(java.io.ObjectOutputStream, javax.swing.text.AttributeSet) definition code for javax.swing.text.StyleContext.writeAttributeSet(java.io.ObjectOutputStream, javax.swing.text.AttributeSet)

public static void writeAttributeSet(ObjectOutputStream sample code for java.io.ObjectOutputStream definition code for java.io.ObjectOutputStream  out,
                                     AttributeSet sample code for javax.swing.text.AttributeSet definition code for javax.swing.text.AttributeSet  a)
                              throws IOException sample code for java.io.IOException definition code for java.io.IOException 
Writes a set of attributes to the given object stream for the purpose of serialization. This will take special care to deal with static attribute keys that have been registered wit the registerStaticAttributeKey method. Any attribute key not regsitered as a static key will be serialized directly. All values are expected to be serializable.

Parameters:
out - the output stream
a - the attribute set
Throws:
IOException sample code for java.io.IOException definition code for java.io.IOException - on any I/O error

readAttributeSet sample code for javax.swing.text.StyleContext.readAttributeSet(java.io.ObjectInputStream, javax.swing.text.MutableAttributeSet) definition code for javax.swing.text.StyleContext.readAttributeSet(java.io.ObjectInputStream, javax.swing.text.MutableAttributeSet)

public static void readAttributeSet(ObjectInputStream sample code for java.io.ObjectInputStream definition code for java.io.ObjectInputStream  in,
                                    MutableAttributeSet sample code for javax.swing.text.MutableAttributeSet definition code for javax.swing.text.MutableAttributeSet  a)
                             throws ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException ,
                                    IOException sample code for java.io.IOException definition code for java.io.IOException 
Reads a set of attributes from the given object input stream that have been previously written out with writeAttributeSet. This will try to restore keys that were static objects to the static objects in the current virtual machine considering only those keys that have been registered with the registerStaticAttributeKey method. The attributes retrieved from the stream will be placed into the given mutable set.

Parameters:
in - the object stream to read the attribute data from.
a - the attribute set to place the attribute definitions in.
Throws:
ClassNotFoundException sample code for java.lang.ClassNotFoundException definition code for java.lang.ClassNotFoundException - passed upward if encountered when reading the object stream.
IOException sample code for java.io.IOException definition code for java.io.IOException - passed upward if encountered when reading the object stream.

registerStaticAttributeKey sample code for javax.swing.text.StyleContext.registerStaticAttributeKey(java.lang.Object) definition code for javax.swing.text.StyleContext.registerStaticAttributeKey(java.lang.Object)

public static void registerStaticAttributeKey(Object sample code for java.lang.Object definition code for java.lang.Object  key)
Registers an object as a static object that is being used as a key in attribute sets. This allows the key to be treated specially for serialization.

For operation under a 1.1 virtual machine, this uses the value returned by toString concatenated to the classname. The value returned by toString should not have the class reference in it (ie it should be reimplemented from the definition in Object) in order to be the same when recomputed later.

Parameters:
key - the non-null object key

getStaticAttribute sample code for javax.swing.text.StyleContext.getStaticAttribute(java.lang.Object) definition code for javax.swing.text.StyleContext.getStaticAttribute(java.lang.Object)

public static Object sample code for java.lang.Object definition code for java.lang.Object  getStaticAttribute(Object sample code for java.lang.Object definition code for java.lang.Object  key)
Returns the object previously registered with registerStaticAttributeKey.


getStaticAttributeKey sample code for javax.swing.text.StyleContext.getStaticAttributeKey(java.lang.Object) definition code for javax.swing.text.StyleContext.getStaticAttributeKey(java.lang.Object)

public static Object sample code for java.lang.Object definition code for java.lang.Object  getStaticAttributeKey(Object sample code for java.lang.Object definition code for java.lang.Object  key)
Returns the String that key will be registered with

See Also:
getStaticAttribute(java.lang.Object) sample code for javax.swing.text.StyleContext.getStaticAttribute(java.lang.Object) definition code for javax.swing.text.StyleContext.getStaticAttribute(java.lang.Object) , registerStaticAttributeKey(java.lang.Object) sample code for javax.swing.text.StyleContext.registerStaticAttributeKey(java.lang.Object) definition code for javax.swing.text.StyleContext.registerStaticAttributeKey(java.lang.Object)