Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Class java.awt.font.TextAttributeSet

java.lang.Object
    |
    +----java.awt.font.TextAttributeSet

public final class TextAttributeSet
extends Object
implements MutableAttributeSet, Serializable
TextAttributeSet provides a simple implementation of MutableAttributeSet.


Field Summary
static String  BACKGROUND
The background color.
static String  BASELINE
Baseline to which to align lines.
static Byte  BASELINE_DEFAULT
The default baseline if BASELINE is unspecified.
static Byte  BASELINE_HANGING
Use a hanging baseline for the line.
static Byte  BASELINE_IDEOGRAPHIC
Use a center baseline for the line.
static String  BASELINE_OFFSETS
Baseline offsets used by a line.
static Byte  BASELINE_ROMAN
Use a roman baseline for the line.
static String  BIDI_EMBEDDING
The embedding level for nested bidirectional runs.
static Integer  BIDI_EMBEDDING_DEFAULT
The default embedding if BIDI_EMBEDDING is unspecified.
static String  EMBEDDED_GRAPHIC
An embedded graphic to display in the text.
static AttributeSet  EMPTY
An empty attribute set, for convenience.
static String  FAMILY
The unlocalized font family name.
static String  FAMILY_ALL
 
static String  FONT
The font to use to render this text.
static String  FOREGROUND
The foreground color.
static String  INPUT_METHOD_SEGMENT
Constant for the attribute "input method segment".
static String  JUSTIFICATION
Justification for the paragraph.
static Float  JUSTIFICATION_DEFAULT
The default justification if JUSTIFICATION is unspecified.
static Float  JUSTIFICATION_FULL
Justify the line to the full requested width.
static Float  JUSTIFICATION_NONE
Do not allow the line to be justified.
static String  LANGUAGE
Constant for the attribute "language".
static String  POSTURE
The posture of the font.
static Float  POSTURE_DEFAULT
The default posture if POSTURE is unspecified.
static Float  POSTURE_ITALIC
The standard italic posture for the font.
static String  READING
Constant for the attribute "reading".
static String  RUN_DIRECTION
The run direction of the line, either left-to-right or right-to-left.
static Boolean  RUN_DIRECTION_DEFAULT
The default direction if RUN_DIRECTION is unspecified.
static Boolean  RUN_DIRECTION_LTR
Left-to-right (top-to-bottom) run direction.
static Boolean  RUN_DIRECTION_RTL
Right-to-left (bottom-to-top) run direction.
static String  SIZE
The font size in points.
static String  STRIKETHROUGH
Adorn the text with strikethrough.
static Boolean  STRIKETHROUGH_DEFAULT
The default strikethrough if STRIKETHROUGH is unspecified, the value is false.
static Boolean  STRIKETHROUGH_ON
A single strikethrough.
static String  SUPERSUBSCRIPT
Super and subscripting.
static float[]  SUPERSUBSCRIPT_DEFAULT
The default supersubscript if SUPERSUBSCRIPT is unspecified.
static float[]  SUPERSUBSCRIPT_DOWN1
Standard subscript.
static float[]  SUPERSUBSCRIPT_UP1
Standard superscript.
static String  SWAP_COLORS
Swap foreground and background colors (for input method use).
static Boolean  SWAP_COLORS_DEFAULT
Default to not swap foreground and background colors.
static Boolean  SWAP_COLORS_OFF
Do not swap foreground and background colors.
static Boolean  SWAP_COLORS_ON
Swap foreground and background colors.
static String  TRANSFORM
The transform of the font.
static String  UNDERLINE
Adorn the text with underlining.
static Byte  UNDERLINE_LOW_DASHED
Single pixel dashed low underline.
static Byte  UNDERLINE_LOW_DOTTED
Single pixel dotted low underline.
static Byte  UNDERLINE_LOW_GRAY
Double pixel gray low underline.
static Byte  UNDERLINE_LOW_ONE_PIXEL
Single pixel solid low underline.
static Byte  UNDERLINE_LOW_TWO_PIXEL
Double pixel solid low underline.
static Byte  UNDERLINE_OFF
No underline.
static Byte  UNDERLINE_ON
Standard underline at the roman baseline for roman text, and below the decenders for other text.
static String  WEIGHT
The weight of the font.
static Float  WEIGHT_BOLD
The bold weight for the font.
static Float  WEIGHT_DEFAULT
The default weight if WEIGHT is unspecified.
static Float  WEIGHT_LIGHT
The light weight for the font.
 

