Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |
java.lang.Object | +----java.awt.swing.text.StyleContext
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 Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.
Inner Class Summary | |
StyleContext.NamedStyle
|
Field Summary | |
static String | DEFAULT_STYLE
|
Constructor Summary | |
StyleContext()
|
Method Summary | |
AttributeSet | addAttribute(AttributeSet old,
Object name,
Object value)
|
AttributeSet | addAttributes(AttributeSet old,
AttributeSet attr)
|
void | addChangeListener(ChangeListener l)
|
Style | addStyle(String nm,
Style parent)
|
int | getCompressionThreshold()
|
static StyleContext | getDefaultStyleContext()
|
AttributeSet | getEmptySet()
|
Font | getFont(AttributeSet attr)
|
Font | getFont(String family,
int style,
int size)
|
FontMetrics | getFontMetrics(Font f)
|
Style | getStyle(String nm)
|
Enumeration | getStyleNames()
|
static void | readAttributeSet(ObjectInputStream in,
MutableAttributeSet a)
writeAttributeSet .
|
void | reclaim(AttributeSet a)
|
static void | registerStaticAttributeKey(Object key)
|
AttributeSet | removeAttribute(AttributeSet old,
Object name)
|
AttributeSet | removeAttributes(AttributeSet old,
Enumeration names)
|
AttributeSet | removeAttributes(AttributeSet old,
AttributeSet attrs)
|
void | removeChangeListener(ChangeListener l)
|
void | removeStyle(String nm)
|
String | toString()
|
static void | writeAttributeSet(ObjectOutputStream out,
AttributeSet a)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String DEFAULT_STYLE
Constructor Detail |
public StyleContext()
Method Detail |
public static final StyleContext getDefaultStyleContext()
public Style addStyle(String nm, Style parent)
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.
public void removeStyle(String nm)
nm
- the name of the style to remove
public Style getStyle(String nm)
nm
- the name of the style
public Enumeration getStyleNames()
public void addChangeListener(ChangeListener l)
l
- the change listener
public void removeChangeListener(ChangeListener l)
l
- the change listener
public Font getFont(AttributeSet attr)
attr
- the attribute set
public Font getFont(String family, int style, int size)
family
- the font family
style
- the style of the font
size
- the point size
public FontMetrics getFontMetrics(Font f)
f
- the font
public AttributeSet addAttribute(AttributeSet old, Object name, Object value)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
old
- the old attribute set ???
name
- the attribute name
value
- the attribute value
public AttributeSet addAttributes(AttributeSet old, AttributeSet attr)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
old
- the old attribute set
attr
- the attributes to add
public AttributeSet removeAttribute(AttributeSet old, Object name)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
old
- the old set of attributes
name
- the attribute name
public AttributeSet removeAttributes(AttributeSet old, Enumeration names)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
old
- the old attribute set
names
- the attribute names
public AttributeSet removeAttributes(AttributeSet old, AttributeSet attrs)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
old
- the old attribute set
attrs
- the attributes
public AttributeSet getEmptySet()
public void reclaim(AttributeSet a)
This method is thread safe, although most Swing methods are not. Please see Threads and Swing for more information.
a
- the set to reclaim
protected int getCompressionThreshold()
public String toString()
public static void writeAttributeSet(ObjectOutputStream out, AttributeSet a) throws IOException
registerStaticAttributeKey
method.
Any attribute key not regsitered as a static key
will be serialized directly. All values are expected
to be serializable.public static void readAttributeSet(ObjectInputStream in, MutableAttributeSet a) throws ClassNotFoundException, IOException
writeAttributeSet
. This will try 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.
in
- the object stream to read the attribute data from.
a
- the attribute set to place the attribute
definitions in.
public static void registerStaticAttributeKey(Object key)
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.
Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |