Reset branch to trunk.
[official-gcc.git] / trunk / libjava / classpath / javax / swing / text / StyleConstants.java
blob4e5005c6bb232cb7da6663d81f3dc72a043994a3
1 /* StyleConstants.java --
2 Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package javax.swing.text;
41 import java.awt.Color;
42 import java.awt.Component;
43 import java.util.ArrayList;
45 import javax.swing.Icon;
47 /**
48 * Represents standard attribute keys. This class also contains a set of
49 * useful static utility methods for querying and populating an
50 * {@link AttributeSet}.
52 * @since 1.2
54 public class StyleConstants
56 /**
57 * A value representing left alignment for the
58 * {@link ParagraphConstants#Alignment} attribute.
60 public static final int ALIGN_LEFT = 0;
62 /**
63 * A value representing center alignment for the
64 * {@link ParagraphConstants#Alignment} attribute.
66 public static final int ALIGN_CENTER = 1;
68 /**
69 * A value representing right alignment for the
70 * {@link ParagraphConstants#Alignment} attribute.
72 public static final int ALIGN_RIGHT = 2;
74 /**
75 * A value representing ful justification for the
76 * {@link ParagraphConstants#Alignment} attribute.
78 public static final int ALIGN_JUSTIFIED = 3;
80 /** An alias for {@link CharacterConstants#Background}. */
81 public static final Object Background = CharacterConstants.Background;
83 /** An alias for {@link CharacterConstants#BidiLevel}. */
84 public static final Object BidiLevel = CharacterConstants.BidiLevel;
86 /** An alias for {@link CharacterConstants#Bold}. */
87 public static final Object Bold = CharacterConstants.Bold;
89 /** An alias for {@link CharacterConstants#ComponentAttribute}. */
90 public static final Object ComponentAttribute
91 = CharacterConstants.ComponentAttribute;
93 /** An alias for {@link CharacterConstants#Family}. */
94 public static final Object Family = CharacterConstants.Family;
96 /** An alias for {@link CharacterConstants#Family}. */
97 public static final Object FontFamily = CharacterConstants.Family;
99 /** An alias for {@link CharacterConstants#Size}. */
100 public static final Object FontSize = CharacterConstants.Size;
102 /** An alias for {@link CharacterConstants#Foreground}. */
103 public static final Object Foreground = CharacterConstants.Foreground;
105 /** An alias for {@link CharacterConstants#IconAttribute}. */
106 public static final Object IconAttribute = CharacterConstants.IconAttribute;
108 /** An alias for {@link CharacterConstants#Italic}. */
109 public static final Object Italic = CharacterConstants.Italic;
111 /** An alias for {@link CharacterConstants#Size}. */
112 public static final Object Size = CharacterConstants.Size;
114 /** An alias for {@link CharacterConstants#StrikeThrough}. */
115 public static final Object StrikeThrough = CharacterConstants.StrikeThrough;
117 /** An alias for {@link CharacterConstants#Subscript}. */
118 public static final Object Subscript = CharacterConstants.Subscript;
120 /** An alias for {@link CharacterConstants#Superscript}. */
121 public static final Object Superscript = CharacterConstants.Superscript;
123 /** An alias for {@link CharacterConstants#Underline}. */
124 public static final Object Underline = CharacterConstants.Underline;
126 /** An alias for {@link ParagraphConstants#Alignment}. */
127 public static final Object Alignment = ParagraphConstants.Alignment;
129 /** An alias for {@link ParagraphConstants#FirstLineIndent}. */
130 public static final Object FirstLineIndent
131 = ParagraphConstants.FirstLineIndent;
133 /** An alias for {@link ParagraphConstants#LeftIndent}. */
134 public static final Object LeftIndent = ParagraphConstants.LeftIndent;
136 /** An alias for {@link ParagraphConstants#LineSpacing}. */
137 public static final Object LineSpacing = ParagraphConstants.LineSpacing;
139 /** An alias for {@link ParagraphConstants#Orientation}. */
140 public static final Object Orientation = ParagraphConstants.Orientation;
142 /** An alias for {@link ParagraphConstants#RightIndent}. */
143 public static final Object RightIndent = ParagraphConstants.RightIndent;
145 /** An alias for {@link ParagraphConstants#SpaceAbove}. */
146 public static final Object SpaceAbove = ParagraphConstants.SpaceAbove;
148 /** An alias for {@link ParagraphConstants#SpaceBelow}. */
149 public static final Object SpaceBelow = ParagraphConstants.SpaceBelow;
151 /** An alias for {@link ParagraphConstants#TabSet}. */
152 public static final Object TabSet = ParagraphConstants.TabSet;
154 public static final String ComponentElementName = "component";
156 public static final String IconElementName = "icon";
158 public static final Object ComposedTextAttribute
159 = new StyleConstants("composed text");
161 public static final Object ModelAttribute = new StyleConstants("model");
163 public static final Object NameAttribute = new StyleConstants("name");
165 public static final Object ResolveAttribute = new StyleConstants("resolver");
168 * All StyleConstants keys. This is used in StyleContext to register
169 * all known keys as static attribute keys for serialization.
171 static ArrayList keys;
173 String keyname;
175 // Package-private to avoid accessor constructor for use by
176 // subclasses.
177 StyleConstants(String k)
179 keyname = k;
180 if (keys == null)
181 keys = new ArrayList();
182 keys.add(this);
186 * Returns a string representation of the attribute key.
188 * @return A string representation of the attribute key.
190 public String toString()
192 return keyname;
196 * Returns the alignment specified in the given attributes, or
197 * {@link #ALIGN_LEFT} if no alignment is specified.
199 * @param a the attribute set (<code>null</code> not permitted).
201 * @return The alignment (typically one of {@link #ALIGN_LEFT},
202 * {@link #ALIGN_RIGHT}, {@link #ALIGN_CENTER} or
203 * {@link #ALIGN_JUSTIFIED}).
205 * @see #setAlignment(MutableAttributeSet, int)
207 public static int getAlignment(AttributeSet a)
209 Integer i = (Integer) a.getAttribute(Alignment);
210 if (i != null)
211 return i.intValue();
212 else
213 return ALIGN_LEFT;
217 * Returns the background color specified in the given attributes, or
218 * {@link Color#BLACK} if no background color is specified.
220 * @param a the attribute set (<code>null</code> not permitted).
222 * @return The background color.
224 * @see #setBackground(MutableAttributeSet, Color)
226 public static Color getBackground(AttributeSet a)
228 Color c = (Color) a.getAttribute(Background);
229 if (c != null)
230 return c;
231 else
232 return Color.BLACK;
236 * Returns the bidi level specified in the given attributes, or
237 * <code>0</code> if no bidi level is specified.
239 * @param a the attribute set (<code>null</code> not permitted).
241 * @return The bidi level.
243 * @see #setBidiLevel(MutableAttributeSet, int)
245 public static int getBidiLevel(AttributeSet a)
247 Integer i = (Integer) a.getAttribute(BidiLevel);
248 if (i != null)
249 return i.intValue();
250 else
251 return 0;
255 * Returns the component specified in the given attributes, or
256 * <code>null</code> if no component is specified.
258 * @param a the attribute set (<code>null</code> not permitted).
260 * @return The component (possibly <code>null</code>).
262 * @see #setComponent(MutableAttributeSet, Component)
264 public static Component getComponent(AttributeSet a)
266 Component c = (Component) a.getAttribute(ComponentAttribute);
267 if (c != null)
268 return c;
269 else
270 return null;
274 * Returns the indentation specified in the given attributes, or
275 * <code>0.0f</code> if no indentation is specified.
277 * @param a the attribute set (<code>null</code> not permitted).
279 * @return The indentation.
281 * @see #setFirstLineIndent(MutableAttributeSet, float)
283 public static float getFirstLineIndent(AttributeSet a)
285 Float f = (Float) a.getAttribute(FirstLineIndent);
286 if (f != null)
287 return f.floatValue();
288 else
289 return 0.0f;
293 * Returns the font family specified in the given attributes, or
294 * <code>Monospaced</code> if no font family is specified.
296 * @param a the attribute set (<code>null</code> not permitted).
298 * @return The font family.
300 * @see #setFontFamily(MutableAttributeSet, String)
302 public static String getFontFamily(AttributeSet a)
304 String ff = (String) a.getAttribute(FontFamily);
305 if (ff != null)
306 return ff;
307 else
308 return "Monospaced";
312 * Returns the font size specified in the given attributes, or
313 * <code>12</code> if no font size is specified.
315 * @param a the attribute set (<code>null</code> not permitted).
317 * @return The font size.
319 * @see #setFontSize(MutableAttributeSet, int)
321 public static int getFontSize(AttributeSet a)
323 Integer i = (Integer) a.getAttribute(FontSize);
324 if (i != null)
325 return i.intValue();
326 else
327 return 12;
331 * Returns the foreground color specified in the given attributes, or
332 * {@link Color#BLACK} if no foreground color is specified.
334 * @param a the attribute set (<code>null</code> not permitted).
336 * @return The foreground color.
338 * @see #setForeground(MutableAttributeSet, Color)
340 public static Color getForeground(AttributeSet a)
342 Color c = (Color) a.getAttribute(Foreground);
343 if (c != null)
344 return c;
345 else
346 return Color.BLACK;
350 * Returns the icon specified in the given attributes, or
351 * <code>null</code> if no icon is specified.
353 * @param a the attribute set (<code>null</code> not permitted).
355 * @return The icon (possibly <code>null</code>).
357 * @see #setIcon(MutableAttributeSet, Icon)
359 public static Icon getIcon(AttributeSet a)
361 return (Icon) a.getAttribute(IconAttribute);
365 * Returns the left indentation specified in the given attributes, or
366 * <code>0.0f</code> if no left indentation is specified.
368 * @param a the attribute set (<code>null</code> not permitted).
370 * @return The left indentation.
372 * @see #setLeftIndent(MutableAttributeSet, float)
374 public static float getLeftIndent(AttributeSet a)
376 Float f = (Float) a.getAttribute(LeftIndent);
377 if (f != null)
378 return f.floatValue();
379 else
380 return 0.0f;
384 * Returns the line spacing specified in the given attributes, or
385 * <code>0.0f</code> if no line spacing is specified.
387 * @param a the attribute set (<code>null</code> not permitted).
389 * @return The line spacing.
391 * @see #setLineSpacing(MutableAttributeSet, float)
393 public static float getLineSpacing(AttributeSet a)
395 Float f = (Float) a.getAttribute(LineSpacing);
396 if (f != null)
397 return f.floatValue();
398 else
399 return 0.0f;
403 * Returns the right indentation specified in the given attributes, or
404 * <code>0.0f</code> if no right indentation is specified.
406 * @param a the attribute set (<code>null</code> not permitted).
408 * @return The right indentation.
410 * @see #setRightIndent(MutableAttributeSet, float)
412 public static float getRightIndent(AttributeSet a)
414 Float f = (Float) a.getAttribute(RightIndent);
415 if (f != null)
416 return f.floatValue();
417 else
418 return 0.0f;
422 * Returns the 'space above' specified in the given attributes, or
423 * <code>0.0f</code> if no 'space above' is specified.
425 * @param a the attribute set (<code>null</code> not permitted).
427 * @return The 'space above'.
429 * @see #setSpaceAbove(MutableAttributeSet, float)
431 public static float getSpaceAbove(AttributeSet a)
433 Float f = (Float) a.getAttribute(SpaceAbove);
434 if (f != null)
435 return f.floatValue();
436 else
437 return 0.0f;
441 * Returns the 'space below' specified in the given attributes, or
442 * <code>0.0f</code> if no 'space below' is specified.
444 * @param a the attribute set (<code>null</code> not permitted).
446 * @return The 'space below'.
448 * @see #setSpaceBelow(MutableAttributeSet, float)
450 public static float getSpaceBelow(AttributeSet a)
452 Float f = (Float) a.getAttribute(SpaceBelow);
453 if (f != null)
454 return f.floatValue();
455 else
456 return 0.0f;
460 * Returns the tab set specified in the given attributes, or
461 * <code>null</code> if no tab set is specified.
463 * @param a the attribute set (<code>null</code> not permitted).
465 * @return The tab set.
467 * @see #setTabSet(MutableAttributeSet, javax.swing.text.TabSet)
469 public static javax.swing.text.TabSet getTabSet(AttributeSet a)
471 // I'm guessing that the fully qualified class name is to differentiate
472 // between the TabSet class and the TabSet (attribute) instance on some
473 // compiler...
474 return (javax.swing.text.TabSet) a.getAttribute(StyleConstants.TabSet);
478 * Returns the value of the bold flag in the given attributes, or
479 * <code>false</code> if no bold flag is specified.
481 * @param a the attribute set (<code>null</code> not permitted).
483 * @return The bold flag.
485 * @see #setBold(MutableAttributeSet, boolean)
487 public static boolean isBold(AttributeSet a)
489 Boolean b = (Boolean) a.getAttribute(Bold);
490 if (b != null)
491 return b.booleanValue();
492 else
493 return false;
497 * Returns the value of the italic flag in the given attributes, or
498 * <code>false</code> if no italic flag is specified.
500 * @param a the attribute set (<code>null</code> not permitted).
502 * @return The italic flag.
504 * @see #setItalic(MutableAttributeSet, boolean)
506 public static boolean isItalic(AttributeSet a)
508 Boolean b = (Boolean) a.getAttribute(Italic);
509 if (b != null)
510 return b.booleanValue();
511 else
512 return false;
516 * Returns the value of the strike-through flag in the given attributes, or
517 * <code>false</code> if no strike-through flag is specified.
519 * @param a the attribute set (<code>null</code> not permitted).
521 * @return The strike-through flag.
523 * @see #setStrikeThrough(MutableAttributeSet, boolean)
525 public static boolean isStrikeThrough(AttributeSet a)
527 Boolean b = (Boolean) a.getAttribute(StrikeThrough);
528 if (b != null)
529 return b.booleanValue();
530 else
531 return false;
535 * Returns the value of the subscript flag in the given attributes, or
536 * <code>false</code> if no subscript flag is specified.
538 * @param a the attribute set (<code>null</code> not permitted).
540 * @return The subscript flag.
542 * @see #setSubscript(MutableAttributeSet, boolean)
544 public static boolean isSubscript(AttributeSet a)
546 Boolean b = (Boolean) a.getAttribute(Subscript);
547 if (b != null)
548 return b.booleanValue();
549 else
550 return false;
554 * Returns the value of the superscript flag in the given attributes, or
555 * <code>false</code> if no superscript flag is specified.
557 * @param a the attribute set (<code>null</code> not permitted).
559 * @return The superscript flag.
561 * @see #setSuperscript(MutableAttributeSet, boolean)
563 public static boolean isSuperscript(AttributeSet a)
565 Boolean b = (Boolean) a.getAttribute(Superscript);
566 if (b != null)
567 return b.booleanValue();
568 else
569 return false;
573 * Returns the value of the underline flag in the given attributes, or
574 * <code>false</code> if no underline flag is specified.
576 * @param a the attribute set (<code>null</code> not permitted).
578 * @return The underline flag.
580 * @see #setUnderline(MutableAttributeSet, boolean)
582 public static boolean isUnderline(AttributeSet a)
584 Boolean b = (Boolean) a.getAttribute(Underline);
585 if (b != null)
586 return b.booleanValue();
587 else
588 return false;
592 * Adds an alignment attribute to the specified set.
594 * @param a the attribute set (<code>null</code> not permitted).
595 * @param align the alignment (typically one of
596 * {@link StyleConstants#ALIGN_LEFT},
597 * {@link StyleConstants#ALIGN_RIGHT},
598 * {@link StyleConstants#ALIGN_CENTER} or
599 * {@link StyleConstants#ALIGN_JUSTIFIED}).
601 * @throws NullPointerException if <code>a</code> is <code>null</code>.
603 * @see #getAlignment(AttributeSet)
605 public static void setAlignment(MutableAttributeSet a, int align)
607 a.addAttribute(Alignment, new Integer(align));
611 * Adds a background attribute to the specified set.
613 * @param a the attribute set (<code>null</code> not permitted).
614 * @param bg the background (<code>null</code> not permitted).
616 * @throws NullPointerException if either argument is <code>null</code>.
618 * @see #getBackground(AttributeSet)
620 public static void setBackground(MutableAttributeSet a, Color bg)
622 a.addAttribute(Background, bg);
626 * Adds a bidi-level attribute to the specified set.
628 * @param a the attribute set (<code>null</code> not permitted).
629 * @param lev the level.
631 * @throws NullPointerException if <code>a</code> is <code>null</code>.
633 * @see #getBidiLevel(AttributeSet)
635 public static void setBidiLevel(MutableAttributeSet a, int lev)
637 a.addAttribute(BidiLevel, new Integer(lev));
641 * Adds a bold attribute to the specified set.
643 * @param a the attribute set (<code>null</code> not permitted).
644 * @param b the new value of the bold attribute.
646 * @throws NullPointerException if <code>a</code> is <code>null</code>.
648 * @see #isBold(AttributeSet)
650 public static void setBold(MutableAttributeSet a, boolean b)
652 a.addAttribute(Bold, Boolean.valueOf(b));
656 * Adds a component attribute to the specified set.
658 * @param a the attribute set (<code>null</code> not permitted).
659 * @param c the component (<code>null</code> not permitted).
661 * @throws NullPointerException if either argument is <code>null</code>.
663 * @see #getComponent(AttributeSet)
665 public static void setComponent(MutableAttributeSet a, Component c)
667 a.addAttribute(ComponentAttribute, c);
671 * Adds a first line indentation attribute to the specified set.
673 * @param a the attribute set (<code>null</code> not permitted).
674 * @param i the indentation.
676 * @throws NullPointerException if <code>a</code> is <code>null</code>.
678 * @see #getFirstLineIndent(AttributeSet)
680 public static void setFirstLineIndent(MutableAttributeSet a, float i)
682 a.addAttribute(FirstLineIndent, new Float(i));
686 * Adds a font family attribute to the specified set.
688 * @param a the attribute set (<code>null</code> not permitted).
689 * @param fam the font family name (<code>null</code> not permitted).
691 * @throws NullPointerException if either argument is <code>null</code>.
693 * @see #getFontFamily(AttributeSet)
695 public static void setFontFamily(MutableAttributeSet a, String fam)
697 a.addAttribute(FontFamily, fam);
701 * Adds a font size attribute to the specified set.
703 * @param a the attribute set (<code>null</code> not permitted).
704 * @param s the font size (in points).
706 * @throws NullPointerException if <code>a</code> is <code>null</code>.
708 * @see #getFontSize(AttributeSet)
710 public static void setFontSize(MutableAttributeSet a, int s)
712 a.addAttribute(FontSize, new Integer(s));
716 * Adds a foreground color attribute to the specified set.
718 * @param a the attribute set (<code>null</code> not permitted).
719 * @param fg the foreground color (<code>null</code> not permitted).
721 * @throws NullPointerException if either argument is <code>null</code>.
723 * @see #getForeground(AttributeSet)
725 public static void setForeground(MutableAttributeSet a, Color fg)
727 a.addAttribute(Foreground, fg);
731 * Adds an icon attribute to the specified set.
733 * @param a the attribute set (<code>null</code> not permitted).
734 * @param c the icon (<code>null</code> not permitted).
736 * @throws NullPointerException if either argument is <code>null</code>.
738 * @see #getIcon(AttributeSet)
740 public static void setIcon(MutableAttributeSet a, Icon c)
742 a.addAttribute(AbstractDocument.ElementNameAttribute, IconElementName);
743 a.addAttribute(IconAttribute, c);
747 * Adds an italic attribute to the specified set.
749 * @param a the attribute set (<code>null</code> not permitted).
750 * @param b the new value of the italic attribute.
752 * @throws NullPointerException if <code>a</code> is <code>null</code>.
754 * @see #isItalic(AttributeSet)
756 public static void setItalic(MutableAttributeSet a, boolean b)
758 a.addAttribute(Italic, Boolean.valueOf(b));
762 * Adds a left indentation attribute to the specified set.
764 * @param a the attribute set (<code>null</code> not permitted).
765 * @param i the indentation.
767 * @throws NullPointerException if <code>a</code> is <code>null</code>.
769 * @see #getLeftIndent(AttributeSet)
771 public static void setLeftIndent(MutableAttributeSet a, float i)
773 a.addAttribute(LeftIndent, new Float(i));
777 * Adds a line spacing attribute to the specified set.
779 * @param a the attribute set (<code>null</code> not permitted).
780 * @param i the line spacing.
782 * @throws NullPointerException if <code>a</code> is <code>null</code>.
784 * @see #getLineSpacing(AttributeSet)
786 public static void setLineSpacing(MutableAttributeSet a, float i)
788 a.addAttribute(LineSpacing, new Float(i));
792 * Adds a right indentation attribute to the specified set.
794 * @param a the attribute set (<code>null</code> not permitted).
795 * @param i the right indentation.
797 * @throws NullPointerException if <code>a</code> is <code>null</code>.
799 * @see #getRightIndent(AttributeSet)
801 public static void setRightIndent(MutableAttributeSet a, float i)
803 a.addAttribute(RightIndent, new Float(i));
807 * Adds a 'space above' attribute to the specified set.
809 * @param a the attribute set (<code>null</code> not permitted).
810 * @param i the space above attribute value.
812 * @throws NullPointerException if <code>a</code> is <code>null</code>.
814 * @see #getSpaceAbove(AttributeSet)
816 public static void setSpaceAbove(MutableAttributeSet a, float i)
818 a.addAttribute(SpaceAbove, new Float(i));
822 * Adds a 'space below' attribute to the specified set.
824 * @param a the attribute set (<code>null</code> not permitted).
825 * @param i the space below attribute value.
827 * @throws NullPointerException if <code>a</code> is <code>null</code>.
829 * @see #getSpaceBelow(AttributeSet)
831 public static void setSpaceBelow(MutableAttributeSet a, float i)
833 a.addAttribute(SpaceBelow, new Float(i));
837 * Adds a strike-through attribue to the specified set.
839 * @param a the attribute set (<code>null</code> not permitted).
840 * @param b the strike-through attribute value.
842 * @throws NullPointerException if <code>a</code> is <code>null</code>.
844 * @see #isStrikeThrough(AttributeSet)
846 public static void setStrikeThrough(MutableAttributeSet a, boolean b)
848 a.addAttribute(StrikeThrough, Boolean.valueOf(b));
852 * Adds a subscript attribute to the specified set.
854 * @param a the attribute set (<code>null</code> not permitted).
855 * @param b the subscript attribute value.
857 * @throws NullPointerException if <code>a</code> is <code>null</code>.
859 * @see #isSubscript(AttributeSet)
861 public static void setSubscript(MutableAttributeSet a, boolean b)
863 a.addAttribute(Subscript, Boolean.valueOf(b));
867 * Adds a superscript attribute to the specified set.
869 * @param a the attribute set (<code>null</code> not permitted).
870 * @param b the superscript attribute value.
872 * @throws NullPointerException if <code>a</code> is <code>null</code>.
874 * @see #isSuperscript(AttributeSet)
876 public static void setSuperscript(MutableAttributeSet a, boolean b)
878 a.addAttribute(Superscript, Boolean.valueOf(b));
882 * Adds a {@link TabSet} attribute to the specified set.
884 * @param a the attribute set (<code>null</code> not permitted).
885 * @param tabs the tab set (<code>null</code> not permitted).
887 * @throws NullPointerException if either argument is <code>null</code>.
889 * @see #getTabSet(AttributeSet)
891 public static void setTabSet(MutableAttributeSet a,
892 javax.swing.text.TabSet tabs)
894 a.addAttribute(StyleConstants.TabSet, tabs);
898 * Adds an underline attribute to the specified set.
900 * @param a the attribute set (<code>null</code> not permitted).
901 * @param b the underline attribute value.
903 * @throws NullPointerException if <code>a</code> is <code>null</code>.
905 * @see #isUnderline(AttributeSet)
907 public static void setUnderline(MutableAttributeSet a, boolean b)
909 a.addAttribute(Underline, Boolean.valueOf(b));
912 // The remainder are so-called "typesafe enumerations" which
913 // alias subsets of the above constants.
916 * A set of keys for attributes that apply to characters.
918 public static class CharacterConstants
919 extends StyleConstants
920 implements AttributeSet.CharacterAttribute
923 * Private constructor prevents new instances being created.
925 * @param k the key name.
927 private CharacterConstants(String k)
929 super(k);
932 /** An alias for {@link ColorConstants#Background}. */
933 public static final Object Background = ColorConstants.Background;
935 /** A key for the bidi level character attribute. */
936 public static final Object BidiLevel = new CharacterConstants("bidiLevel");
938 /** An alias for {@link FontConstants#Bold}. */
939 public static final Object Bold = FontConstants.Bold;
941 /** A key for the component character attribute. */
942 public static final Object ComponentAttribute
943 = new CharacterConstants("component");
945 /** An alias for {@link FontConstants#Family}. */
946 public static final Object Family = FontConstants.Family;
948 /** An alias for {@link FontConstants#Size}. */
949 public static final Object Size = FontConstants.Size;
951 /** An alias for {@link ColorConstants#Foreground}. */
952 public static final Object Foreground = ColorConstants.Foreground;
954 /** A key for the icon character attribute. */
955 public static final Object IconAttribute = new CharacterConstants("icon");
957 /** A key for the italic character attribute. */
958 public static final Object Italic = FontConstants.Italic;
960 /** A key for the strike through character attribute. */
961 public static final Object StrikeThrough
962 = new CharacterConstants("strikethrough");
964 /** A key for the subscript character attribute. */
965 public static final Object Subscript = new CharacterConstants("subscript");
967 /** A key for the superscript character attribute. */
968 public static final Object Superscript
969 = new CharacterConstants("superscript");
971 /** A key for the underline character attribute. */
972 public static final Object Underline = new CharacterConstants("underline");
977 * A set of keys for attributes that relate to colors.
979 public static class ColorConstants
980 extends StyleConstants
981 implements AttributeSet.ColorAttribute, AttributeSet.CharacterAttribute
984 * Private constructor prevents new instances being created.
986 * @param k the key name.
988 private ColorConstants(String k)
990 super(k);
993 /** A key for the foreground color attribute. */
994 public static final Object Foreground = new ColorConstants("foreground");
996 /** A key for the background color attribute. */
997 public static final Object Background = new ColorConstants("background");
1001 * A set of keys for attributes that apply to fonts.
1003 public static class FontConstants
1004 extends StyleConstants
1005 implements AttributeSet.FontAttribute, AttributeSet.CharacterAttribute
1008 * Private constructor prevents new instances being created.
1010 * @param k the key name.
1012 private FontConstants(String k)
1014 super(k);
1017 /** A key for the bold font attribute. */
1018 public static final Object Bold = new FontConstants("bold");
1020 /** A key for the family font attribute. */
1021 public static final Object Family = new FontConstants("family");
1023 /** A key for the italic font attribute. */
1024 public static final Object Italic = new FontConstants("italic");
1026 /** A key for the size font attribute. */
1027 public static final Object Size = new FontConstants("size");
1031 * A set of keys for attributes that apply to paragraphs.
1033 public static class ParagraphConstants
1034 extends StyleConstants
1035 implements AttributeSet.ParagraphAttribute
1038 * Private constructor prevents new instances being created.
1040 * @param k the key name.
1042 private ParagraphConstants(String k)
1044 super(k);
1047 /** A key for the alignment paragraph attribute. */
1048 public static final Object Alignment = new ParagraphConstants("Alignment");
1050 /** A key for the first line indentation paragraph attribute. */
1051 public static final Object FirstLineIndent
1052 = new ParagraphConstants("FirstLineIndent");
1054 /** A key for the left indentation paragraph attribute. */
1055 public static final Object LeftIndent
1056 = new ParagraphConstants("LeftIndent");
1058 /** A key for the line spacing paragraph attribute. */
1059 public static final Object LineSpacing
1060 = new ParagraphConstants("LineSpacing");
1062 /** A key for the orientation paragraph attribute. */
1063 public static final Object Orientation
1064 = new ParagraphConstants("Orientation");
1066 /** A key for the right indentation paragraph attribute. */
1067 public static final Object RightIndent
1068 = new ParagraphConstants("RightIndent");
1070 /** A key for the 'space above' paragraph attribute. */
1071 public static final Object SpaceAbove
1072 = new ParagraphConstants("SpaceAbove");
1074 /** A key for the 'space below' paragraph attribute. */
1075 public static final Object SpaceBelow
1076 = new ParagraphConstants("SpaceBelow");
1078 /** A key for the tabset paragraph attribute. */
1079 public static final Object TabSet = new ParagraphConstants("TabSet");