44
44
import javax.swing.Icon;
47
* Represents standard attribute keys. This class also contains a set of
48
* useful static utility methods for querying and populating an
49
* {@link AttributeSet}.
46
53
public class StyleConstants
56
* A value representing left alignment for the
57
* {@link ParagraphConstants#Alignment} attribute.
48
59
public static final int ALIGN_LEFT = 0;
62
* A value representing center alignment for the
63
* {@link ParagraphConstants#Alignment} attribute.
49
65
public static final int ALIGN_CENTER = 1;
68
* A value representing right alignment for the
69
* {@link ParagraphConstants#Alignment} attribute.
50
71
public static final int ALIGN_RIGHT = 2;
74
* A value representing ful justification for the
75
* {@link ParagraphConstants#Alignment} attribute.
51
77
public static final int ALIGN_JUSTIFIED = 3;
79
/** An alias for {@link CharacterConstants#Background}. */
53
80
public static final Object Background = CharacterConstants.Background;
82
/** An alias for {@link CharacterConstants#BidiLevel}. */
54
83
public static final Object BidiLevel = CharacterConstants.BidiLevel;
85
/** An alias for {@link CharacterConstants#Bold}. */
55
86
public static final Object Bold = CharacterConstants.Bold;
56
public static final Object ComponentAttribute = CharacterConstants.ComponentAttribute;
57
public static final Object FontFamily = CharacterConstants.Family;
88
/** An alias for {@link CharacterConstants#ComponentAttribute}. */
89
public static final Object ComponentAttribute
90
= CharacterConstants.ComponentAttribute;
92
/** An alias for {@link CharacterConstants#Family}. */
93
public static final Object Family = CharacterConstants.Family;
95
/** An alias for {@link CharacterConstants#Family}. */
96
public static final Object FontFamily = CharacterConstants.Family;
98
/** An alias for {@link CharacterConstants#Size}. */
58
99
public static final Object FontSize = CharacterConstants.Size;
101
/** An alias for {@link CharacterConstants#Foreground}. */
59
102
public static final Object Foreground = CharacterConstants.Foreground;
104
/** An alias for {@link CharacterConstants#IconAttribute}. */
60
105
public static final Object IconAttribute = CharacterConstants.IconAttribute;
107
/** An alias for {@link CharacterConstants#Italic}. */
61
108
public static final Object Italic = CharacterConstants.Italic;
110
/** An alias for {@link CharacterConstants#Size}. */
111
public static final Object Size = CharacterConstants.Size;
113
/** An alias for {@link CharacterConstants#StrikeThrough}. */
62
114
public static final Object StrikeThrough = CharacterConstants.StrikeThrough;
116
/** An alias for {@link CharacterConstants#Subscript}. */
63
117
public static final Object Subscript = CharacterConstants.Subscript;
119
/** An alias for {@link CharacterConstants#Superscript}. */
64
120
public static final Object Superscript = CharacterConstants.Superscript;
122
/** An alias for {@link CharacterConstants#Underline}. */
65
123
public static final Object Underline = CharacterConstants.Underline;
125
/** An alias for {@link ParagraphConstants#Alignment}. */
67
126
public static final Object Alignment = ParagraphConstants.Alignment;
68
public static final Object FirstLineIndent = ParagraphConstants.FirstLineIndent;
128
/** An alias for {@link ParagraphConstants#FirstLineIndent}. */
129
public static final Object FirstLineIndent
130
= ParagraphConstants.FirstLineIndent;
132
/** An alias for {@link ParagraphConstants#LeftIndent}. */
69
133
public static final Object LeftIndent = ParagraphConstants.LeftIndent;
135
/** An alias for {@link ParagraphConstants#LineSpacing}. */
70
136
public static final Object LineSpacing = ParagraphConstants.LineSpacing;
138
/** An alias for {@link ParagraphConstants#Orientation}. */
71
139
public static final Object Orientation = ParagraphConstants.Orientation;
141
/** An alias for {@link ParagraphConstants#RightIndent}. */
72
142
public static final Object RightIndent = ParagraphConstants.RightIndent;
144
/** An alias for {@link ParagraphConstants#SpaceAbove}. */
73
145
public static final Object SpaceAbove = ParagraphConstants.SpaceAbove;
147
/** An alias for {@link ParagraphConstants#SpaceBelow}. */
74
148
public static final Object SpaceBelow = ParagraphConstants.SpaceBelow;
150
/** An alias for {@link ParagraphConstants#TabSet}. */
75
151
public static final Object TabSet = ParagraphConstants.TabSet;
77
153
public static final String ComponentElementName = "component";
78
155
public static final String IconElementName = "icon";
80
public static final Object ComposedTextAttribute = new StyleConstants("composed text");
157
public static final Object ComposedTextAttribute
158
= new StyleConstants("composed text");
81
160
public static final Object ModelAttribute = new StyleConstants("model");
82
162
public static final Object NameAttribute = new StyleConstants("name");
83
164
public static final Object ResolveAttribute = new StyleConstants("resolver");
176
* Returns a string representation of the attribute key.
178
* @return A string representation of the attribute key.
94
180
public String toString()
186
* Returns the alignment specified in the given attributes, or
187
* {@link #ALIGN_LEFT} if no alignment is specified.
189
* @param a the attribute set (<code>null</code> not permitted).
191
* @return The alignment (typically one of {@link #ALIGN_LEFT},
192
* {@link #ALIGN_RIGHT}, {@link #ALIGN_CENTER} or
193
* {@link #ALIGN_JUSTIFIED}).
195
* @see #setAlignment(MutableAttributeSet, int)
99
197
public static int getAlignment(AttributeSet a)
101
if (a.isDefined(Alignment))
102
return ((Integer)a.getAttribute(Alignment)).intValue();
199
Integer i = (Integer) a.getAttribute(Alignment);
104
203
return ALIGN_LEFT;
207
* Returns the background color specified in the given attributes, or
208
* {@link Color#BLACK} if no background color is specified.
210
* @param a the attribute set (<code>null</code> not permitted).
212
* @return The background color.
214
* @see #setBackground(MutableAttributeSet, Color)
107
216
public static Color getBackground(AttributeSet a)
109
if (a.isDefined(Background))
110
return (Color) a.getAttribute(Background);
218
Color c = (Color) a.getAttribute(Background);
226
* Returns the bidi level specified in the given attributes, or
227
* <code>0</code> if no bidi level is specified.
229
* @param a the attribute set (<code>null</code> not permitted).
231
* @return The bidi level.
233
* @see #setBidiLevel(MutableAttributeSet, int)
115
235
public static int getBidiLevel(AttributeSet a)
117
if (a.isDefined(BidiLevel))
118
return ((Integer)a.getAttribute(BidiLevel)).intValue();
237
Integer i = (Integer) a.getAttribute(BidiLevel);
245
* Returns the component specified in the given attributes, or
246
* <code>null</code> if no component is specified.
248
* @param a the attribute set (<code>null</code> not permitted).
250
* @return The component (possibly <code>null</code>).
252
* @see #setComponent(MutableAttributeSet, Component)
123
254
public static Component getComponent(AttributeSet a)
125
if (a.isDefined(ComponentAttribute))
126
return (Component) a.getAttribute(ComponentAttribute);
256
Component c = (Component) a.getAttribute(ComponentAttribute);
128
return (Component) null;
264
* Returns the indentation specified in the given attributes, or
265
* <code>0.0f</code> if no indentation is specified.
267
* @param a the attribute set (<code>null</code> not permitted).
269
* @return The indentation.
271
* @see #setFirstLineIndent(MutableAttributeSet, float)
131
273
public static float getFirstLineIndent(AttributeSet a)
133
if (a.isDefined(FirstLineIndent))
134
return ((Float)a.getAttribute(FirstLineIndent)).floatValue();
275
Float f = (Float) a.getAttribute(FirstLineIndent);
277
return f.floatValue();
283
* Returns the font family specified in the given attributes, or
284
* <code>Monospaced</code> if no font family is specified.
286
* @param a the attribute set (<code>null</code> not permitted).
288
* @return The font family.
290
* @see #setFontFamily(MutableAttributeSet, String)
139
292
public static String getFontFamily(AttributeSet a)
141
if (a.isDefined(FontFamily))
142
return (String) a.getAttribute(FontFamily);
294
String ff = (String) a.getAttribute(FontFamily);
144
298
return "Monospaced";
302
* Returns the font size specified in the given attributes, or
303
* <code>12</code> if no font size is specified.
305
* @param a the attribute set (<code>null</code> not permitted).
307
* @return The font size.
309
* @see #setFontSize(MutableAttributeSet, int)
147
311
public static int getFontSize(AttributeSet a)
149
if (a.isDefined(FontSize))
150
return ((Integer)a.getAttribute(FontSize)).intValue();
313
Integer i = (Integer) a.getAttribute(FontSize);
321
* Returns the foreground color specified in the given attributes, or
322
* {@link Color#BLACK} if no foreground color is specified.
324
* @param a the attribute set (<code>null</code> not permitted).
326
* @return The foreground color.
328
* @see #setForeground(MutableAttributeSet, Color)
155
330
public static Color getForeground(AttributeSet a)
157
if (a.isDefined(Foreground))
158
return (Color) a.getAttribute(Foreground);
332
Color c = (Color) a.getAttribute(Foreground);
160
336
return Color.BLACK;
340
* Returns the icon specified in the given attributes, or
341
* <code>null</code> if no icon is specified.
343
* @param a the attribute set (<code>null</code> not permitted).
345
* @return The icon (possibly <code>null</code>).
347
* @see #setIcon(MutableAttributeSet, Icon)
163
349
public static Icon getIcon(AttributeSet a)
165
if (a.isDefined(IconAttribute))
166
return (Icon) a.getAttribute(IconAttribute);
351
return (Icon) a.getAttribute(IconAttribute);
355
* Returns the left indentation specified in the given attributes, or
356
* <code>0.0f</code> if no left indentation is specified.
358
* @param a the attribute set (<code>null</code> not permitted).
360
* @return The left indentation.
362
* @see #setLeftIndent(MutableAttributeSet, float)
171
364
public static float getLeftIndent(AttributeSet a)
173
if (a.isDefined(LeftIndent))
174
return ((Float)a.getAttribute(LeftIndent)).floatValue();
366
Float f = (Float) a.getAttribute(LeftIndent);
368
return f.floatValue();
374
* Returns the line spacing specified in the given attributes, or
375
* <code>0.0f</code> if no line spacing is specified.
377
* @param a the attribute set (<code>null</code> not permitted).
379
* @return The line spacing.
381
* @see #setLineSpacing(MutableAttributeSet, float)
179
383
public static float getLineSpacing(AttributeSet a)
181
if (a.isDefined(LineSpacing))
182
return ((Float)a.getAttribute(LineSpacing)).floatValue();
385
Float f = (Float) a.getAttribute(LineSpacing);
387
return f.floatValue();
393
* Returns the right indentation specified in the given attributes, or
394
* <code>0.0f</code> if no right indentation is specified.
396
* @param a the attribute set (<code>null</code> not permitted).
398
* @return The right indentation.
400
* @see #setRightIndent(MutableAttributeSet, float)
187
402
public static float getRightIndent(AttributeSet a)
189
if (a.isDefined(RightIndent))
190
return ((Float)a.getAttribute(RightIndent)).floatValue();
404
Float f = (Float) a.getAttribute(RightIndent);
406
return f.floatValue();
412
* Returns the 'space above' specified in the given attributes, or
413
* <code>0.0f</code> if no 'space above' is specified.
415
* @param a the attribute set (<code>null</code> not permitted).
417
* @return The 'space above'.
419
* @see #setSpaceAbove(MutableAttributeSet, float)
195
421
public static float getSpaceAbove(AttributeSet a)
197
if (a.isDefined(SpaceAbove))
198
return ((Float)a.getAttribute(SpaceAbove)).floatValue();
423
Float f = (Float) a.getAttribute(SpaceAbove);
425
return f.floatValue();
431
* Returns the 'space below' specified in the given attributes, or
432
* <code>0.0f</code> if no 'space below' is specified.
434
* @param a the attribute set (<code>null</code> not permitted).
436
* @return The 'space below'.
438
* @see #setSpaceBelow(MutableAttributeSet, float)
203
440
public static float getSpaceBelow(AttributeSet a)
205
if (a.isDefined(SpaceBelow))
206
return ((Float)a.getAttribute(SpaceBelow)).floatValue();
442
Float f = (Float) a.getAttribute(SpaceBelow);
444
return f.floatValue();
450
* Returns the tab set specified in the given attributes, or
451
* <code>null</code> if no tab set is specified.
453
* @param a the attribute set (<code>null</code> not permitted).
455
* @return The tab set.
457
* @see #setTabSet(MutableAttributeSet, javax.swing.text.TabSet)
211
459
public static javax.swing.text.TabSet getTabSet(AttributeSet a)
213
if (a.isDefined(StyleConstants.TabSet))
214
return (javax.swing.text.TabSet) a.getAttribute(StyleConstants.TabSet);
216
return (javax.swing.text.TabSet) null;
461
// I'm guessing that the fully qualified class name is to differentiate
462
// between the TabSet class and the TabSet (attribute) instance on some
464
return (javax.swing.text.TabSet) a.getAttribute(StyleConstants.TabSet);
468
* Returns the value of the bold flag in the given attributes, or
469
* <code>false</code> if no bold flag is specified.
471
* @param a the attribute set (<code>null</code> not permitted).
473
* @return The bold flag.
475
* @see #setBold(MutableAttributeSet, boolean)
219
477
public static boolean isBold(AttributeSet a)
221
if (a.isDefined(Bold))
222
return ((Boolean) a.getAttribute(Bold)).booleanValue();
479
Boolean b = (Boolean) a.getAttribute(Bold);
481
return b.booleanValue();
487
* Returns the value of the italic flag in the given attributes, or
488
* <code>false</code> if no italic flag is specified.
490
* @param a the attribute set (<code>null</code> not permitted).
492
* @return The italic flag.
494
* @see #setItalic(MutableAttributeSet, boolean)
227
496
public static boolean isItalic(AttributeSet a)
229
if (a.isDefined(Italic))
230
return ((Boolean) a.getAttribute(Italic)).booleanValue();
498
Boolean b = (Boolean) a.getAttribute(Italic);
500
return b.booleanValue();
506
* Returns the value of the strike-through flag in the given attributes, or
507
* <code>false</code> if no strike-through flag is specified.
509
* @param a the attribute set (<code>null</code> not permitted).
511
* @return The strike-through flag.
513
* @see #setStrikeThrough(MutableAttributeSet, boolean)
235
515
public static boolean isStrikeThrough(AttributeSet a)
237
if (a.isDefined(StrikeThrough))
238
return ((Boolean) a.getAttribute(StrikeThrough)).booleanValue();
517
Boolean b = (Boolean) a.getAttribute(StrikeThrough);
519
return b.booleanValue();
525
* Returns the value of the subscript flag in the given attributes, or
526
* <code>false</code> if no subscript flag is specified.
528
* @param a the attribute set (<code>null</code> not permitted).
530
* @return The subscript flag.
532
* @see #setSubscript(MutableAttributeSet, boolean)
243
534
public static boolean isSubscript(AttributeSet a)
245
if (a.isDefined(Subscript))
246
return ((Boolean) a.getAttribute(Subscript)).booleanValue();
536
Boolean b = (Boolean) a.getAttribute(Subscript);
538
return b.booleanValue();
544
* Returns the value of the superscript flag in the given attributes, or
545
* <code>false</code> if no superscript flag is specified.
547
* @param a the attribute set (<code>null</code> not permitted).
549
* @return The superscript flag.
551
* @see #setSuperscript(MutableAttributeSet, boolean)
251
553
public static boolean isSuperscript(AttributeSet a)
253
if (a.isDefined(Superscript))
254
return ((Boolean) a.getAttribute(Superscript)).booleanValue();
555
Boolean b = (Boolean) a.getAttribute(Superscript);
557
return b.booleanValue();
563
* Returns the value of the underline flag in the given attributes, or
564
* <code>false</code> if no underline flag is specified.
566
* @param a the attribute set (<code>null</code> not permitted).
568
* @return The underline flag.
570
* @see #setUnderline(MutableAttributeSet, boolean)
259
572
public static boolean isUnderline(AttributeSet a)
261
if (a.isDefined(Underline))
262
return ((Boolean) a.getAttribute(Underline)).booleanValue();
574
Boolean b = (Boolean) a.getAttribute(Underline);
576
return b.booleanValue();
582
* Adds an alignment attribute to the specified set.
584
* @param a the attribute set (<code>null</code> not permitted).
585
* @param align the alignment (typically one of
586
* {@link StyleConstants#ALIGN_LEFT},
587
* {@link StyleConstants#ALIGN_RIGHT},
588
* {@link StyleConstants#ALIGN_CENTER} or
589
* {@link StyleConstants#ALIGN_JUSTIFIED}).
591
* @throws NullPointerException if <code>a</code> is <code>null</code>.
593
* @see #getAlignment(AttributeSet)
267
595
public static void setAlignment(MutableAttributeSet a, int align)
269
597
a.addAttribute(Alignment, new Integer(align));
272
public static void setBackground(MutableAttributeSet a, Color fg)
601
* Adds a background attribute to the specified set.
603
* @param a the attribute set (<code>null</code> not permitted).
604
* @param bg the background (<code>null</code> not permitted).
606
* @throws NullPointerException if either argument is <code>null</code>.
608
* @see #getBackground(AttributeSet)
610
public static void setBackground(MutableAttributeSet a, Color bg)
274
a.addAttribute(Background, fg);
612
a.addAttribute(Background, bg);
616
* Adds a bidi-level attribute to the specified set.
618
* @param a the attribute set (<code>null</code> not permitted).
619
* @param lev the level.
621
* @throws NullPointerException if <code>a</code> is <code>null</code>.
623
* @see #getBidiLevel(AttributeSet)
277
625
public static void setBidiLevel(MutableAttributeSet a, int lev)
279
627
a.addAttribute(BidiLevel, new Integer(lev));
631
* Adds a bold attribute to the specified set.
633
* @param a the attribute set (<code>null</code> not permitted).
634
* @param b the new value of the bold attribute.
636
* @throws NullPointerException if <code>a</code> is <code>null</code>.
638
* @see #isBold(AttributeSet)
282
640
public static void setBold(MutableAttributeSet a, boolean b)
284
642
a.addAttribute(Bold, Boolean.valueOf(b));
646
* Adds a component attribute to the specified set.
648
* @param a the attribute set (<code>null</code> not permitted).
649
* @param c the component (<code>null</code> not permitted).
651
* @throws NullPointerException if either argument is <code>null</code>.
653
* @see #getComponent(AttributeSet)
287
655
public static void setComponent(MutableAttributeSet a, Component c)
289
657
a.addAttribute(ComponentAttribute, c);
661
* Adds a first line indentation attribute to the specified set.
663
* @param a the attribute set (<code>null</code> not permitted).
664
* @param i the indentation.
666
* @throws NullPointerException if <code>a</code> is <code>null</code>.
668
* @see #getFirstLineIndent(AttributeSet)
292
670
public static void setFirstLineIndent(MutableAttributeSet a, float i)
294
672
a.addAttribute(FirstLineIndent, new Float(i));
676
* Adds a font family attribute to the specified set.
678
* @param a the attribute set (<code>null</code> not permitted).
679
* @param fam the font family name (<code>null</code> not permitted).
681
* @throws NullPointerException if either argument is <code>null</code>.
683
* @see #getFontFamily(AttributeSet)
297
685
public static void setFontFamily(MutableAttributeSet a, String fam)
299
687
a.addAttribute(FontFamily, fam);
691
* Adds a font size attribute to the specified set.
693
* @param a the attribute set (<code>null</code> not permitted).
694
* @param s the font size (in points).
696
* @throws NullPointerException if <code>a</code> is <code>null</code>.
698
* @see #getFontSize(AttributeSet)
302
700
public static void setFontSize(MutableAttributeSet a, int s)
304
702
a.addAttribute(FontSize, new Integer(s));
706
* Adds a foreground color attribute to the specified set.
708
* @param a the attribute set (<code>null</code> not permitted).
709
* @param fg the foreground color (<code>null</code> not permitted).
711
* @throws NullPointerException if either argument is <code>null</code>.
713
* @see #getForeground(AttributeSet)
307
715
public static void setForeground(MutableAttributeSet a, Color fg)
309
717
a.addAttribute(Foreground, fg);
721
* Adds an icon attribute to the specified set.
723
* @param a the attribute set (<code>null</code> not permitted).
724
* @param c the icon (<code>null</code> not permitted).
726
* @throws NullPointerException if either argument is <code>null</code>.
728
* @see #getIcon(AttributeSet)
312
730
public static void setIcon(MutableAttributeSet a, Icon c)
314
732
a.addAttribute(IconAttribute, c);
736
* Adds an italic attribute to the specified set.
738
* @param a the attribute set (<code>null</code> not permitted).
739
* @param b the new value of the italic attribute.
741
* @throws NullPointerException if <code>a</code> is <code>null</code>.
743
* @see #isItalic(AttributeSet)
317
745
public static void setItalic(MutableAttributeSet a, boolean b)
319
747
a.addAttribute(Italic, Boolean.valueOf(b));
751
* Adds a left indentation attribute to the specified set.
753
* @param a the attribute set (<code>null</code> not permitted).
754
* @param i the indentation.
756
* @throws NullPointerException if <code>a</code> is <code>null</code>.
758
* @see #getLeftIndent(AttributeSet)
322
760
public static void setLeftIndent(MutableAttributeSet a, float i)
324
762
a.addAttribute(LeftIndent, new Float(i));
766
* Adds a line spacing attribute to the specified set.
768
* @param a the attribute set (<code>null</code> not permitted).
769
* @param i the line spacing.
771
* @throws NullPointerException if <code>a</code> is <code>null</code>.
773
* @see #getLineSpacing(AttributeSet)
327
775
public static void setLineSpacing(MutableAttributeSet a, float i)
329
777
a.addAttribute(LineSpacing, new Float(i));
781
* Adds a right indentation attribute to the specified set.
783
* @param a the attribute set (<code>null</code> not permitted).
784
* @param i the right indentation.
786
* @throws NullPointerException if <code>a</code> is <code>null</code>.
788
* @see #getRightIndent(AttributeSet)
332
790
public static void setRightIndent(MutableAttributeSet a, float i)
334
792
a.addAttribute(RightIndent, new Float(i));
796
* Adds a 'space above' attribute to the specified set.
798
* @param a the attribute set (<code>null</code> not permitted).
799
* @param i the space above attribute value.
801
* @throws NullPointerException if <code>a</code> is <code>null</code>.
803
* @see #getSpaceAbove(AttributeSet)
337
805
public static void setSpaceAbove(MutableAttributeSet a, float i)
339
807
a.addAttribute(SpaceAbove, new Float(i));
811
* Adds a 'space below' attribute to the specified set.
813
* @param a the attribute set (<code>null</code> not permitted).
814
* @param i the space below attribute value.
816
* @throws NullPointerException if <code>a</code> is <code>null</code>.
818
* @see #getSpaceBelow(AttributeSet)
342
820
public static void setSpaceBelow(MutableAttributeSet a, float i)
344
822
a.addAttribute(SpaceBelow, new Float(i));
826
* Adds a strike-through attribue to the specified set.
828
* @param a the attribute set (<code>null</code> not permitted).
829
* @param b the strike-through attribute value.
831
* @throws NullPointerException if <code>a</code> is <code>null</code>.
833
* @see #isStrikeThrough(AttributeSet)
347
835
public static void setStrikeThrough(MutableAttributeSet a, boolean b)
349
837
a.addAttribute(StrikeThrough, Boolean.valueOf(b));
841
* Adds a subscript attribute to the specified set.
843
* @param a the attribute set (<code>null</code> not permitted).
844
* @param b the subscript attribute value.
846
* @throws NullPointerException if <code>a</code> is <code>null</code>.
848
* @see #isSubscript(AttributeSet)
352
850
public static void setSubscript(MutableAttributeSet a, boolean b)
354
852
a.addAttribute(Subscript, Boolean.valueOf(b));
856
* Adds a superscript attribute to the specified set.
858
* @param a the attribute set (<code>null</code> not permitted).
859
* @param b the superscript attribute value.
861
* @throws NullPointerException if <code>a</code> is <code>null</code>.
863
* @see #isSuperscript(AttributeSet)
357
865
public static void setSuperscript(MutableAttributeSet a, boolean b)
359
867
a.addAttribute(Superscript, Boolean.valueOf(b));
362
public static void setTabSet(MutableAttributeSet a, javax.swing.text.TabSet tabs)
871
* Adds a {@link TabSet} attribute to the specified set.
873
* @param a the attribute set (<code>null</code> not permitted).
874
* @param tabs the tab set (<code>null</code> not permitted).
876
* @throws NullPointerException if either argument is <code>null</code>.
878
* @see #getTabSet(AttributeSet)
880
public static void setTabSet(MutableAttributeSet a,
881
javax.swing.text.TabSet tabs)
364
883
a.addAttribute(StyleConstants.TabSet, tabs);
887
* Adds an underline attribute to the specified set.
889
* @param a the attribute set (<code>null</code> not permitted).
890
* @param b the underline attribute value.
892
* @throws NullPointerException if <code>a</code> is <code>null</code>.
894
* @see #isUnderline(AttributeSet)
367
896
public static void setUnderline(MutableAttributeSet a, boolean b)
369
898
a.addAttribute(Underline, Boolean.valueOf(b));
372
901
// The remainder are so-called "typesafe enumerations" which
373
902
// alias subsets of the above constants.
905
* A set of keys for attributes that apply to characters.
374
907
public static class CharacterConstants
375
908
extends StyleConstants
376
909
implements AttributeSet.CharacterAttribute
912
* Private constructor prevents new instances being created.
914
* @param k the key name.
378
916
private CharacterConstants(String k)
383
public static Object Background = ColorConstants.Background;
384
public static Object BidiLevel = new CharacterConstants("bidiLevel");
385
public static Object Bold = FontConstants.Bold;
386
public static Object ComponentAttribute = new CharacterConstants("component");
387
public static Object Family = FontConstants.Family;
388
public static Object Size = FontConstants.Size;
389
public static Object Foreground = ColorConstants.Foreground;
390
public static Object IconAttribute = new CharacterConstants("icon");
391
public static Object Italic = FontConstants.Italic;
392
public static Object StrikeThrough = new CharacterConstants("strikethrough");
393
public static Object Subscript = new CharacterConstants("subscript");
394
public static Object Superscript = new CharacterConstants("superscript");
395
public static Object Underline = new CharacterConstants("underline");
921
/** An alias for {@link ColorConstants#Background}. */
922
public static final Object Background = ColorConstants.Background;
924
/** A key for the bidi level character attribute. */
925
public static final Object BidiLevel = new CharacterConstants("bidiLevel");
927
/** An alias for {@link FontConstants#Bold}. */
928
public static final Object Bold = FontConstants.Bold;
930
/** A key for the component character attribute. */
931
public static final Object ComponentAttribute
932
= new CharacterConstants("component");
934
/** An alias for {@link FontConstants#Family}. */
935
public static final Object Family = FontConstants.Family;
937
/** An alias for {@link FontConstants#Size}. */
938
public static final Object Size = FontConstants.Size;
940
/** An alias for {@link ColorConstants#Foreground}. */
941
public static final Object Foreground = ColorConstants.Foreground;
943
/** A key for the icon character attribute. */
944
public static final Object IconAttribute = new CharacterConstants("icon");
946
/** A key for the italic character attribute. */
947
public static final Object Italic = FontConstants.Italic;
949
/** A key for the strike through character attribute. */
950
public static final Object StrikeThrough
951
= new CharacterConstants("strikethrough");
953
/** A key for the subscript character attribute. */
954
public static final Object Subscript = new CharacterConstants("subscript");
956
/** A key for the superscript character attribute. */
957
public static final Object Superscript
958
= new CharacterConstants("superscript");
960
/** A key for the underline character attribute. */
961
public static final Object Underline = new CharacterConstants("underline");
966
* A set of keys for attributes that relate to colors.
398
968
public static class ColorConstants
399
969
extends StyleConstants
400
970
implements AttributeSet.ColorAttribute, AttributeSet.CharacterAttribute
973
* Private constructor prevents new instances being created.
975
* @param k the key name.
402
977
private ColorConstants(String k)
406
public static Object Foreground = new ColorConstants("foreground");
407
public static Object Background = new ColorConstants("background");
982
/** A key for the foreground color attribute. */
983
public static final Object Foreground = new ColorConstants("foreground");
985
/** A key for the background color attribute. */
986
public static final Object Background = new ColorConstants("background");
990
* A set of keys for attributes that apply to fonts.
410
992
public static class FontConstants
411
993
extends StyleConstants
412
994
implements AttributeSet.FontAttribute, AttributeSet.CharacterAttribute
997
* Private constructor prevents new instances being created.
999
* @param k the key name.
414
1001
private FontConstants(String k)
418
public static Object Bold = new FontConstants("bold");
419
public static Object Family = new FontConstants("family");
420
public static Object Italic = new FontConstants("italic");
421
public static Object Size = new FontConstants("size");
1006
/** A key for the bold font attribute. */
1007
public static final Object Bold = new FontConstants("bold");
1009
/** A key for the family font attribute. */
1010
public static final Object Family = new FontConstants("family");
1012
/** A key for the italic font attribute. */
1013
public static final Object Italic = new FontConstants("italic");
1015
/** A key for the size font attribute. */
1016
public static final Object Size = new FontConstants("size");
1020
* A set of keys for attributes that apply to paragraphs.
424
1022
public static class ParagraphConstants
425
1023
extends StyleConstants
426
1024
implements AttributeSet.ParagraphAttribute
1027
* Private constructor prevents new instances being created.
1029
* @param k the key name.
428
1031
private ParagraphConstants(String k)
432
public static Object Alignment = new ParagraphConstants("Alignment");
433
public static Object FirstLineIndent = new ParagraphConstants("FirstLineIndent");
434
public static Object LeftIndent = new ParagraphConstants("LeftIndent");
435
public static Object LineSpacing = new ParagraphConstants("LineSpacing");
436
public static Object Orientation = new ParagraphConstants("Orientation");
437
public static Object RightIndent = new ParagraphConstants("RightIndent");
438
public static Object SpaceAbove = new ParagraphConstants("SpaceAbove");
439
public static Object SpaceBelow = new ParagraphConstants("SpaceBelow");
440
public static Object TabSet = new ParagraphConstants("TabSet");
1036
/** A key for the alignment paragraph attribute. */
1037
public static final Object Alignment = new ParagraphConstants("Alignment");
1039
/** A key for the first line indentation paragraph attribute. */
1040
public static final Object FirstLineIndent
1041
= new ParagraphConstants("FirstLineIndent");
1043
/** A key for the left indentation paragraph attribute. */
1044
public static final Object LeftIndent
1045
= new ParagraphConstants("LeftIndent");
1047
/** A key for the line spacing paragraph attribute. */
1048
public static final Object LineSpacing
1049
= new ParagraphConstants("LineSpacing");
1051
/** A key for the orientation paragraph attribute. */
1052
public static final Object Orientation
1053
= new ParagraphConstants("Orientation");
1055
/** A key for the right indentation paragraph attribute. */
1056
public static final Object RightIndent
1057
= new ParagraphConstants("RightIndent");
1059
/** A key for the 'space above' paragraph attribute. */
1060
public static final Object SpaceAbove
1061
= new ParagraphConstants("SpaceAbove");
1063
/** A key for the 'space below' paragraph attribute. */
1064
public static final Object SpaceBelow
1065
= new ParagraphConstants("SpaceBelow");
1067
/** A key for the tabset paragraph attribute. */
1068
public static final Object TabSet = new ParagraphConstants("TabSet");