Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
javax.swing.text.StyleContext
Nested Class Summary | |
class | |
class |
Field Summary | |
static String |
|
Constructor Summary | |
|
Method Summary | |
AttributeSet |
|
AttributeSet |
|
void |
|
Style | |
protected MutableAttributeSet | |
protected StyleContext.SmallAttributeSet | |
Color | |
ChangeListener[] | |
protected int | |
static StyleContext | |
AttributeSet |
|
Font | |
Font |
|
FontMetrics | |
Color | |
static Object |
|
static Object |
|
Style | |
Enumeration |
|
static void |
|
void |
|
void |
|
static void |
|
AttributeSet |
|
AttributeSet |
|
AttributeSet |
|
void |
|
void |
|
String |
|
static void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final String DEFAULT_STYLE
The name of the default style.
- Field Value:
- "default"
public StyleContext()
Creates a new instance of the style context. Add the default style to the style table.
public AttributeSet addAttribute(AttributeSet old, Object name, Object value)
Returns anAttributeSet
that contains the attributes ofold
plus the new attribute specified byname
andvalue
.
- Specified by:
- addAttribute in interface AbstractDocument.AttributeContext
- Parameters:
old
- the attribute set to be merged with the new attributename
- the name of the attribute to be addedvalue
- the value of the attribute to be added
- Returns:
- the old attributes plus the new attribute
public AttributeSet addAttributes(AttributeSet old, AttributeSet attributes)
- Specified by:
- addAttributes in interface AbstractDocument.AttributeContext
- Parameters:
old
- the set of attributes where to add the new attributesattributes
- the attributes to be added
- Returns:
- an
AttributeSet
that contains the attributes ofold
plus the new attributes inattributes
protected StyleContext.SmallAttributeSet createSmallAttributeSet(AttributeSet a)
public AttributeSet getEmptySet()
Returns an emptyAttributeSet
.
- Specified by:
- getEmptySet in interface AbstractDocument.AttributeContext
- Returns:
- an empty
AttributeSet
public static Object getStaticAttribute(Object key)
Gets the object previously registered with registerStaticAttributeKey.
- Parameters:
key
- - the key that was registered.
- Returns:
- the object previously registered with registerStaticAttributeKey.
public static Object getStaticAttributeKey(Object key)
Returns the String that key will be registered with registerStaticAttributeKey.
- Parameters:
key
- - the key that will be registered.
- Returns:
- the string the key will be registered with.
public Style getStyle(String name)
Get the style from the style table. If the passed name matchesDEFAULT_STYLE
, returns the default style. Otherwise returns the previously defined style ofnull
if the style with the given name is not defined.
- Parameters:
name
- the name of the style.
- Returns:
- the style with the given name or null if no such defined.
public Enumeration getStyleNames()
Get the names of the style. The returned enumeration always contains at least one member, the default style.
public static void readAttributeSet(ObjectInputStream in, MutableAttributeSet a) throws ClassNotFoundException, IOException
Reads a set of attributes from the given object input stream. This will attempt to restore keys that were static objects by considering only the keys that have were registered with registerStaticAttributeKey. The attributes retrieved will be placed into the given set.
- Parameters:
in
- - the stream to read froma
- - the set of attributes
- Throws:
ClassNotFoundException
- - may be encountered when reading from streamIOException
- - any I/O error
public void readAttributes(ObjectInputStream in, MutableAttributeSet a) throws ClassNotFoundException, IOException
Handles reading in the attributes.
- Parameters:
in
- - the stream to read froma
- - the set of attributes
- Throws:
ClassNotFoundException
- - may be encountered when reading from streamIOException
- - any I/O error
public void reclaim(AttributeSet attributes)
Called to indicate that the attributes inattributes
are no longer used.
- Specified by:
- reclaim in interface AbstractDocument.AttributeContext
- Parameters:
attributes
- the attributes are no longer used
public static void registerStaticAttributeKey(Object key)
Registers an attribute key as a well-known keys. When an attribute with such a key is written to a stream, a special syntax is used so that it can be recognized when it is read back in. All attribute keys defined inStyleContext
are registered as static keys. If you define additional attribute keys that you want to exist as nonreplicated objects, then you should register them using this method.
- Parameters:
key
- the key to register as static attribute key
public AttributeSet removeAttribute(AttributeSet old, Object name)
- Specified by:
- removeAttribute in interface AbstractDocument.AttributeContext
- Parameters:
old
- the attribute set from which an attribute is removedname
- the name of the attribute to be removed
- Returns:
- the attributes of
old
minus the attribute specified byname
public AttributeSet removeAttributes(AttributeSet old, Enumeration names)
Removes all attributes specified bynames
fromold
and returns the resultingAttributeSet
.
- Specified by:
- removeAttributes in interface AbstractDocument.AttributeContext
- Parameters:
old
- the set of attributes from which to remove attributesnames
- the names of the attributes to be removed fromold
- Returns:
- the attributes of
old
minus the attributes inattributes
public AttributeSet removeAttributes(AttributeSet old, AttributeSet attributes)
Removes all attributes inattributes
fromold
and returns the resultingAttributeSet
.
- Specified by:
- removeAttributes in interface AbstractDocument.AttributeContext
- Parameters:
old
- the set of attributes from which to remove attributesattributes
- the attributes to be removed fromold
- Returns:
- the attributes of
old
minus the attributes inattributes
public String toString()
Returns a string representation of this StyleContext.
- Returns:
- a string representation of this StyleContext
public static void writeAttributeSet(ObjectOutputStream out, AttributeSet a) throws IOException
Serialize an attribute set in a way that is compatible with it being read in again byreadAttributeSet(ObjectInputStream,MutableAttributeSet)
. In particular registered static keys are transformed properly.
- Parameters:
out
- - stream to write toa
- - the attribute set
- Throws:
IOException
- - any I/O error
public void writeAttributes(ObjectOutputStream out, AttributeSet a) throws IOException
Handles writing of the given attributes.
- Parameters:
out
- - stream to write toa
- - the attribute set
- Throws:
IOException
- - any I/O error