Constructor Summary
 TextAttributeSet()
Construct a new mutable attribute set.
 TextAttributeSet(AttributeSet source)
Construct a new mutable attribute set containing the provided attributes.
 TextAttributeSet(String name, Object value)
Construct a new mutable attribute set containing the provided attribute.
 

Method Summary
void  add(String name, Object value)
Remove any existing attribute with the same name, and add a new attribute with the given name and value.
void  add(AttributeSet attributes)
Remove any existing attributes with the same names, and add the new attributes.
Object  clone()
Return a copy of this attribute set.
boolean  contains(String name, Object value)
Returns true if this set contains this attribute with an equal value, or if the value is null and the attribute is not defined.
boolean  contains(AttributeSet rhs)
Returns true if this set contains all the attributes with equal values.
boolean  equals(Object rhs)
Return true if the argument is an attribute set containing the same attributes as this.
boolean  equals(AttributeSet rhs)
Return true if the argument contains the same attributes as this.
Object  get(String name)
Returns the value of the attribute with this name, or null if the attribute is not defined.
int  getSize()
Returns the number of attributes.
int  hashCode()
Return a hash code.
boolean  isEmpty()
Returns true if the set is empty.
Enumeration  names()
Returns an enumeration over the names of the attributes in the set.
void  remove(String name)
Remove any existing attribute with the given name.
void  remove(Enumeration names)
Remove any existing attributes with the given names.
void  set(AttributeSet attributes)
Removes all attributes, then adds the new attributes.
 
Methods inherited from class java.lang.Object
 clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LANGUAGE

public static final String LANGUAGE
Constant for the attribute "language". The value of this attribute should be an instance of Locale.
See Also:
Locale

READING

public static final String READING
Constant for the attribute "reading". In languages where the written form and the pronunciation of a word are only loosely related (such as Japanese), it is often necessary to store the reading (pronunciation) along with the written form. This is an annotation attribute. The value should be an instance of Annotation holding an instance of String.
See Also:
Annotation, String

INPUT_METHOD_SEGMENT

public static final String INPUT_METHOD_SEGMENT
Constant for the attribute "input method segment". Input methods often break up text into segments, which usually correspond to words. This is an annotation attribute. The value should be an instance of Annotation holding a value of null.
See Also:
String

SWAP_COLORS

public static final String SWAP_COLORS
Swap foreground and background colors (for input method use).

Values are instances of Boolean. The default is not to swap the colors. If the foreground and backround color attributes are both defined, this causes them to be swapped when rendering text. If either is defaulted the exact effect is undefined-- generally it will produce an 'inverted' appearance.


SWAP_COLORS_ON

public static final Boolean SWAP_COLORS_ON
Swap foreground and background colors.

SWAP_COLORS_OFF

public static final Boolean SWAP_COLORS_OFF
Do not swap foreground and background colors.

SWAP_COLORS_DEFAULT

public static final Boolean SWAP_COLORS_DEFAULT
Default to not swap foreground and background colors.

FAMILY

public static final String FAMILY
The unlocalized font family name.

Values are instances of String, e.g. "Serif", "Palatino". The default value is unspecified.


FAMILY_ALL

public static final String FAMILY_ALL

WEIGHT

public static final String WEIGHT
The weight of the font.

Values are instances of Float. The value is between 0.0 and 2.0. This roughly corresponds to the ratio of the stem width to the width of regular characters for this typeface. Lower values are lighter.


WEIGHT_DEFAULT

public static final Float WEIGHT_DEFAULT
The default weight if WEIGHT is unspecified. This value is 1.0.
See Also:
WEIGHT

