KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > awt > font > TextAttribute


1 /*
2  * @(#)TextAttribute.java 1.46 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 /*
9  * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
10  * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
11  *
12  * The original version of this source code and documentation is
13  * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
14  * of IBM. These materials are provided under terms of a License
15  * Agreement between Taligent and Sun. This technology is protected
16  * by multiple US and International patents.
17  *
18  * This notice and attribution to Taligent may not be removed.
19  * Taligent is a registered trademark of Taligent, Inc.
20  *
21  */

22
23 package java.awt.font;
24
25 import java.io.InvalidObjectException JavaDoc;
26 import java.text.AttributedCharacterIterator.Attribute;
27 import java.util.Map JavaDoc;
28 import java.util.HashMap JavaDoc;
29
30 /**
31  * The <code>TextAttribute</code> class defines attribute keys and
32  * attribute values used for text rendering.
33  * <p>
34  * <code>TextAttribute</code> instances are used as attribute keys to
35  * identify attributes in
36  * {@link java.text.AttributedCharacterIterator AttributedCharacterIterator},
37  * {@link java.awt.Font Font}, and other classes handling text
38  * attributes. Other constants defined in this class are used
39  * as attribute values.
40  * <p>
41  * For each text attribute, the documentation describes:
42  * <UL>
43  * <LI>the type of their values,
44  * <LI>the valid values if there are limitations
45  * <LI>relevant constants
46  * <LI>the default effect if the attribute is absent (or has a
47  * <code>null</code> value).
48  * <LI>a description of the effect.
49  * <LI>the fallback behavior if the exact attribute requested is not
50  * available.
51  * </UL>
52  * <p>
53  * <H4>Types of Values</H4>
54  * <UL>
55  * <LI>The values of attributes must always be immutable.
56  * <LI>Where a list of limitations is given, any value outside of that
57  * set is reserved for future use, and ignored at present.
58  * <LI>If the value is <code>null</code> or not of the proper type
59  * then it has the default effect. The effect of a particular value
60  * can be interpolated, especially in the case of multiple master
61  * fonts. This interpolation is done based on the nearest defined
62  * constants above and below the request:<BR>
63  * <BLOCKQUOTE><TT>
64  * interpolation = (request - below)/(above - below);
65  * </TT></BLOCKQUOTE>
66  * </UL>
67  * <p>
68  * <H4>Interpolation</H4>
69  * <UL>
70  * <LI>Fonts should interpolate values in certain circumstances. For example,
71  * when the WEIGHT value is 2.13. If the nearest surrounding values
72  * in the font are WEIGHT_BOLD = 2.0 and WEIGHT_HEAVY = 2.25 then font would
73  * then interpret the WEIGHT request as being 52% of the way between what
74  * it considers BOLD and what it considers HEAVY. If the nearest surrounding
75  * values are WEIGHT_SEMIBOLD = 1.25 and WEIGHT_ULTRABOLD = 2.75 then the
76  * WEIGHT request is interpreted as being 58.67% of the way between SEMIBOLD
77  * and ULTRABOLD.
78  * <LI>Where a font does not have enough capability to handle a given
79  * request, such as superscript, then it should simulate it to the best of
80  * its ability. To determine if simulation is being performed, the client
81  * should query the font to see what actual attributes were used.
82  * </UL>
83  *
84  * @see java.text.AttributedCharacterIterator
85  * @see java.awt.Font
86  */

