001: /*
002: *
003: * @(#)TextAttribute.java 1.7 06/10/03
004: *
005: * Portions Copyright 2000-2006 Sun Microsystems, Inc. All Rights
006: * Reserved. Use is subject to license terms.
007: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
008: *
009: * This program is free software; you can redistribute it and/or
010: * modify it under the terms of the GNU General Public License version
011: * 2 only, as published by the Free Software Foundation.
012: *
013: * This program is distributed in the hope that it will be useful, but
014: * WITHOUT ANY WARRANTY; without even the implied warranty of
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016: * General Public License version 2 for more details (a copy is
017: * included at /legal/license.txt).
018: *
019: * You should have received a copy of the GNU General Public License
020: * version 2 along with this work; if not, write to the Free Software
021: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
022: * 02110-1301 USA
023: *
024: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
025: * Clara, CA 95054 or visit www.sun.com if you need additional
026: * information or have any questions.
027: */
028:
029: /*
030: * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
031: * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
032: *
033: * The original version of this source code and documentation is
034: * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
035: * of IBM. These materials are provided under terms of a License
036: * Agreement between Taligent and Sun. This technology is protected
037: * by multiple US and International patents.
038: *
039: * This notice and attribution to Taligent may not be removed.
040: * Taligent is a registered trademark of Taligent, Inc.
041: *
042: */
043:
044: package java.awt.font;
045:
046: import java.io.InvalidObjectException;
047: import java.text.AttributedCharacterIterator.Attribute;
048: import java.util.Map;
049: import java.util.HashMap;
050:
051: /**
052: * The <code>TextAttribute</code> class defines attribute keys and
053: * attribute values used for text rendering.
054: * <p>
055: * <code>TextAttribute</code> instances are used as attribute keys to
056: * identify attributes in
057: * {@link java.text.AttributedCharacterIterator AttributedCharacterIterator},
058: * {@link java.awt.Font Font}, and other classes handling text
059: * attributes. Other constants defined in this class are used
060: * as attribute values.
061: * <p>
062: * For each text attribute, the documentation describes:
063: * <UL>
064: * <LI>the type of their values,
065: * <LI>the valid values if there are limitations
066: * <LI>relevant constants
067: * <LI>the default effect if the attribute is absent (or has a
068: * <code>null</code> value).
069: * <LI>a description of the effect.
070: * <LI>the fallback behavior if the exact attribute requested is not
071: * available.
072: * </UL>
073: * <p>
074: * <H4>Types of Values</H4>
075: * <UL>
076: * <LI>The values of attributes must always be immutable.
077: * <LI>Where a list of limitations is given, any value outside of that
078: * set is reserved for future use, and ignored at present.
079: * <LI>If the value is <code>null</code> or not of the proper type
080: * then it has the default effect. The effect of a particular value
081: * can be interpolated, especially in the case of multiple master
082: * fonts. This interpolation is done based on the nearest defined
083: * constants above and below the request:<BR>
084: * <BLOCKQUOTE><TT>
085: * interpolation = (request - below)/(above - below);
086: * </TT></BLOCKQUOTE>
087: * </UL>
088: * <p>
089: * <H4>Interpolation</H4>
090: * <UL>
091: * <LI>Fonts should interpolate values in certain circumstances. For example,
092: * when the WEIGHT value is 2.13. If the nearest surrounding values
093: * in the font are WEIGHT_BOLD = 2.0 and WEIGHT_HEAVY = 2.25 then font would
094: * then interpret the WEIGHT request as being 52% of the way between what
095: * it considers BOLD and what it considers HEAVY. If the nearest surrounding
096: * values are WEIGHT_SEMIBOLD = 1.25 and WEIGHT_ULTRABOLD = 2.75 then the
097: * WEIGHT request is interpreted as being 58.67% of the way between SEMIBOLD
098: * and ULTRABOLD.
099: * <LI>Where a font does not have enough capability to handle a given
100: * request, such as superscript, then it should simulate it to the best of
101: * its ability. To determine if simulation is being performed, the client
102: * should query the font to see what actual attributes were used.
103: * </UL>
104: *
105: * @see java.text.AttributedCharacterIterator
106: * @see java.awt.Font
107: */
108: public final class TextAttribute extends Attribute {
109:
110: // table of all instances in this class, used by readResolve
111: private static final Map instanceMap = new HashMap(29);
112:
113: /**
114: * Constructs a <code>TextAttribute</code> with the specified name.
115: * @param name the attribute name to assign to this
116: * <code>TextAttribute</code>
117: */
118: private TextAttribute(String name) {
119: super (name);
120: if (this .getClass() == TextAttribute.class) {
121: instanceMap.put(name, this );
122: }
123: }
124:
125: /**
126: * Resolves instances being deserialized to the predefined constants.
127: */
128: protected Object readResolve() throws InvalidObjectException {
129: if (this .getClass() != TextAttribute.class) {
130: throw new InvalidObjectException(
131: "subclass didn't correctly implement readResolve");
132: }
133:
134: TextAttribute instance = (TextAttribute) instanceMap
135: .get(getName());
136: if (instance != null) {
137: return instance;
138: } else {
139: throw new InvalidObjectException("unknown attribute name");
140: }
141: }
142:
143: // Serialization compatibility with Java 2 platform v1.2.
144: // 1.2 will throw an InvalidObjectException if ever asked to deserialize INPUT_METHOD_UNDERLINE.
145: // This shouldn't happen in real life.
146: static final long serialVersionUID = 7744112784117861702L;
147:
148: //
149: // For use with Font.
150: //
151:
152: /**
153: * Attribute key for the unlocalized font family name.
154: *
155: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
156: * SUMMARY="Key, Value, Constants, Default, and Description
157: * for TextAttribute FAMILY">
158: * <TR>
159: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
160: * <TD VALIGN="TOP">FAMILY</TD></TR>
161: * <TR>
162: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
163: * <TD VALIGN="TOP">String</TD></TR>
164: * <TR>
165: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
166: * <TD VALIGN="TOP">"Serif", "SansSerif"</TD></TR>
167: * <TR>
168: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
169: * <TD VALIGN="TOP">Host default;</TD></TR>
170: * <TR>
171: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
172: * <TD VALIGN="TOP">The name of the font family. If the family name is not
173: * found, the default font is used. The name should not be the full
174: * font name or specify other attributes (such as the name
175: * "Helvetica Bold"). Such names might result in the default
176: * font if the name does not match a known
177: * family name.</TD></TR>
178: * </TABLE>
179: */
180: public static final TextAttribute FAMILY = new TextAttribute(
181: "family");
182:
183: /**
184: * Attribute key for the weight of a font.
185: *
186: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
187: * SUMMARY="Key, Value, Constants, Description, Default,
188: * and Fallback for TextAttribute WEIGHT">
189: * <TR>
190: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
191: * <TD VALIGN="TOP">WEIGHT</TD></TR>
192: * <TR>
193: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
194: * <TD VALIGN="TOP">Float</TD></TR>
195: * <TR>
196: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
197: * <TD VALIGN="TOP">
198: * WEIGHT_EXTRA_LIGHT = 0.5,<BR>
199: * WEIGHT_LIGHT = 0.75,<BR>
200: * WEIGHT_DEMILIGHT = 0.875,<BR>
201: * WEIGHT_REGULAR = 1.0,<BR>
202: * WEIGHT_SEMIBOLD = 1.25,<BR>
203: * WEIGHT_MEDIUM = 1.5,<BR>
204: * WEIGHT_DEMIBOLD = 1.75,<BR>
205: * WEIGHT_BOLD = 2.0,<BR>
206: * WEIGHT_HEAVY = 2.25,<BR>
207: * WEIGHT_EXTRABOLD = 2.5,<BR>
208: * WEIGHT_ULTRABOLD = 2.75</TD></TR>
209: * <TR>
210: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
211: * <TD VALIGN="TOP">WEIGHT_REGULAR</TD></TR>
212: * <TR>
213: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
214: * <TD VALIGN="TOP">The value is roughly the ratio of the stem width to
215: * that of the regular weight. If the font has a different value for
216: * specific constants, then the value is interpolated as described in
217: * the class description.</TD></TR>
218: * <TR>
219: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
220: * <TD VALIGN="TOP">Currently none. However, in the future, shape
221: * manipulations might be<BR> available to simulate weight variations
222: * for fonts that don't have them.</TD></TR>
223: * </TABLE>
224: * <BR>
225: */
226: public static final TextAttribute WEIGHT = new TextAttribute(
227: "weight");
228:
229: /**
230: * The lightest predefined weight.
231: * @see #WEIGHT
232: */
233: public static final Float WEIGHT_EXTRA_LIGHT = new Float(0.5f);
234:
235: /**
236: * The standard light weight.
237: * @see #WEIGHT
238: */
239: public static final Float WEIGHT_LIGHT = new Float(0.75f);
240:
241: /**
242: * An intermediate weight between LIGHT and STANDARD.
243: * @see #WEIGHT
244: */
245: public static final Float WEIGHT_DEMILIGHT = new Float(0.875f);
246:
247: /**
248: * The standard weight. This weight is used if WEIGHT is unspecified.
249: * @see #WEIGHT
250: */
251: public static final Float WEIGHT_REGULAR = new Float(1.0f);
252:
253: /**
254: * A moderately heavier weight than REGULAR.
255: * @see #WEIGHT
256: */
257: public static final Float WEIGHT_SEMIBOLD = new Float(1.25f);
258:
259: /**
260: * An intermediate weight between the REGULAR and BOLD weights.
261: * @see #WEIGHT
262: */
263: public static final Float WEIGHT_MEDIUM = new Float(1.5f);
264:
265: /**
266: * A moderately lighter weight than BOLD.
267: * @see #WEIGHT
268: */
269: public static final Float WEIGHT_DEMIBOLD = new Float(1.75f);
270:
271: /**
272: * The standard bold weight.
273: * @see #WEIGHT
274: */
275: public static final Float WEIGHT_BOLD = new Float(2.0f);
276:
277: /**
278: * A moderately heavier weight than BOLD.
279: * @see #WEIGHT
280: */
281: public static final Float WEIGHT_HEAVY = new Float(2.25f);
282:
283: /**
284: * An extra heavy weight.
285: * @see #WEIGHT
286: */
287: public static final Float WEIGHT_EXTRABOLD = new Float(2.5f);
288:
289: /**
290: * The heaviest predefined weight.
291: * @see #WEIGHT
292: */
293: public static final Float WEIGHT_ULTRABOLD = new Float(2.75f);
294:
295: /**
296: * Attribute key for the width of a font.
297: *
298: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
299: * SUMMARY="Key, Value, Constants, Description, Default,
300: * and Fallback for TextAttribute WIDTH">
301: * <TR>
302: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
303: * <TD VALIGN="TOP">WIDTH</TD></TR>
304: * <TR>
305: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
306: * <TD VALIGN="TOP">Float</TD></TR>
307: * <TR>
308: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
309: * <TD VALIGN="TOP">WIDTH_CONDENSED = 0.75,<BR>
310: * WIDTH_SEMI_CONDENSED = 0.875,<BR>
311: * WIDTH_REGULAR = 1.0,<BR>
312: * WIDTH_SEMI_EXTENDED = 1.25,<BR>
313: * WIDTH_EXTENDED = 1.5</TD></TR>
314: * <TR>
315: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
316: * <TD VALIGN="TOP">WIDTH_REGULAR</TD></TR>
317: * <TR>
318: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
319: * <TD VALIGN="TOP">The value is roughly the ratio of the advance width
320: * to that of the regular width. If the font has a different value for
321: * specific constants, then the value is interpolated as described in
322: * the class description.</TD></TR>
323: * <TR>
324: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
325: * <TD VALIGN="TOP">If a Narrow font is available and matches, use that.
326: * Otherwise scale with a transform based on the value.</TD></TR>
327: * </TABLE>
328: */
329: // public static final TextAttribute WIDTH = new TextAttribute("width");
330: /**
331: * The most condensed predefined width.
332: * @see #WIDTH
333: */
334: // public static final Float WIDTH_CONDENSED = new Float(0.75f);
335: /**
336: * A moderately condensed width.
337: * @see #WIDTH
338: */
339: // public static final Float WIDTH_SEMI_CONDENSED = new Float(0.875f);
340: /**
341: * The standard width. This width is used if WIDTH is unspecified.
342: * @see #WIDTH
343: */
344: // public static final Float WIDTH_REGULAR = new Float(1.0f);
345: /**
346: * A moderately extended width.
347: * @see #WIDTH
348: */
349: // public static final Float WIDTH_SEMI_EXTENDED = new Float(1.25f);
350: /**
351: * The most extended predefined width.
352: * @see #WIDTH
353: */
354: // public static final Float WIDTH_EXTENDED = new Float(1.5f);
355: /**
356: * Attribute key for the posture of a font.
357: *
358: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
359: * SUMMARY="Key, Value, Constants, Default, Description,
360: * and Fallback for TextAttribute POSTURE">
361: * <TR>
362: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
363: * <TD VALIGN="TOP">POSTURE</TD></TR>
364: * <TR>
365: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
366: * <TD VALIGN="TOP">Float</TD></TR>
367: * <TR>
368: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
369: * <TD VALIGN="TOP">POSTURE_REGULAR = 0, <BR>
370: * POSTURE_OBLIQUE = 0.20</TD></TR>
371: * <TR>
372: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
373: * <TD VALIGN="TOP">POSTURE_REGULAR</TD></TR>
374: * <TR>
375: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
376: * <TD VALIGN="TOP">The value is interpreted generally as a skew slope,
377: * positive leans to the right. If the font has a different value for
378: * specific constants, then the value is interpolated as described in
379: * the class description. With fonts that have italic faces, not only
380: * the skew of the character changes, but also the letter shapes
381: * might change.<BR>
382: * <B>Notes: </B><BR>
383: * To set the value by angle, use:<BR>
384: * <TT>value = new Float(Math.tan(Math.PI*degrees/180.0)</TT><BR>
385: * To determine the angle from the value, use:<BR>
386: * <TT>angle = Math.atan(value.floatValue())*180/Math.PI</TT></TD></TR>
387: * <TR>
388: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
389: * <TD VALIGN="TOP">If an Oblique font is available and matches, use that.
390: * Otherwise skew with a transform using the posture value interpreted as
391: * run/rise.</TD></TR>
392: * </TABLE>
393: *
394: * @see java.awt.Font#getItalicAngle()
395: */
396: public static final TextAttribute POSTURE = new TextAttribute(
397: "posture");
398:
399: /**
400: * The standard posture, upright.
401: * @see #POSTURE
402: */
403: public static final Float POSTURE_REGULAR = new Float(0.0f);
404:
405: /**
406: * The standard italic posture.
407: * @see #POSTURE
408: */
409: public static final Float POSTURE_OBLIQUE = new Float(0.20f);
410:
411: /**
412: * Attribute key for the font size.
413: *
414: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
415: * SUMMARY="Key, Value, Default, Description, and Fallback
416: * for TextAttribute SIZE">
417: * <TR>
418: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
419: * <TD VALIGN="TOP">SIZE</TD></TR>
420: * <TR>
421: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
422: * <TD VALIGN="TOP">Float</TD></TR>
423: * <TR>
424: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
425: * <TD VALIGN="TOP">from System Properties</TD></TR>
426: * <TR>
427: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
428: * <TD VALIGN="TOP">Represents point size. Note that the appearance and
429: * metrics of a 12pt font with a 2X transform might be different than
430: * that of a 24 point font with no transform.</TD></TR>
431: * <TR>
432: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
433: * <TD VALIGN="TOP">Scale to provided size.</TD></TR>
434: * </TABLE>
435: */
436: public static final TextAttribute SIZE = new TextAttribute("size");
437:
438: /**
439: * Attribute key for the transform of a font.
440: *
441: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
442: * SUMMARY="Key, Value, Default, and Description for
443: * TextAttribute TRANSFORM">
444: * <TR>
445: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
446: * <TD VALIGN="TOP">TRANSFORM</TD></TR>
447: * <TR>
448: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
449: * <TD VALIGN="TOP">TransformAttribute</TD></TR>
450: * <TR>
451: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
452: * <TD VALIGN="TOP">Identity transform</TD></TR>
453: * <TR>
454: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
455: * <TD VALIGN="TOP"><P>Used to transform glyphs rendered by this font. The
456: * primary intent is to support scaling, skewing, and translation. In
457: * general, large rotations do not produce very useful results. The
458: * transform modifies both the glyph and the advance. The translations
459: * in the transform are interpreted as a ratio of the point size. That
460: * is, with a point size of 12, a translation of 0.5 results in a
461: * movement of 6 points.
462: * <p>
463: * The advance point of the transformed glyph is the transform of the
464: * advance point projected onto the baseline. If the advance ends up
465: * to the left (top) of the glyph origin, the two points are swapped.
466: * <p>
467: * <P><EM>Example one</EM>: The point
468: * size is 20, the original advance is 10.0, and the transform is a 60
469: * degree counterclockwise rotation plus an offset up and to the right
470: * of 0.1, -0.1. The translation results in an offset of <2.0, -2.0>.
471: * The original advance point is <10.0, 0.0>; after the rotation it
472: * is <6.0, -8.0>; when adding the offset this becomes
473: * <8.0,-10.0>, when projecting on the (horizontal) baseline this
474: * becomes the new advance point: <8.0, 0.0>. The advance width is
475: * the distance from the origin to the advance point: 8.0. The rotated
476: * glyph is rendered two points up and to the right of its origin and
477: * rotated. This does not affect the baseline for subsequent
478: * glyphs.</P></TD></TR>
479: * </TABLE>
480: */
481: // public static final TextAttribute TRANSFORM = new TextAttribute("transform");
482: /**
483: * Attribute key for super and subscripting.
484: *
485: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
486: * SUMMARY="Key, Value, Constants, Default, Description,
487: * and Fallback for TextAttribute SUPERSCRIPT">
488: * <TR>
489: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
490: * <TD VALIGN="TOP">SUPERSCRIPT</TD></TR>
491: * <TR>
492: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
493: * <TD VALIGN="TOP">Integer</TD></TR>
494: * <TR>
495: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
496: * <TD VALIGN="TOP">SUPERSCRIPT_NONE = 0,<BR>
497: * SUPERSCRIPT_SUPER = 1,<BR>
498: * SUPERSCRIPT_SUB = -1</TD></TR>
499: * <TR>
500: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
501: * <TD VALIGN="TOP">SUPERSCRIPT_NONE</TD></TR>
502: * <TR>
503: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
504: * <TD VALIGN="TOP">Requests that the font display the characters with
505: * glyphs at a particular superscript level: 0 = none, 1 =
506: * superscript, 2 = superscript of superscript,...-1
507: * = subscript, -2 = subscript of subscript,... Requests that the font
508: * display text using default superscript (or subscript) glyphs and/or
509: * scaling.</TD></TR>
510: * <TR>
511: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
512: * <TD VALIGN="TOP">Use transform with translation of +/-1/2 and scale
513: * of 2/3, progressively for each level. That is, for the transform at
514: * level N (with N != 0):<BR>
515: * <TT>offset = sign(N)*1/2*(2/3)^(abs(N)-1)<BR>
516: * scale = (2/3)^abs(N)</TT></TD></TR>
517: * </TABLE>
518: */
519: // public static final TextAttribute SUPERSCRIPT = new TextAttribute("superscript");
520: /**
521: * Standard superscript.
522: * @see #SUPERSCRIPT
523: */
524: // public static final Integer SUPERSCRIPT_SUPER = new Integer(1);
525: /**
526: * Standard subscript.
527: * @see #SUPERSCRIPT
528: */
529: // public static final Integer SUPERSCRIPT_SUB = new Integer(-1);
530: /**
531: * Attribute key for the font to use to render text.
532: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
533: * SUMMARY="Key, Value, Default, and Description for TextAttribute FONT">
534: * <TR>
535: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
536: * <TD VALIGN="TOP">FONT</TD></TR>
537: * <TR>
538: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
539: * <TD VALIGN="TOP">Font</TD></TR>
540: * <TR>
541: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
542: * <TD VALIGN="TOP">None, perform default resolution</TD></TR>
543: * <TR>
544: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
545: * <TD VALIGN="TOP">A way for users to override the resolution of font
546: * attributes into a <code>Font</code>, or force use of a particular
547: * <code>Font</code> instance.
548: * This also allows users to specify subclasses of <code>Font</code> in
549: * cases where a <code>Font</code> can be subclassed.</TD></TR>
550: * </TABLE>
551: */
552: public static final TextAttribute FONT = new TextAttribute("font");
553:
554: /**
555: * Attribute key for a user_defined glyph to display in the text in lieu
556: * of a character.
557: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
558: * SUMMARY="Key, Value, and Description for TextAttribute CHAR_REPLACEMENT">
559: * <TR>
560: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
561: * <TD VALIGN="TOP">CHAR_REPLACEMENT</TD></TR>
562: * <TR>
563: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
564: * <TD VALIGN="TOP">GraphicAttribute</TD></TR>
565: * <TR>
566: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
567: * <TD VALIGN="TOP">Allows the user to specify an empty position plus
568: * metric information. This method is used to reserve space for a graphic
569: * or other embedded component. Required for
570: * correct BIDI position of 'inline' components within a line. An optional
571: * convenience method allows drawing for simple cases. Follows the
572: * Microsoft model: the character that this is applied to should be
573: * \uFFFC.</TD></TR>
574: * </TABLE>
575: */
576: // public static final TextAttribute CHAR_REPLACEMENT = new TextAttribute("char_replacement");
577: //
578: // Adornments added to text.
579: //
580: /**
581: * Attribute key for the foreground paint
582: * adornment.
583: *
584: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
585: * SUMMARY="Key, Value, Default, and Description of TextAttribute FOREGROUND">
586: * <TR>
587: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
588: * <TD VALIGN="TOP">FOREGROUND</TD></TR>
589: * <TR>
590: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
591: * <TD VALIGN="TOP">Paint</TD></TR>
592: * <TR>
593: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
594: * <TD VALIGN="TOP">Color.black</TD></TR>
595: * <TR>
596: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
597: * <TD VALIGN="TOP">Specify the foreground Paint (or Color) of the text.</TD></TR>
598: * </TABLE>
599: */
600: public static final TextAttribute FOREGROUND = new TextAttribute(
601: "foreground");
602:
603: /**
604: * Attribute key for the background Paint adornment.
605: *
606: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
607: * SUMMARY="Key, Value, Default, and Description of TextAttribute BACKGROUND">
608: * <TR>
609: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
610: * <TD VALIGN="TOP">BACKGROUND</TD></TR>
611: * <TR>
612: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
613: * <TD VALIGN="TOP">Paint</TD></TR>
614: * <TR>
615: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
616: * <TD VALIGN="TOP">null</TD></TR>
617: * <TR>
618: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
619: * <TD VALIGN="TOP">Specify the background Paint (or Color) of the text.</TD></TR>
620: * </TABLE>
621: */
622: // public static final TextAttribute BACKGROUND = new TextAttribute("background");
623: /**
624: * Attribute key for underline adornments.
625: *
626: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
627: * SUMMARY="Key, Value, Constants, Default, Description,
628: * and Fallback for TextAttribute UNDERLINE">
629: * <TR>
630: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
631: * <TD VALIGN="TOP">UNDERLINE</TD></TR>
632: * <TR>
633: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
634: * <TD VALIGN="TOP">Integer</TD></TR>
635: * <TR>
636: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
637: * <TD VALIGN="TOP">UNDERLINE_ON = 0</TD></TR>
638: * <TR>
639: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
640: * <TD VALIGN="TOP">none</TD></TR>
641: * <TR>
642: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
643: * <TD VALIGN="TOP">An embellishment added to the glyphs rendered by a
644: * font.</TD></TR>
645: * <TR>
646: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Fallback</TH>
647: * <TD VALIGN="TOP"></TD></TR>
648: * </TABLE>
649: */
650: public static final TextAttribute UNDERLINE = new TextAttribute(
651: "underline");
652:
653: /**
654: * Standard underline at the roman baseline for roman text, and below
655: * the decenders for other text.
656: *
657: * @see #UNDERLINE
658: */
659: public static final Integer UNDERLINE_ON = new Integer((byte) 0);
660:
661: /**
662: * Attribute key for the strikethrough adornment.
663: *
664: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
665: * SUMMARY="Key, Value, Constants, Default, and Description
666: * for TextAttribute STRIKETHROUGH">
667: * <TR>
668: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
669: * <TD VALIGN="TOP">STRIKETHROUGH</TD></TR>
670: * <TR>
671: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
672: * <TD VALIGN="TOP">Boolean</TD></TR>
673: * <TR>
674: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
675: * <TD VALIGN="TOP">true = on, false = off</TD></TR>
676: * <TR>
677: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
678: * <TD VALIGN="TOP">off</TD></TR>
679: * <TR>
680: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
681: * <TD VALIGN="TOP">An embellishment added to the glyphs rendered by a
682: * font.</TD></TR>
683: * </TABLE>
684: */
685: public static final TextAttribute STRIKETHROUGH = new TextAttribute(
686: "strikethrough");
687:
688: /**
689: * A single strikethrough.
690: *
691: * @see #STRIKETHROUGH
692: */
693: public static final Boolean STRIKETHROUGH_ON = new Boolean(true);
694:
695: //
696: // Attributes use to control layout of text on a line.
697: //
698:
699: /**
700: * Attribute key for the run direction of the line.
701: *
702: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
703: * SUMMARY="Key, Value, Constants, Default, and Description
704: * of TextAttribute RUN_DIRECTION">
705: * <TR>
706: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
707: * <TD VALIGN="TOP">RUN_DIRECTION</TD></TR>
708: * <TR>
709: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
710: * <TD VALIGN="TOP">Boolean</TD></TR>
711: * <TR>
712: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
713: * <TD VALIGN="TOP">RUN_DIRECTION_LTR = true, RUN_DIRECTION_RTL = false
714: * </TD></TR>
715: * <TR>
716: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
717: * <TD VALIGN="TOP">Use the default Unicode base direction from the BIDI
718: * algorithm.</TD></TR>
719: * <TR>
720: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
721: * <TD VALIGN="TOP"><P>Specifies which base run direction to use when
722: * positioning mixed directional runs within a paragraph. If this value is
723: * RUN_DIRECTION_DEFAULT, <code>TextLayout</code> uses the default Unicode
724: * base direction from the BIDI algorithm.</P>
725: * <P><I>This attribute should have the same value over the whole
726: * paragraph.</I></TD></TR>
727: * </TABLE>
728: */
729: // public static final TextAttribute RUN_DIRECTION = new TextAttribute("run_direction");
730: /**
731: * Left-to-right run direction.
732: * @see #RUN_DIRECTION
733: */
734: // public static final Boolean RUN_DIRECTION_LTR = new Boolean(false);
735: /**
736: * Right-to-left run direction.
737: * @see #RUN_DIRECTION
738: */
739: // public static final Boolean RUN_DIRECTION_RTL = new Boolean(true);
740: /**
741: * Attribute key for the embedding level for nested bidirectional runs.
742: *
743: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
744: * SUMMARY="Key, Value, Limits, Default, and Description
745: * of TextAttribute BIDI_EMBEDDING">
746: * <TR>
747: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
748: * <TD VALIGN="TOP">BIDI_EMBEDDING</TD></TR>
749: * <TR>
750: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
751: * <TD VALIGN="TOP">Integer</TD></TR>
752: * <TR>
753: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Limits</TH>
754: * <TD VALIGN="TOP">Positive values 1 through 61 are <I>embedding</I>
755: * levels, negative values<BR> through -61 are <I>override</I> levels
756: * </TD></TR>
757: * <TR>
758: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
759: * <TD VALIGN="TOP">Use standard BIDI to compute levels from formatting
760: * characters in the text.</TD></TR>
761: * <TR>
762: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
763: * <TD VALIGN="TOP">Specifies the bidi embedding level of the character.
764: * When this attribute is present anywhere in a paragraph, then the
765: * Unicode characters RLO, LRO, RLE, LRE, PDF are disregarded in the BIDI
766: * analysis of that paragraph.
767: * See the Unicode Standard v. 2.0, section 3-11.
768: * </TD></TR>
769: * </TABLE>
770: */
771: // public static final TextAttribute BIDI_EMBEDDING = new TextAttribute("bidi_embedding");
772: /**
773: * Attribute key for the justification of a paragraph.
774: *
775: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
776: * SUMMARY="Key, Value, Limits, Default, and Description
777: * of TextAttribute JUSTIFICATION">
778: * <TR>
779: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
780: * <TD VALIGN="TOP">JUSTIFICATION</TD></TR>
781: * <TR>
782: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
783: * <TD VALIGN="TOP">Float</TD></TR>
784: * <TR>
785: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Limits</TH>
786: * <TD VALIGN="TOP">0.0 through1.0</TD></TR>
787: * <TR>
788: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
789: * <TD VALIGN="TOP">1.0</TD></TR>
790: * <TR>
791: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Description</TH>
792: * <TD VALIGN="TOP"><P>Specifies which fraction of the extra space to use
793: * when justification is requested. For example, if the line is 50 points
794: * wide and the margins are 70 points apart, a value of 0.5 means that the
795: * line is padded to reach a width of 60 points.</P>
796: * <P><I>This attribute should have the same value over the whole
797: * paragraph.</I></TD></TR>
798: * </TABLE>
799: */
800: // public static final TextAttribute JUSTIFICATION = new TextAttribute("justification");
801: /**
802: * Justify the line to the full requested width.
803: * @see #JUSTIFICATION
804: */
805: // public static final Float JUSTIFICATION_FULL = new Float(1.0f);
806: /**
807: * Do not allow the line to be justified.
808: * @see #JUSTIFICATION
809: */
810: // public static final Float JUSTIFICATION_NONE = new Float(0.0f);
811: //
812: // For use by input method.
813: //
814: /**
815: * Attribute key for input method highlight styles.
816: * <p>Values are instances of
817: * {@link java.awt.im.InputMethodHighlight InputMethodHighlight}.
818: * These instances should be wrapped in
819: * {@link java.text.Annotation Annotation} instances
820: * if segments need to be highlighted separately.
821: * <p>
822: * Input method highlights are used while text is being composed
823: * using an input method. Text editing components should retain them
824: * even if they generally only deal with unstyled text, and make them
825: * available to the drawing routines.
826: * @see java.awt.im.InputMethodHighlight
827: */
828: public static final TextAttribute INPUT_METHOD_HIGHLIGHT = new TextAttribute(
829: "input method highlight");
830:
831: /**
832: * Attribute key for input method underline adornments.
833: *
834: * <P><TABLE BORDER="0" CELLSPACING="0" CELLPADDING="1"
835: * SUMMARY="Key, Value, Limits, Default and Description
836: * of TextAttribute INPUT_METHOD_UNDERLINE">
837: * <TR>
838: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Key</TH>
839: * <TD VALIGN="TOP">INPUT_METHOD_UNDERLINE</TD></TR>
840: * <TR>
841: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Value</TH>
842: * <TD VALIGN="TOP">Integer</TD></TR>
843: * <TR>
844: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Constants</TH>
845: * <TD VALIGN="TOP">UNDERLINE_LOW_ONE_PIXEL, UNDERLINE_LOW_TWO_PIXEL,
846: * UNDERLINE_LOW_DOTTED, UNDERLINE_LOW_GRAY, UNDERLINE_LOW_DASHED</TD></TR>
847: * <TR>
848: * <TH VALIGN="TOP" ALIGN="RIGHT"><P ALIGN=RIGHT>Default</TH>
849: * <TD VALIGN="TOP">no underline</TD></TR>
850: * </TABLE>
851: * @since 1.3
852: */
853: // public static final TextAttribute INPUT_METHOD_UNDERLINE = new TextAttribute("input method underline");
854: /**
855: * Single pixel solid low underline.
856: * @see #INPUT_METHOD_UNDERLINE
857: * @since 1.3
858: */
859: // public static final Integer UNDERLINE_LOW_ONE_PIXEL = new Integer(1);
860: /**
861: * Double pixel solid low underline.
862: * @see #INPUT_METHOD_UNDERLINE
863: * @since 1.3
864: */
865: // public static final Integer UNDERLINE_LOW_TWO_PIXEL = new Integer(2);
866: /**
867: * Single pixel dotted low underline.
868: * @see #INPUT_METHOD_UNDERLINE
869: * @since 1.3
870: */
871: // public static final Integer UNDERLINE_LOW_DOTTED = new Integer(3);
872: /**
873: * Double pixel gray low underline.
874: * @see #INPUT_METHOD_UNDERLINE
875: * @since 1.3
876: */
877: // public static final Integer UNDERLINE_LOW_GRAY = new Integer(4);
878: /**
879: * Single pixel dashed low underline.
880: * @see #INPUT_METHOD_UNDERLINE
881: * @since 1.3
882: */
883: // public static final Integer UNDERLINE_LOW_DASHED = new Integer(5);
884: /**
885: * Attribute key for swapping foreground and background Paints (or Colors).
886: *
887: * <p>Values are instances of <code>Boolean</code>.
888: * The default is not to swap the foreground and background.
889: * If the foreground and background attributes are both defined,
890: * this causes them to be swapped when rendering text. If either is
891: * defaulted, the exact effect is undefined--generally it will produce
892: * an 'inverted' appearance.
893: */
894: // public static final TextAttribute SWAP_COLORS = new TextAttribute("swap_colors");
895: /** Swap foreground and background. */
896: // public static final Boolean SWAP_COLORS_ON = new Boolean(true);
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 NUMERIC_SHAPING = new TextAttribute("numeric_shaping");
904: }
|