WEIGHT_BOLD

public static final Float WEIGHT_BOLD
The bold weight for the font. This value is 1.5.
See Also:
WEIGHT

WEIGHT_LIGHT

public static final Float WEIGHT_LIGHT
The light weight for the font. This value is 0.7.
See Also:
WEIGHT

POSTURE

public static final String POSTURE
The posture of the font.

Values are instances of Float. The value is the run/rise, generally between -1.0 and 1.0, where negative values indicate a leftwards slant, positive a rightwards slant, and zero no slant. There is no guarantee, however, that the slope of the text as returned by font will be the same as the posture value.

See Also:
getItalicAngle

POSTURE_DEFAULT

public static final Float POSTURE_DEFAULT
The default posture if POSTURE is unspecified. This value is 0.0.
See Also:
POSTURE

POSTURE_ITALIC

public static final Float POSTURE_ITALIC
The standard italic posture for the font. This value is 0.333.
See Also:
POSTURE

SIZE

public static final String SIZE
The font size in points.

Values are instances of Float. The value can be any positive value, although most fonts will pin to a reasonable range. The default value is unspecified.


TRANSFORM

public static final String TRANSFORM
The transform of the font.

Values are instances of Transform. The default value is 'null', i.e. when not specified the font uses its default transform.


FONT

public static final String FONT
The font to use to render this text.

Values are instances of Font. The default value is 'null', i.e. text layout will try to resolve the font as best it can for the given text.


EMBEDDED_GRAPHIC

public static final String EMBEDDED_GRAPHIC
An embedded graphic to display in the text.

Values are instances of GraphicAttribute. All characters with this attribute appear as the graphic. Usually, the character used to represent embedded graphics is the Unicode Replacement Character, '?'.


BIDI_EMBEDDING

public static final String BIDI_EMBEDDING
The embedding level for nested bidirectional runs.

TextLayout assumes this feature has the same value for all text in a paragraph.

Values are instances of Integer, between 0 and 31 inclusive. Values from 0 to 15 represent embeddings. If bit 4 is set (values from 16 to 31) they represent directional overrides. Even values indicate left-to-right, odd indicate right-to-left. Within an embedding, text assumes a base line direction corresponding to the embedding, and the standard bidirectional properties of the text applies. Within an override, all text flows in the given direction, and the standard bidirectional properties of the text are overridden. See the Unicode Standard v. 2.0, section 3-11.


BIDI_EMBEDDING_DEFAULT

public static final Integer BIDI_EMBEDDING_DEFAULT
The default embedding if BIDI_EMBEDDING is unspecified. This value is 0.
See Also:
BIDI_EMBEDDING

BACKGROUND

public static final String BACKGROUND
The background color.

Values are instances of Color. The default value is 'null', meaning a transparent background.


FOREGROUND

public static final String FOREGROUND
The foreground color.

Values are instances of Color. The default value is 'null', meaning use the current color in the Graphics.


UNDERLINE

public static final String UNDERLINE
Adorn the text with underlining.

Values are instances of Byte. The standard underline is UNDERLINE_ON, the low underlines are for input method highlighting.


UNDERLINE_OFF

public static final Byte UNDERLINE_OFF
No underline.

UNDERLINE_ON

public static final Byte UNDERLINE_ON
Standard underline at the roman baseline for roman text, and below the decenders for other text.

UNDERLINE_LOW_ONE_PIXEL

public static final Byte UNDERLINE_LOW_ONE_PIXEL
Single pixel solid low underline.

UNDERLINE_LOW_TWO_PIXEL

public static final Byte UNDERLINE_LOW_TWO_PIXEL
Double pixel solid low underline.

UNDERLINE_LOW_DOTTED

public static final Byte UNDERLINE_LOW_DOTTED
Single pixel dotted low underline.

UNDERLINE_LOW_GRAY

public static final Byte UNDERLINE_LOW_GRAY
Double pixel gray low underline.

UNDERLINE_LOW_DASHED

public static final Byte UNDERLINE_LOW_DASHED
Single pixel dashed low underline.

