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 JavaBeans
has been added to the java.beans package.
Please see java..
| Modifier and Type | Class and Description |
|---|---|
| pack-priv static class | StyleContext.
key for a font table |
| pack-priv static class | StyleContext.
An enumeration of the keys in a SmallAttributeSet. |
| public class | StyleContext.
A collection of attributes, typically used to represent character and paragraph styles. |
| public class | StyleContext.
This class holds a small number of attributes in an array. |
| Modifier and Type | Field and Description |
|---|---|
| private transient Map | |
| public static final String | DEFAULT_STYLE
The name given to the default logical style attached to paragraphs. |
| private static StyleContext | |
| private transient StyleContext. | |
| private transient Hashtable | |
| private static Hashtable | |
| private transient MutableAttributeSet | |
| private Style | |
| private static Hashtable | |
| pack-priv static final int | THRESHOLD
The threshold for no longer sharing the set of attributes in an immutable table. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public synchronized AttributeSet | Returns: the updated attribute setthe old attribute set old, Object the non-null attribute name name, Object the attribute value value)Implements javax. Adds an attribute to the given set, and returns the new representative set. |
| public synchronized AttributeSet | Returns: the updated attribute setthe old attribute set old, AttributeSet the attributes to add attr)Implements javax. Adds a set of attributes to the element. |
| public void | addChangeListener(ChangeListener
the change listener l)Adds a listener to track when styles are added or removed. |
| public Style | Returns: the created stylethe 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. nm, Style the parent style. This may be null if unspecified
attributes need not be resolved in some other style. parent)Adds a new style into the style hierarchy. |
| protected MutableAttributeSet | Returns: a large set of attributes that should trade off space for timeThe set of attributes to be represented in
the larger form. a)Create a large set of attributes that should trade off space for time. |
| protected StyleContext. | Returns: a compact set of attributes that might be sharedThe set of attributes to be represented in
the compact form. a)Create a compact set of attributes that might be shared. |
| public Color | Returns: the colorthe set of attributes attr)Takes a set of attributes and turn it into a background color specification. |
| public ChangeListener[] | Returns: all of theChangeListeners added or an empty
array if no listeners have been addedReturns an array of all the |
| protected int | Returns: the thresholdReturns the maximum number of key/value pairs to try and compress into unique/immutable sets. |
| public static final StyleContext | Returns: the contextReturns default AttributeContext shared by all documents that don't bother to define/supply their own context. |
| public AttributeSet | Returns: the setImplements javax. Fetches an empty AttributeSet. |
| public Font | |
| public Font | |
| public FontMetrics | |
| public Color | Returns: the colorthe set of attributes attr)Takes a set of attributes and turn it into a foreground color specification. |
| pack-priv AttributeSet | |
| pack-priv MutableAttributeSet | getMutableAttributeSet(AttributeSet a)
Creates a mutable attribute set to hand out because the current needs are too big to try and use a shared version. |
| public static Object | Returns: Returns the object previously registered withregisterStaticAttributeKeythe object key key)Returns the object previously registered with
|
| public static Object | Returns: the String thatkey will be registered withthe object key key)Returns the String that |
| public Style | |
| public Enumeration | |
| public void | readAttributes(ObjectInputStream
the object stream to read the attribute data from. in, MutableAttributeSet the attribute set to place the attribute
definitions in. a)Context-specific handling of reading in attributes |
| public static void | readAttributeSet(ObjectInputStream
the object stream to read the attribute data from. in, MutableAttributeSet the attribute set to place the attribute
definitions in. a)Reads a set of attributes from the given object input
stream that have been previously written out with
|
| private void | |
| public void | reclaim(AttributeSet
the set to reclaim a)Implements javax. Returns a set no longer needed by the MutableAttributeSet implementation. |
| public static void | registerStaticAttributeKey(Object
the non-null object key key)Registers an object as a static object that is being used as a key in attribute sets. |
| public synchronized AttributeSet | Returns: the updated attribute setthe old set of attributes old, Object the non-null attribute name name)Implements javax. Removes an attribute from the set. |
| public synchronized AttributeSet | Returns: the updated attribute setthe old attribute set old, Enumeration<?> the attribute names names)Implements javax. Removes a set of attributes for the element. |
| public synchronized AttributeSet | Returns: the updated attribute setthe old attribute set old, AttributeSet the attributes attrs)Implements javax. Removes a set of attributes for the element. |
| public void | removeChangeListener(ChangeListener
the change listener l)Removes a listener that was tracking styles being added or removed. |
| public void | removeStyle(String
the name of the style to remove nm)Removes a named style previously added to the document. |
| pack-priv synchronized void | |
| public String | Returns: the stringOverrides java. Converts a StyleContext to a String. |
| public void | writeAttributes(ObjectOutputStream
the output stream out, AttributeSet the attribute set a)Context-specific handling of writing out attributes |
| public static void | writeAttributeSet(ObjectOutputStream
the output stream out, AttributeSet the attribute set a)Writes a set of attributes to the given object stream for the purpose of serialization. |
| private void |