87 public final class TextAttribute extends Attribute {
88
89     // table of all instances in this class, used by readResolve
90
private static final Map JavaDoc instanceMap = new HashMap JavaDoc(29);
91
92     /**
93      * Constructs a <code>TextAttribute</code> with the specified name.
94      * @param name the attribute name to assign to this
95      * <code>TextAttribute</code>
96      */

97     protected TextAttribute(String JavaDoc name) {
98         super(name);
99         if (this.getClass() == TextAttribute JavaDoc.class) {
100             instanceMap.put(name, this);
101         }
102     }
103
104     /**
105      * Resolves instances being deserialized to the predefined constants.
106      */

107     protected Object JavaDoc readResolve() throws InvalidObjectException JavaDoc {
108         if (this.getClass() != TextAttribute JavaDoc.class) {
109             throw new InvalidObjectException JavaDoc("subclass didn't correctly implement readResolve");
110         }
111         
112         TextAttribute JavaDoc instance = (TextAttribute JavaDoc) instanceMap.get(getName());
113         if (instance != null) {
114             return instance;
115         } else {
116             throw new InvalidObjectException JavaDoc("unknown attribute name");
117         }
118     }
119     
120     // Serialization compatibility with Java 2 platform v1.2.
121
// 1.2 will throw an InvalidObjectException if ever asked to deserialize INPUT_METHOD_UNDERLINE.
122
// This shouldn't happen in real life.
123
static final long serialVersionUID = 7744112784117861702L;
124
125     //
126
// For use with Font.
127
//
128

129     /**
130      * Attribute key for the unlocalized font family name.
131      *
132      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
133      * SUMMARY="Key, Value, Constants, Default, and Description
134      * for TextAttribute FAMILY">
135      * <TR>
136      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
137      * <TD VALIGN="TOP">FAMILY</TD></TR>
138      * <TR>
139      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
140      * <TD VALIGN="TOP">String</TD></TR>
141      * <TR>
142      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
143      * <TD VALIGN="TOP">&quot;Serif&quot;, &quot;SansSerif&quot;</TD></TR>
144      * <TR>
145      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
146      * <TD VALIGN="TOP">Host default;</TD></TR>
147      * <TR>
148      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
149      * <TD VALIGN="TOP">The name of the font family. If the family name is not
150      * found, the default font is used. The name should not be the full
151      * font name or specify other attributes (such as the name
152      * &quot;Helvetica Bold&quot;). Such names might result in the default
153      * font if the name does not match a known
154      * family name.</TD></TR>
155      * </TABLE>
156      */

157     public static final TextAttribute JavaDoc FAMILY = new TextAttribute JavaDoc("family");
158
159     /**
160      * Attribute key for the weight of a font.
161      *
162      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
163      * SUMMARY="Key, Value, Constants, Description, Default,
164      * and Fallback for TextAttribute WEIGHT">
165      * <TR>
166      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
167      * <TD VALIGN="TOP">WEIGHT</TD></TR>
168      * <TR>
169      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
170      * <TD VALIGN="TOP">Float</TD></TR>
171      * <TR>
172      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
173      * <TD VALIGN="TOP">
174      * WEIGHT_EXTRA_LIGHT = 0.5,<BR>
175      * WEIGHT_LIGHT = 0.75,<BR>
176      * WEIGHT_DEMILIGHT = 0.875,<BR>
177      * WEIGHT_REGULAR = 1.0,<BR>
178      * WEIGHT_SEMIBOLD = 1.25,<BR>
179      * WEIGHT_MEDIUM = 1.5,<BR>
180      * WEIGHT_DEMIBOLD = 1.75,<BR>
181      * WEIGHT_BOLD = 2.0,<BR>
182      * WEIGHT_HEAVY = 2.25,<BR>
183      * WEIGHT_EXTRABOLD = 2.5,<BR>
184      * WEIGHT_ULTRABOLD = 2.75</TD></TR>
185      * <TR>
186      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
187      * <TD VALIGN="TOP">WEIGHT_REGULAR</TD></TR>
188      * <TR>
189      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
190      * <TD VALIGN="TOP">The value is roughly the ratio of the stem width to
191      * that of the regular weight. If the font has a different value for
192      * specific constants, then the value is interpolated as described in
193      * the class description.</TD></TR>
194      * <TR>
195      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
196      * <TD VALIGN="TOP">Currently none. However, in the future, shape
197      * manipulations might be<BR> available to simulate weight variations
198      * for fonts that don't have them.</TD></TR>
199      * </TABLE>
200      * <BR>
201      */

202     public static final TextAttribute JavaDoc WEIGHT = new TextAttribute JavaDoc("weight");
203
204     /**
205      * The lightest predefined weight.
206      * @see #WEIGHT
207      */

208     public static final Float JavaDoc WEIGHT_EXTRA_LIGHT = new Float JavaDoc(0.5f);
209
210     /**
211      * The standard light weight.
212      * @see #WEIGHT
213      */

214     public static final Float JavaDoc WEIGHT_LIGHT = new Float JavaDoc(0.75f);
215
216     /**
217      * An intermediate weight between LIGHT and STANDARD.
218      * @see #WEIGHT
219      */

220     public static final Float JavaDoc WEIGHT_DEMILIGHT = new Float JavaDoc(0.875f);
221
222     /**
223      * The standard weight. This weight is used if WEIGHT is unspecified.
224      * @see #WEIGHT
225      */

226     public static final Float JavaDoc WEIGHT_REGULAR = new Float JavaDoc(1.0f);
227
228     /**
229      * A moderately heavier weight than REGULAR.
230      * @see #WEIGHT
231      */

232     public static final Float JavaDoc WEIGHT_SEMIBOLD = new Float JavaDoc(1.25f);
233
234     /**
235      * An intermediate weight between the REGULAR and BOLD weights.
236      * @see #WEIGHT
237      */

238     public static final Float JavaDoc WEIGHT_MEDIUM = new Float JavaDoc(1.5f);
239
240     /**
241      * A moderately lighter weight than BOLD.
242      * @see #WEIGHT
243      */

244     public static final Float JavaDoc WEIGHT_DEMIBOLD = new Float JavaDoc(1.75f);
245
246     /**
247      * The standard bold weight.
248      * @see #WEIGHT
249      */

250     public static final Float JavaDoc WEIGHT_BOLD = new Float JavaDoc(2.0f);
251
252     /**
253      * A moderately heavier weight than BOLD.
254      * @see #WEIGHT
255      */

256     public static final Float JavaDoc WEIGHT_HEAVY = new Float JavaDoc(2.25f);
257
258     /**
259      * An extra heavy weight.
260      * @see #WEIGHT
261      */

262     public static final Float JavaDoc WEIGHT_EXTRABOLD = new Float JavaDoc(2.5f);
263
264     /**
265      * The heaviest predefined weight.
266      * @see #WEIGHT
267      */

268     public static final Float JavaDoc WEIGHT_ULTRABOLD = new Float JavaDoc(2.75f);
269
270     /**
271      * Attribute key for the width of a font.
272      *
273      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
274      * SUMMARY="Key, Value, Constants, Description, Default,
275      * and Fallback for TextAttribute WIDTH">
276      * <TR>
277      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
278      * <TD VALIGN="TOP">WIDTH</TD></TR>
279      * <TR>
280      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
281      * <TD VALIGN="TOP">Float</TD></TR>
282      * <TR>
283      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
284      * <TD VALIGN="TOP">WIDTH_CONDENSED = 0.75,<BR>
285      * WIDTH_SEMI_CONDENSED = 0.875,<BR>
286      * WIDTH_REGULAR = 1.0,<BR>
287      * WIDTH_SEMI_EXTENDED = 1.25,<BR>
288      * WIDTH_EXTENDED = 1.5</TD></TR>
289      * <TR>
290      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
291      * <TD VALIGN="TOP">WIDTH_REGULAR</TD></TR>
292      * <TR>
293      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
294      * <TD VALIGN="TOP">The value is roughly the ratio of the advance width
295      * to that of the regular width. If the font has a different value for
296      * specific constants, then the value is interpolated as described in
297      * the class description.</TD></TR>
298      * <TR>
299      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
300      * <TD VALIGN="TOP">If a Narrow font is available and matches, use that.
301      * Otherwise scale with a transform based on the value.</TD></TR>
302      * </TABLE>
303      */

304     public static final TextAttribute JavaDoc WIDTH = new TextAttribute JavaDoc("width");
305
306     /**
307      * The most condensed predefined width.
308      * @see #WIDTH
309      */

310     public static final Float JavaDoc WIDTH_CONDENSED = new Float JavaDoc(0.75f);
311
312     /**
313      * A moderately condensed width.
314      * @see #WIDTH
315      */

316     public static final Float JavaDoc WIDTH_SEMI_CONDENSED = new Float JavaDoc(0.875f);
317
318     /**
319      * The standard width. This width is used if WIDTH is unspecified.
320      * @see #WIDTH
321      */

322     public static final Float JavaDoc WIDTH_REGULAR = new Float JavaDoc(1.0f);
323
324     /**
325      * A moderately extended width.
326      * @see #WIDTH
327      */

328     public static final Float JavaDoc WIDTH_SEMI_EXTENDED = new Float JavaDoc(1.25f);
329
330     /**
331      * The most extended predefined width.
332      * @see #WIDTH
333      */

334     public static final Float JavaDoc WIDTH_EXTENDED = new Float JavaDoc(1.5f);
335
336     /**
337      * Attribute key for the posture of a font.
338      *
339      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
340      * SUMMARY="Key, Value, Constants, Default, Description,
341      * and Fallback for TextAttribute POSTURE">
342      * <TR>
343      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
344      * <TD VALIGN="TOP">POSTURE</TD></TR>
345      * <TR>
346      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
347      * <TD VALIGN="TOP">Float</TD></TR>
348      * <TR>
349      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
350      * <TD VALIGN="TOP">POSTURE_REGULAR = 0, <BR>
351      * POSTURE_OBLIQUE = 0.20</TD></TR>
352      * <TR>
353      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
354      * <TD VALIGN="TOP">POSTURE_REGULAR</TD></TR>
355      * <TR>
356      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
357      * <TD VALIGN="TOP">The value is interpreted generally as a skew slope,
358      * positive leans to the right. If the font has a different value for
359      * specific constants, then the value is interpolated as described in
360      * the class description. With fonts that have italic faces, not only
361      * the skew of the character changes, but also the letter shapes
362      * might change.<BR>
363      * <B>Notes: </B><BR>
364      * To set the value by angle, use:<BR>
365      * <TT>value = new Float(Math.tan(Math.PI*degrees/180.0)</TT><BR>
366      * To determine the angle from the value, use:<BR>
367      * <TT>angle = Math.atan(value.floatValue())*180/Math.PI</TT></TD></TR>
368      * <TR>
369      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
370      * <TD VALIGN="TOP">If an Oblique font is available and matches, use that.
371      * Otherwise skew with a transform using the posture value interpreted as
372      * run/rise.</TD></TR>
373      * </TABLE>
374      *
375      * @see java.awt.Font#getItalicAngle()
376      */

377     public static final TextAttribute JavaDoc POSTURE = new TextAttribute JavaDoc("posture");
378
379     /**
380      * The standard posture, upright.
381      * @see #POSTURE
382      */

383     public static final Float JavaDoc POSTURE_REGULAR = new Float JavaDoc(0.0f);
384
385     /**
386      * The standard italic posture.
387      * @see #POSTURE
388      */

389     public static final Float JavaDoc POSTURE_OBLIQUE = new Float JavaDoc(0.20f);
390
391     /**
392      * Attribute key for the font size.
393      *
394      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
395      * SUMMARY="Key, Value, Default, Description, and Fallback
396      * for TextAttribute SIZE">
397      * <TR>
398      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
399      * <TD VALIGN="TOP">SIZE</TD></TR>
400      * <TR>
401      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
402      * <TD VALIGN="TOP">Float</TD></TR>
403      * <TR>
404      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
405      * <TD VALIGN="TOP">from System Properties</TD></TR>
406      * <TR>
407      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
408      * <TD VALIGN="TOP">Represents point size. Note that the appearance and
409      * metrics of a 12pt font with a 2X transform might be different than
410      * that of a 24 point font with no transform.</TD></TR>
411      * <TR>
412      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
413      * <TD VALIGN="TOP">Scale to provided size.</TD></TR>
414      * </TABLE>
415      */

416     public static final TextAttribute JavaDoc SIZE = new TextAttribute JavaDoc("size");
417
418     /**
419      * Attribute key for the transform of a font.
420      *
421      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
422      * SUMMARY="Key, Value, Default, and Description for
423      * TextAttribute TRANSFORM">
424      * <TR>
425      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
426      * <TD VALIGN="TOP">TRANSFORM</TD></TR>
427      * <TR>
428      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
429      * <TD VALIGN="TOP">TransformAttribute</TD></TR>
430      * <TR>
431      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
432      * <TD VALIGN="TOP">Identity transform</TD></TR>
433      * <TR>
434      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
435      * <TD VALIGN="TOP"><P>Used to transform glyphs rendered by this font. The
436      * primary intent is to support scaling, skewing, and translation. In
437      * general, large rotations do not produce very useful results. The
438      * transform modifies both the glyph and the advance. The translations
439      * in the transform are interpreted as a ratio of the point size. That
440      * is, with a point size of 12, a translation of 0.5 results in a
441      * movement of 6 points.
442      * <p>
443      * The advance point of the transformed glyph is the transform of the
444      * advance point projected onto the baseline. If the advance ends up
445      * to the left (top) of the glyph origin, the two points are swapped.
446      * <p>
447      * <P><EM>Example one</EM>: The point
448      * size is 20, the original advance is 10.0, and the transform is a 60
449      * degree counterclockwise rotation plus an offset up and to the right
450      * of 0.1, -0.1. The translation results in an offset of &lt;2.0, -2.0&gt;.
451      * The original advance point is &lt;10.0, 0.0&gt;; after the rotation it
452      * is &lt;6.0, -8.0&gt;; when adding the offset this becomes
453      * &lt;8.0,-10.0&gt;, when projecting on the (horizontal) baseline this
454      * becomes the new advance point: &lt;8.0, 0.0&gt;. The advance width is
455      * the distance from the origin to the advance point: 8.0. The rotated
456      * glyph is rendered two points up and to the right of its origin and
457      * rotated. This does not affect the baseline for subsequent
458      * glyphs.</P></TD></TR>
459      * </TABLE>
460      */

461     public static final TextAttribute JavaDoc TRANSFORM = new TextAttribute JavaDoc("transform");
462
463     /**
464      * Attribute key for super and subscripting.
465      *
466      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
467      * SUMMARY="Key, Value, Constants, Default, Description,
468      * and Fallback for TextAttribute SUPERSCRIPT">
469      * <TR>
470      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
471      * <TD VALIGN="TOP">SUPERSCRIPT</TD></TR>
472      * <TR>
473      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
474      * <TD VALIGN="TOP">Integer</TD></TR>
475      * <TR>
476      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
477      * <TD VALIGN="TOP">SUPERSCRIPT_NONE = 0,<BR>
478      * SUPERSCRIPT_SUPER = 1,<BR>
479      * SUPERSCRIPT_SUB = -1</TD></TR>
480      * <TR>
481      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
482      * <TD VALIGN="TOP">SUPERSCRIPT_NONE</TD></TR>
483      * <TR>
484      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
485      * <TD VALIGN="TOP">Requests that the font display the characters with
486      * glyphs at a particular superscript level: 0 = none, 1 =
487      * superscript, 2 = superscript of superscript,...-1
488      * = subscript, -2 = subscript of subscript,... Requests that the font
489      * display text using default superscript (or subscript) glyphs and/or
490      * scaling.</TD></TR>
491      * <TR>
492      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
493      * <TD VALIGN="TOP">Use transform with translation of +/-1/2 and scale
494      * of 2/3, progressively for each level. That is, for the transform at
495      * level N (with N != 0):<BR>
496      * <TT>offset = sign(N)*1/2*(2/3)^(abs(N)-1)<BR>
497      * scale = (2/3)^abs(N)</TT></TD></TR>
498      * </TABLE>
499      */

500     public static final TextAttribute JavaDoc SUPERSCRIPT = new TextAttribute JavaDoc("superscript");
501
502     /**
503      * Standard superscript.
504      * @see #SUPERSCRIPT
505      */

506     public static final Integer JavaDoc SUPERSCRIPT_SUPER = new Integer JavaDoc(1);
507
508     /**
509      * Standard subscript.
510      * @see #SUPERSCRIPT
511      */

512     public static final Integer JavaDoc SUPERSCRIPT_SUB = new Integer JavaDoc(-1);
513
514     /**
515      * Attribute key for the font to use to render text.
516      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
517      * SUMMARY="Key, Value, Default, and Description for TextAttribute FONT">
518      * <TR>
519      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
520      * <TD VALIGN="TOP">FONT</TD></TR>
521      * <TR>
522      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
523      * <TD VALIGN="TOP">Font</TD></TR>
524      * <TR>
525      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
526      * <TD VALIGN="TOP">None, perform default resolution</TD></TR>
527      * <TR>
528      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
529      * <TD VALIGN="TOP">A way for users to override the resolution of font
530      * attributes into a <code>Font</code>, or force use of a particular
531      * <code>Font</code> instance.
532      * This also allows users to specify subclasses of <code>Font</code> in
533      * cases where a <code>Font</code> can be subclassed.</TD></TR>
534      * </TABLE>
535      */

536     public static final TextAttribute JavaDoc FONT = new TextAttribute JavaDoc("font");
537
538     /**
539      * Attribute key for a user_defined glyph to display in the text in lieu
540      * of a character.
541      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
542      * SUMMARY="Key, Value, and Description for TextAttribute CHAR_REPLACEMENT">
543      * <TR>
544      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
545      * <TD VALIGN="TOP">CHAR_REPLACEMENT</TD></TR>
546      * <TR>
547      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
548      * <TD VALIGN="TOP">GraphicAttribute</TD></TR>
549      * <TR>
550      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
551      * <TD VALIGN="TOP">Allows the user to specify an empty position plus
552      * metric information. This method is used to reserve space for a graphic
553      * or other embedded component. Required for
554      * correct BIDI position of 'inline' components within a line. An optional
555      * convenience method allows drawing for simple cases. Follows the
556      * Microsoft model: the character that this is applied to should be
557      * <code>&#92;uFFFC</code>.</TD></TR>
558      * </TABLE>
559      */

560     public static final TextAttribute JavaDoc CHAR_REPLACEMENT = new TextAttribute JavaDoc("char_replacement");
561
562     //
563
// Adornments added to text.
564
//
565

566     /**
567      * Attribute key for the foreground paint
568      * adornment.
569      *
570      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
571      * SUMMARY="Key, Value, Default, and Description of TextAttribute FOREGROUND">
572      * <TR>
573      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
574      * <TD VALIGN="TOP">FOREGROUND</TD></TR>
575      * <TR>
576      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
577      * <TD VALIGN="TOP">Paint</TD></TR>
578      * <TR>
579      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
580      * <TD VALIGN="TOP">Color.black</TD></TR>
581      * <TR>
582      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
583      * <TD VALIGN="TOP">Specify the foreground Paint (or Color) of the text.</TD></TR>
584      * </TABLE>
585      */

586     public static final TextAttribute JavaDoc FOREGROUND = new TextAttribute JavaDoc("foreground");
587
588     /**
589      * Attribute key for the background Paint adornment.
590      *
591      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
592      * SUMMARY="Key, Value, Default, and Description of TextAttribute BACKGROUND">
593      * <TR>
594      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
595      * <TD VALIGN="TOP">BACKGROUND</TD></TR>
596      * <TR>
597      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
598      * <TD VALIGN="TOP">Paint</TD></TR>
599      * <TR>
600      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
601      * <TD VALIGN="TOP">null</TD></TR>
602      * <TR>
603      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
604      * <TD VALIGN="TOP">Specify the background Paint (or Color) of the text.</TD></TR>
605      * </TABLE>
606      */

607     public static final TextAttribute JavaDoc BACKGROUND = new TextAttribute JavaDoc("background");
608
609     /**
610      * Attribute key for underline adornments.
611      *
612      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
613      * SUMMARY="Key, Value, Constants, Default, Description,
614      * and Fallback for TextAttribute UNDERLINE">
615      * <TR>
616      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
617      * <TD VALIGN="TOP">UNDERLINE</TD></TR>
618      * <TR>
619      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
620      * <TD VALIGN="TOP">Integer</TD></TR>
621      * <TR>
622      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
623      * <TD VALIGN="TOP">UNDERLINE_ON = 0</TD></TR>
624      * <TR>
625      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
626      * <TD VALIGN="TOP">none</TD></TR>
627      * <TR>
628      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
629      * <TD VALIGN="TOP">An embellishment added to the glyphs rendered by a
630      * font.</TD></TR>
631      * <TR>
632      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
633      * <TD VALIGN="TOP"></TD></TR>
634      * </TABLE>
635      */

636     public static final TextAttribute JavaDoc UNDERLINE = new TextAttribute JavaDoc("underline");
637
638     /**
639      * Standard underline at the roman baseline for roman text, and below
640      * the decenders for other text.
641      *
642      * @see #UNDERLINE
643      */

644     public static final Integer JavaDoc UNDERLINE_ON = new Integer JavaDoc((byte)0);
645
646     /**
647      * Attribute key for the strikethrough adornment.
648      *
649      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
650      * SUMMARY="Key, Value, Constants, Default, and Description
651      * for TextAttribute STRIKETHROUGH">
652      * <TR>
653      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
654      * <TD VALIGN="TOP">STRIKETHROUGH</TD></TR>
655      * <TR>
656      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
657      * <TD VALIGN="TOP">Boolean</TD></TR>
658      * <TR>
659      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
660      * <TD VALIGN="TOP">true = on, false = off</TD></TR>
661      * <TR>
662      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
663      * <TD VALIGN="TOP">off</TD></TR>
664      * <TR>
665      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
666      * <TD VALIGN="TOP">An embellishment added to the glyphs rendered by a
667      * font.</TD></TR>
668      * </TABLE>
669      */

670     public static final TextAttribute JavaDoc STRIKETHROUGH = new TextAttribute JavaDoc("strikethrough");
671
672     /**
673      * A single strikethrough.
674      *
675      * @see #STRIKETHROUGH
676      */

677     public static final Boolean JavaDoc STRIKETHROUGH_ON = new Boolean JavaDoc(true);
678
679     //
680
// Attributes use to control layout of text on a line.
681
//
682

683     /**
684      * Attribute key for the run direction of the line.
685      *
686      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
687      * SUMMARY="Key, Value, Constants, Default, and Description
688      * of TextAttribute RUN_DIRECTION">
689      * <TR>
690      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
691      * <TD VALIGN="TOP">RUN_DIRECTION</TD></TR>
692      * <TR>
693      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
694      * <TD VALIGN="TOP">Boolean</TD></TR>
695      * <TR>
696      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
697      * <TD VALIGN="TOP">RUN_DIRECTION_LTR = true, RUN_DIRECTION_RTL = false
698      * </TD></TR>
699      * <TR>
700      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
701      * <TD VALIGN="TOP">Use the default Unicode base direction from the BIDI
702      * algorithm.</TD></TR>
703      * <TR>
704      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
705      * <TD VALIGN="TOP"><P>Specifies which base run direction to use when
706      * positioning mixed directional runs within a paragraph. If this value is
707      * RUN_DIRECTION_DEFAULT, <code>TextLayout</code> uses the default Unicode
708      * base direction from the BIDI algorithm.</P>
709      * <P><I>This attribute should have the same value over the whole
710      * paragraph.</I></TD></TR>
711      * </TABLE>
712      */

713     public static final TextAttribute JavaDoc RUN_DIRECTION = new TextAttribute JavaDoc("run_direction");
714
715     /**
716      * Left-to-right run direction.
717      * @see #RUN_DIRECTION
718      */

719     public static final Boolean JavaDoc RUN_DIRECTION_LTR = new Boolean JavaDoc(false);
720
721     /**
722      * Right-to-left run direction.
723      * @see #RUN_DIRECTION
724      */

725     public static final Boolean JavaDoc RUN_DIRECTION_RTL = new Boolean JavaDoc(true);
726
727     /**
728      * Attribute key for the embedding level for nested bidirectional runs.
729      *
730      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
731      * SUMMARY="Key, Value, Limits, Default, and Description
732      * of TextAttribute BIDI_EMBEDDING">
733      * <TR>
734      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
735      * <TD VALIGN="TOP">BIDI_EMBEDDING</TD></TR>
736      * <TR>
737      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
738      * <TD VALIGN="TOP">Integer</TD></TR>
739      * <TR>
740      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Limits</TH>
741      * <TD VALIGN="TOP">Positive values 1 through 61 are <I>embedding</I>
742      * levels, negative values<BR> through -61 are <I>override</I> levels
743      * </TD></TR>
744      * <TR>
745      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
746      * <TD VALIGN="TOP">Use standard BIDI to compute levels from formatting
747      * characters in the text.</TD></TR>
748      * <TR>
749      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
750      * <TD VALIGN="TOP">Specifies the bidi embedding level of the character.
751      * When this attribute is present anywhere in a paragraph, then the
752      * Unicode characters RLO, LRO, RLE, LRE, PDF are disregarded in the BIDI
753      * analysis of that paragraph.
754      * See the Unicode Standard v. 2.0, section 3-11.
755      * </TD></TR>
756      * </TABLE>
757      */

758     public static final TextAttribute JavaDoc BIDI_EMBEDDING = new TextAttribute JavaDoc("bidi_embedding");
759
760     /**
761      * Attribute key for the justification of a paragraph.
762      *
763      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
764      * SUMMARY="Key, Value, Limits, Default, and Description
765      * of TextAttribute JUSTIFICATION">
766      * <TR>
767      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
768      * <TD VALIGN="TOP">JUSTIFICATION</TD></TR>
769      * <TR>
770      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
771      * <TD VALIGN="TOP">Float</TD></TR>
772      * <TR>
773      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Limits</TH>
774      * <TD VALIGN="TOP">0.0 through1.0</TD></TR>
775      * <TR>
776      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
777      * <TD VALIGN="TOP">1.0</TD></TR>
778      * <TR>
779      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
780      * <TD VALIGN="TOP"><P>Specifies which fraction of the extra space to use
781      * when justification is requested. For example, if the line is 50 points
782      * wide and the margins are 70 points apart, a value of 0.5 means that the
783      * line is padded to reach a width of 60 points.</P>
784      * <P><I>This attribute should have the same value over the whole
785      * paragraph.</I></TD></TR>
786      * </TABLE>
787      */

788     public static final TextAttribute JavaDoc JUSTIFICATION = new TextAttribute JavaDoc("justification");
789
790     /**
791      * Justify the line to the full requested width.
792      * @see #JUSTIFICATION
793      */

794     public static final Float JavaDoc JUSTIFICATION_FULL = new Float JavaDoc(1.0f);
795
796     /**
797      * Do not allow the line to be justified.
798      * @see #JUSTIFICATION
799      */

800     public static final Float JavaDoc JUSTIFICATION_NONE = new Float JavaDoc(0.0f);
801
802     //
803
// For use by input method.
804
//
805

806     /**
807      * Attribute key for input method highlight styles.
808      * <p>Values are instances of
809      * {@link java.awt.im.InputMethodHighlight InputMethodHighlight}.
810      * These instances should be wrapped in
811      * {@link java.text.Annotation Annotation} instances
812      * if segments need to be highlighted separately.
813      * <p>
814      * Input method highlights are used while text is being composed
815      * using an input method. Text editing components should retain them
816      * even if they generally only deal with unstyled text, and make them
817      * available to the drawing routines.
818      * @see java.awt.im.InputMethodHighlight
819      */

820     public static final TextAttribute JavaDoc INPUT_METHOD_HIGHLIGHT = new TextAttribute JavaDoc("input method highlight");
821
822     /**
823      * Attribute key for input method underline adornments.
824      *
825      * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
826      * SUMMARY="Key, Value, Limits, Default and Description
827      * of TextAttribute INPUT_METHOD_UNDERLINE">
828      * <TR>
829      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
830      * <TD VALIGN="TOP">INPUT_METHOD_UNDERLINE</TD></TR>
831      * <TR>
832      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
833      * <TD VALIGN="TOP">Integer</TD></TR>
834      * <TR>
835      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
836      * <TD VALIGN="TOP">UNDERLINE_LOW_ONE_PIXEL, UNDERLINE_LOW_TWO_PIXEL,
837      * UNDERLINE_LOW_DOTTED, UNDERLINE_LOW_GRAY, UNDERLINE_LOW_DASHED</TD></TR>
838      * <TR>
839      * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
840      * <TD VALIGN="TOP">no underline</TD></TR>
841      * </TABLE>
842      * @since 1.3
843      */

844     public static final TextAttribute JavaDoc INPUT_METHOD_UNDERLINE
845                  = new TextAttribute JavaDoc("input method underline");
846
847     /**
848      * Single pixel solid low underline.
849      * @see #INPUT_METHOD_UNDERLINE
850      * @since 1.3
851      */

852     public static final Integer JavaDoc UNDERLINE_LOW_ONE_PIXEL = new Integer JavaDoc(1);
853
854     /**
855      * Double pixel solid low underline.
856      * @see #INPUT_METHOD_UNDERLINE
857      * @since 1.3
858      */

859     public static final Integer JavaDoc UNDERLINE_LOW_TWO_PIXEL = new Integer JavaDoc(2);
860
861     /**
862      * Single pixel dotted low underline.
863      * @see #INPUT_METHOD_UNDERLINE
864      * @since 1.3
865      */

866     public static final Integer JavaDoc UNDERLINE_LOW_DOTTED = new Integer JavaDoc(3);
867
868     /**
869      * Double pixel gray low underline.
870      * @see #INPUT_METHOD_UNDERLINE
871      * @since 1.3
872      */

873     public static final Integer JavaDoc UNDERLINE_LOW_GRAY = new Integer JavaDoc(4);
874
875     /**
876      * Single pixel dashed low underline.
877      * @see #INPUT_METHOD_UNDERLINE
878      * @since 1.3
879      */

880     public static final Integer JavaDoc UNDERLINE_LOW_DASHED = new Integer JavaDoc(5);
881
882     /**
883      * Attribute key for swapping foreground and background Paints (or Colors).
884      *
885      * <p>Values are instances of <code>Boolean</code>.
886      * The default is not to swap the foreground and background.
887      * If the foreground and background attributes are both defined,
888      * this causes them to be swapped when rendering text. If either is
889      * defaulted, the exact effect is undefined--generally it will produce
890      * an 'inverted' appearance.
891      */

892     public static final TextAttribute JavaDoc SWAP_COLORS = new TextAttribute JavaDoc("swap_colors");
893
894     /** Swap foreground and background. */
895     public static final Boolean JavaDoc SWAP_COLORS_ON = new Boolean JavaDoc(true);
896
897     /**
898      * Attribute key for converting ASCII decimal digits to other decimal ranges.
899      *
900      * <p>Values are instances of <code>NumericShaping</code>.
901      * The default is not to perform numeric shaping.
902      */

903     public static final TextAttribute JavaDoc NUMERIC_SHAPING = new TextAttribute JavaDoc("numeric_shaping");
904 }
905
Popular Tags