STRIKETHROUGH

public static final String STRIKETHROUGH
Adorn the text with strikethrough.

Values are instances of Boolean.


STRIKETHROUGH_DEFAULT

public static final Boolean STRIKETHROUGH_DEFAULT
The default strikethrough if STRIKETHROUGH is unspecified, the value is false.
See Also:
STRIKETHROUGH

STRIKETHROUGH_ON

public static final Boolean STRIKETHROUGH_ON
A single strikethrough. This value is true.
See Also:
STRIKETHROUGH

SUPERSUBSCRIPT

public static final String SUPERSUBSCRIPT
Super and subscripting.

Values are arrays of two floats. The first value is is used to scale the point size, the second computes the offset as a ratio of the point size. For example, when applied to a 12 point font, a value of [.75, -.5] requests a point size of 9, positioned 6 points above the baseline.


SUPERSUBSCRIPT_DEFAULT

public static final float[] SUPERSUBSCRIPT_DEFAULT
The default supersubscript if SUPERSUBSCRIPT is unspecified. This value is [1, 0].
See Also:
SUPERSUBSCRIPT

SUPERSUBSCRIPT_UP1

public static final float[] SUPERSUBSCRIPT_UP1
Standard superscript. This value is [0.75, -0.5].
See Also:
SUPERSUBSCRIPT

SUPERSUBSCRIPT_DOWN1

public static final float[] SUPERSUBSCRIPT_DOWN1
Standard subscript. This value is [0.75, 0.5].
See Also:
SUPERSUBSCRIPT

JUSTIFICATION

public static final String JUSTIFICATION
Justification for the paragraph.

TextLayout assumes this feature has the same value for all text in a paragraph. Value is a float, extracted as a Double. This is a ratio controlling the space adjustment. For example, if a line's natural advance is 50 pixels, and it is asked to justify to a width of 100 pixels, a ratio of 1.0 results in a justified line with an advance of 100 pixels, and a ratio of 0.5 results in a justified line with an advance of 75 pixels.


JUSTIFICATION_DEFAULT

public static final Float JUSTIFICATION_DEFAULT
The default justification if JUSTIFICATION is unspecified. This value is 1.0.
See Also:
JUSTIFICATION

JUSTIFICATION_FULL

public static final Float JUSTIFICATION_FULL
Justify the line to the full requested width. This value is 1.0.
See Also:
JUSTIFICATION

JUSTIFICATION_NONE

public static final Float JUSTIFICATION_NONE
Do not allow the line to be justified. This value is 0.0.
See Also:
JUSTIFICATION

RUN_DIRECTION

public static final String RUN_DIRECTION
The run direction of the line, either left-to-right or right-to-left. On vertical lines, left-to-right means top-to-bottom.

TextLayout assumes this feature has the same value for all text in a paragraph.

Values are instances of boolean.


RUN_DIRECTION_DEFAULT

public static final Boolean RUN_DIRECTION_DEFAULT
The default direction if RUN_DIRECTION is unspecified. This value is false, indicating left-to-right.
See Also:
RUN_DIRECTION

RUN_DIRECTION_LTR

public static final Boolean RUN_DIRECTION_LTR
Left-to-right (top-to-bottom) run direction. This value is false.
See Also:
RUN_DIRECTION

RUN_DIRECTION_RTL

public static final Boolean RUN_DIRECTION_RTL
Right-to-left (bottom-to-top) run direction. This value is true.
See Also:
RUN_DIRECTION

BASELINE

public static final String BASELINE
Baseline to which to align lines.

TextLayout assumes this feature has the same value for all text in a paragraph. Regardless of the baselines to which characters align, the layout as a whole will align to this line.

Values are instances of Integer.

See Also:
ROMAN_BASELINE, CENTER_BASELINE, HANGING_BASELINE, getBaselineOffsetsFor, getBaselineFor

BASELINE_DEFAULT

public static final Byte BASELINE_DEFAULT
The default baseline if BASELINE is unspecified. This value is Font.ROMAN_BASELINE.
See Also:
BASELINE

