|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.text.StyleContext
public class StyleContext
| Nested Class Summary | |
|---|---|
class |
StyleContext.NamedStyle
|
class |
StyleContext.SmallAttributeSet
|
| Field Summary | |
|---|---|
static String |
DEFAULT_STYLE
The name of the default style. |
| Constructor Summary | |
|---|---|
StyleContext()
Creates a new instance of the style context. |
|
| Method Summary | |
|---|---|
AttributeSet |
addAttribute(AttributeSet old,
Object name,
Object value)
Returns an AttributeSet that contains the attributes
of old plus the new attribute specified by
name and value. |
AttributeSet |
addAttributes(AttributeSet old,
AttributeSet attributes)
Returns an AttributeSet that contains the attributes
of old plus the new attributes in attributes. |
void |
addChangeListener(ChangeListener listener)
|
Style |
addStyle(String name,
Style parent)
|
protected MutableAttributeSet |
createLargeAttributeSet(AttributeSet a)
|
protected StyleContext.SmallAttributeSet |
createSmallAttributeSet(AttributeSet a)
|
Color |
getBackground(AttributeSet a)
|
ChangeListener[] |
getChangeListeners()
|
protected int |
getCompressionThreshold()
|
static StyleContext |
getDefaultStyleContext()
|
AttributeSet |
getEmptySet()
Returns an empty AttributeSet. |
Font |
getFont(AttributeSet attr)
|
Font |
getFont(String family,
int style,
int size)
|
FontMetrics |
getFontMetrics(Font f)
|
Color |
getForeground(AttributeSet a)
|
static Object |
getStaticAttribute(Object key)
Gets the object previously registered with registerStaticAttributeKey. |
static Object |
getStaticAttributeKey(Object key)
Returns the String that key will be registered with registerStaticAttributeKey. |
Style |
getStyle(String name)
Get the style from the style table. |
Enumeration<?> |
getStyleNames()
Get the names of the style. |
void |
readAttributes(ObjectInputStream in,
MutableAttributeSet a)
Handles reading in the attributes. |
static void |
readAttributeSet(ObjectInputStream in,
MutableAttributeSet a)
Reads a set of attributes from the given object input stream. |
void |
reclaim(AttributeSet attributes)
Called to indicate that the attributes in attributes are
no longer used. |
static void |
registerStaticAttributeKey(Object key)
Registers an attribute key as a well-known keys. |
AttributeSet |
removeAttribute(AttributeSet old,
Object name)
Returns a AttributeSet that has the attribute with the specified
name removed from old. |
AttributeSet |
removeAttributes(AttributeSet old,
AttributeSet attributes)
Removes all attributes in attributes from old
and returns the resulting AttributeSet. |
AttributeSet |
removeAttributes(AttributeSet old,
Enumeration<?> names)
Removes all attributes specified by names from
old and returns the resulting AttributeSet. |
void |
removeChangeListener(ChangeListener listener)
|
void |
removeStyle(String name)
|
String |
toString()
Returns a string representation of this StyleContext. |
void |
writeAttributes(ObjectOutputStream out,
AttributeSet a)
Handles writing of the given attributes. |
static void |
writeAttributeSet(ObjectOutputStream out,
AttributeSet a)
Serialize an attribute set in a way that is compatible with it being read in again by readAttributeSet(ObjectInputStream, MutableAttributeSet). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_STYLE
| Constructor Detail |
|---|
public StyleContext()
| Method Detail |
|---|
protected StyleContext.SmallAttributeSet createSmallAttributeSet(AttributeSet a)
protected MutableAttributeSet createLargeAttributeSet(AttributeSet a)
public void addChangeListener(ChangeListener listener)
public void removeChangeListener(ChangeListener listener)
public ChangeListener[] getChangeListeners()
public Style addStyle(String name,
Style parent)
public void removeStyle(String name)
public Style getStyle(String name)
DEFAULT_STYLE, returns the default style.
Otherwise returns the previously defined style of
null if the style with the given name is not defined.
name - the name of the style.
public Enumeration<?> getStyleNames()
public Font getFont(AttributeSet attr)
public Font getFont(String family,
int style,
int size)
public FontMetrics getFontMetrics(Font f)
public Color getForeground(AttributeSet a)
public Color getBackground(AttributeSet a)
protected int getCompressionThreshold()
public static StyleContext getDefaultStyleContext()
public AttributeSet addAttribute(AttributeSet old,
Object name,
Object value)
AbstractDocument.AttributeContextAttributeSet that contains the attributes
of old plus the new attribute specified by
name and value.
addAttribute in interface AbstractDocument.AttributeContextold - 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
public AttributeSet addAttributes(AttributeSet old,
AttributeSet attributes)
AbstractDocument.AttributeContextAttributeSet that contains the attributes
of old plus the new attributes in attributes.
addAttributes in interface AbstractDocument.AttributeContextold - the set of attributes where to add the new attributesattributes - the attributes to be added
AttributeSet that contains the attributes
of old plus the new attributes in
attributespublic AttributeSet getEmptySet()
AbstractDocument.AttributeContextAttributeSet.
getEmptySet in interface AbstractDocument.AttributeContextAttributeSetpublic void reclaim(AttributeSet attributes)
AbstractDocument.AttributeContextattributes are
no longer used.
reclaim in interface AbstractDocument.AttributeContextattributes - the attributes are no longer used
public AttributeSet removeAttribute(AttributeSet old,
Object name)
AbstractDocument.AttributeContextAttributeSet that has the attribute with the specified
name removed from old.
removeAttribute in interface AbstractDocument.AttributeContextold - the attribute set from which an attribute is removedname - the name of the attribute to be removed
old minus the attribute
specified by name
public AttributeSet removeAttributes(AttributeSet old,
AttributeSet attributes)
AbstractDocument.AttributeContextattributes from old
and returns the resulting AttributeSet.
removeAttributes in interface AbstractDocument.AttributeContextold - the set of attributes from which to remove attributesattributes - the attributes to be removed from old
old minus the attributes in
attributes
public AttributeSet removeAttributes(AttributeSet old,
Enumeration<?> names)
AbstractDocument.AttributeContextnames from
old and returns the resulting AttributeSet.
removeAttributes in interface AbstractDocument.AttributeContextold - the set of attributes from which to remove attributesnames - the names of the attributes to be removed from
old
old minus the attributes in
attributespublic static Object getStaticAttribute(Object key)
key - - the key that was registered.
public static Object getStaticAttributeKey(Object key)
key - - the key that will be registered.
public static void readAttributeSet(ObjectInputStream in,
MutableAttributeSet a)
throws ClassNotFoundException,
IOException
in - - the stream to read froma - - the set of attributes
ClassNotFoundException - - may be encountered when reading from
stream
IOException - - any I/O error
public static void writeAttributeSet(ObjectOutputStream out,
AttributeSet a)
throws IOException
readAttributeSet(ObjectInputStream, MutableAttributeSet).
In particular registered static keys are transformed properly.
out - - stream to write toa - - the attribute set
IOException - - any I/O error
public void readAttributes(ObjectInputStream in,
MutableAttributeSet a)
throws ClassNotFoundException,
IOException
in - - the stream to read froma - - the set of attributes
ClassNotFoundException - - may be encountered when reading from stream
IOException - - any I/O errorreadAttributeSet(ObjectInputStream, MutableAttributeSet)
public void writeAttributes(ObjectOutputStream out,
AttributeSet a)
throws IOException
out - - stream to write toa - - the attribute set
IOException - - any I/O errorwriteAttributeSet(ObjectOutputStream, AttributeSet)public static void registerStaticAttributeKey(Object key)
StyleContext 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.
key - the key to register as static attribute keypublic String toString()
toString in class ObjectObject.getClass(),
Object.hashCode(),
Class.getName(),
Integer.toHexString(int)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||