BASELINE_ROMAN

public static final Byte BASELINE_ROMAN
Use a roman baseline for the line. This value is Font.ROMAN_BASELINE.
See Also:
BASELINE

BASELINE_IDEOGRAPHIC

public static final Byte BASELINE_IDEOGRAPHIC
Use a center baseline for the line. This value is Font.CENTER_BASELINE.
See Also:
BASELINE

BASELINE_HANGING

public static final Byte BASELINE_HANGING
Use a hanging baseline for the line. This value is Font.HANGING_BASELINE.
See Also:
BASELINE

BASELINE_OFFSETS

public static final String BASELINE_OFFSETS
Baseline offsets used by a line.

TextLayout assumes this feature has the same value for all text in a paragraph.

Values are arrays of three floats. The distance from one baseline to another is offsets[b] - offsets[a], where a is the starting baseline. For example, the distance from the hanging baseline to the ideographic baseline is: offsets[BASELINE_IDEOGRAPHIC.byteValue()]- offsets[BASELINE_HANGING.byteValue()]

If defaulted, TextLayout attempts to find a reasonable value for all text in the paragraph.


EMPTY

public static final AttributeSet EMPTY
An empty attribute set, for convenience.
Constructor Detail

TextAttributeSet

public TextAttributeSet()
Construct a new mutable attribute set.

TextAttributeSet

public TextAttributeSet(AttributeSet source)
Construct a new mutable attribute set containing the provided attributes.
Parameters:
source - the attributes to copy into this set.

TextAttributeSet

public TextAttributeSet(String name,
                        Object value)
Construct a new mutable attribute set containing the provided attribute.
Parameters:
name - the name of the attribute.
value - the value of the attribute.
Method Detail

isEmpty

public boolean isEmpty()
Returns true if the set is empty.

getSize

public int getSize()
Returns the number of attributes.

names

public Enumeration names()
Returns an enumeration over the names of the attributes in the set. The elements of the enumeration are all Strings.

get

public Object get(String name)
Returns the value of the attribute with this name, or null if the attribute is not defined.

contains

public boolean contains(String name,
                        Object value)
Returns true if this set contains this attribute with an equal value, or if the value is null and the attribute is not defined.

contains

public boolean contains(AttributeSet rhs)
Returns true if this set contains all the attributes with equal values.

equals

public boolean equals(Object rhs)
Return true if the argument is an attribute set containing the same attributes as this.
Parameters:
rhs - the object which may be an attribute set.
Overrides:
equals in class Object

equals

public boolean equals(AttributeSet rhs)
Return true if the argument contains the same attributes as this.
Parameters:
rhs - the attribute set to test against.

hashCode

public int hashCode()
Return a hash code.
Overrides:
hashCode in class Object

add

public void add(String name,
                Object value)
Remove any existing attribute with the same name, and add a new attribute with the given name and value. The value must be immutable, or not mutated by any client.
Implements:
add in interface MutableAttributeSet
Parameters:
name - the name of the attribute to add
value - the value of the attribute to add

add

public void add(AttributeSet attributes)
Remove any existing attributes with the same names, and add the new attributes.
Implements:
add in interface MutableAttributeSet
Parameters:
attributes - the set of attributes to add

remove

public void remove(String name)
Remove any existing attribute with the given name.
Implements:
remove in interface MutableAttributeSet
Parameters:
name - the name of the attribute to remove

remove

public void remove(Enumeration names)
Remove any existing attributes with the given names.
Implements:
remove in interface MutableAttributeSet
Parameters:
names - an enumeration over the names of attributes to remove. The elements of the enumeration are Strings.

set

public void set(AttributeSet attributes)
Removes all attributes, then adds the new attributes.
Implements:
set in interface MutableAttributeSet

clone

public Object clone()
Return a copy of this attribute set. Attributes are shared with the copy.
Overrides:
clone in class Object

Contents | Package | Class | Tree | Deprecated | Index | Help Java 1.2 Beta 3
PREV | NEXT SHOW LISTS | HIDE LISTS

Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.