summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/swing/text/StyleConstants.java
blob: 598eaf621bc92213b70e111429bcf94e00b7be1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
/* StyleConstants.java --
   Copyright (C) 2004, 2005 Free Software Foundation, Inc.

This file is part of GNU Classpath.

GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING.  If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.

Linking this library statically or dynamically with other modules is
making a combined work based on this library.  Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.

As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module.  An independent module is a module which is not derived from
or based on this library.  If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so.  If you do not wish to do so, delete this
exception statement from your version. */


package javax.swing.text;

import java.awt.Color;
import java.awt.Component;

import javax.swing.Icon;

public class StyleConstants
{
  public static final int ALIGN_LEFT = 0;
  public static final int ALIGN_CENTER = 1;
  public static final int ALIGN_RIGHT = 2;
  public static final int ALIGN_JUSTIFIED = 3;

  public static final Object Background = CharacterConstants.Background;
  public static final Object BidiLevel = CharacterConstants.BidiLevel;
  public static final Object Bold = CharacterConstants.Bold;
  public static final Object ComponentAttribute = CharacterConstants.ComponentAttribute;
  public static final Object Family = CharacterConstants.Family;
  public static final Object FontFamily = CharacterConstants.Family;  
  public static final Object FontSize = CharacterConstants.Size;
  public static final Object Foreground = CharacterConstants.Foreground;
  public static final Object IconAttribute = CharacterConstants.IconAttribute;
  public static final Object Italic = CharacterConstants.Italic;
  public static final Object Size = CharacterConstants.Size;
  public static final Object StrikeThrough = CharacterConstants.StrikeThrough;
  public static final Object Subscript = CharacterConstants.Subscript;
  public static final Object Superscript = CharacterConstants.Superscript;
  public static final Object Underline = CharacterConstants.Underline;

  public static final Object Alignment = ParagraphConstants.Alignment;
  public static final Object FirstLineIndent = ParagraphConstants.FirstLineIndent;
  public static final Object LeftIndent = ParagraphConstants.LeftIndent;
  public static final Object LineSpacing = ParagraphConstants.LineSpacing;
  public static final Object Orientation = ParagraphConstants.Orientation;
  public static final Object RightIndent = ParagraphConstants.RightIndent;
  public static final Object SpaceAbove = ParagraphConstants.SpaceAbove;
  public static final Object SpaceBelow = ParagraphConstants.SpaceBelow;
  public static final Object TabSet = ParagraphConstants.TabSet;

  public static final String ComponentElementName = "component";
  public static final String IconElementName = "icon";

  public static final Object ComposedTextAttribute = new StyleConstants("composed text");
  public static final Object ModelAttribute = new StyleConstants("model");
  public static final Object NameAttribute = new StyleConstants("name");
  public static final Object ResolveAttribute = new StyleConstants("resolver");

  String keyname;

  // Package-private to avoid accessor constructor for use by
  // subclasses.
  StyleConstants(String k) 
  {
    keyname = k;
  }

  public String toString()
  {
    return keyname;
  }

  public static int getAlignment(AttributeSet a)
  {
    if (a.isDefined(Alignment))
      return ((Integer)a.getAttribute(Alignment)).intValue();
    else
      return ALIGN_LEFT;      
  } 

  public static Color getBackground(AttributeSet a)
  {
    if (a.isDefined(Background))
      return (Color) a.getAttribute(Background);
    else
      return Color.WHITE;
  } 
  
  public static int getBidiLevel(AttributeSet a)
  {
    if (a.isDefined(BidiLevel))
      return ((Integer)a.getAttribute(BidiLevel)).intValue();
    else
      return 0;
  } 

  public static Component getComponent(AttributeSet a)
  {
    if (a.isDefined(ComponentAttribute))
      return (Component) a.getAttribute(ComponentAttribute);
    else
      return (Component) null;
  } 

  public static float getFirstLineIndent(AttributeSet a)
  {
    if (a.isDefined(FirstLineIndent))
      return ((Float)a.getAttribute(FirstLineIndent)).floatValue();
    else
      return 0.f;
  } 

  public static String getFontFamily(AttributeSet a)
  {
    if (a.isDefined(FontFamily))
      return (String) a.getAttribute(FontFamily);
    else
      return "Monospaced";
  } 

  public static int getFontSize(AttributeSet a)
  {
    if (a.isDefined(FontSize))
      return ((Integer)a.getAttribute(FontSize)).intValue();
    else
      return 12;
  } 

  public static Color getForeground(AttributeSet a)
  {
    if (a.isDefined(Foreground))
      return (Color) a.getAttribute(Foreground);
    else
      return Color.BLACK;
  } 

  public static Icon getIcon(AttributeSet a)
  {
    if (a.isDefined(IconAttribute))
      return (Icon) a.getAttribute(IconAttribute);
    else
      return (Icon) null;
  } 

  public static float getLeftIndent(AttributeSet a)
  {
    if (a.isDefined(LeftIndent))
      return ((Float)a.getAttribute(LeftIndent)).floatValue();
    else
      return 0.f;  
  } 

  public static float getLineSpacing(AttributeSet a)
  {
    if (a.isDefined(LineSpacing))
      return ((Float)a.getAttribute(LineSpacing)).floatValue();
    else
      return 0.f;  
  } 

  public static float getRightIndent(AttributeSet a)
  {
    if (a.isDefined(RightIndent))
      return ((Float)a.getAttribute(RightIndent)).floatValue();
    else
      return 0.f;  
  } 

  public static float getSpaceAbove(AttributeSet a)
  {
    if (a.isDefined(SpaceAbove))
      return ((Float)a.getAttribute(SpaceAbove)).floatValue();
    else
      return 0.f;  
  } 

  public static float getSpaceBelow(AttributeSet a)
  {
    if (a.isDefined(SpaceBelow))
      return ((Float)a.getAttribute(SpaceBelow)).floatValue();
    else
      return 0.f;  
  } 

  public static javax.swing.text.TabSet getTabSet(AttributeSet a)
  {
    if (a.isDefined(StyleConstants.TabSet))
      return (javax.swing.text.TabSet) a.getAttribute(StyleConstants.TabSet);
    else
      return (javax.swing.text.TabSet) null;
  } 

  public static boolean isBold(AttributeSet a)
  {
    if (a.isDefined(Bold))
      return ((Boolean) a.getAttribute(Bold)).booleanValue();
    else
      return false;    
  } 

  public static boolean isItalic(AttributeSet a)
  {
    if (a.isDefined(Italic))
      return ((Boolean) a.getAttribute(Italic)).booleanValue();
    else
      return false;    
  } 

  public static boolean isStrikeThrough(AttributeSet a)
  {
    if (a.isDefined(StrikeThrough))
      return ((Boolean) a.getAttribute(StrikeThrough)).booleanValue();
    else
      return false;    
  } 

  public static boolean isSubscript(AttributeSet a)
  {
    if (a.isDefined(Subscript))
      return ((Boolean) a.getAttribute(Subscript)).booleanValue();
    else
      return false;    
  } 

  public static boolean isSuperscript(AttributeSet a)
  {
    if (a.isDefined(Superscript))
      return ((Boolean) a.getAttribute(Superscript)).booleanValue();
    else
      return false;    
  } 

  public static boolean isUnderline(AttributeSet a)
  {
    if (a.isDefined(Underline))
      return ((Boolean) a.getAttribute(Underline)).booleanValue();
    else
      return false;    
  } 

  public static void setAlignment(MutableAttributeSet a, int align)
  {
    a.addAttribute(Alignment, new Integer(align));
  } 

  public static void setBackground(MutableAttributeSet a, Color fg)
  {
    a.addAttribute(Background, fg);
  } 

  public static void setBidiLevel(MutableAttributeSet a, int lev)
  {
    a.addAttribute(BidiLevel, new Integer(lev));
  } 

  public static void setBold(MutableAttributeSet a, boolean b)
  {
    a.addAttribute(Bold, Boolean.valueOf(b));
  } 
  
  public static void setComponent(MutableAttributeSet a, Component c)
  {
    a.addAttribute(ComponentAttribute, c);
  } 

  public static void setFirstLineIndent(MutableAttributeSet a, float i)
  {
    a.addAttribute(FirstLineIndent, new Float(i));
  } 

  public static void setFontFamily(MutableAttributeSet a, String fam)
  {
    a.addAttribute(FontFamily, fam);
  } 

  public static void setFontSize(MutableAttributeSet a, int s)
  {
    a.addAttribute(FontSize, new Integer(s));
  } 

  public static void setForeground(MutableAttributeSet a, Color fg)
  {
    a.addAttribute(Foreground, fg);
  }

  public static void setIcon(MutableAttributeSet a, Icon c)
  {
    a.addAttribute(IconAttribute, c);
  }
 
  public static void setItalic(MutableAttributeSet a, boolean b)
  {
    a.addAttribute(Italic, Boolean.valueOf(b));
  }
 
  public static void setLeftIndent(MutableAttributeSet a, float i)
  {
    a.addAttribute(LeftIndent, new Float(i));
  } 

  public static void setLineSpacing(MutableAttributeSet a, float i)
  {
    a.addAttribute(LineSpacing, new Float(i));
  } 

  public static void setRightIndent(MutableAttributeSet a, float i)
  {
    a.addAttribute(RightIndent, new Float(i));
  } 

  public static void setSpaceAbove(MutableAttributeSet a, float i)
  {
    a.addAttribute(SpaceAbove, new Float(i));
  } 

  public static void setSpaceBelow(MutableAttributeSet a, float i)
  {
    a.addAttribute(SpaceBelow, new Float(i));
  } 

  public static void setStrikeThrough(MutableAttributeSet a, boolean b)
  {
    a.addAttribute(StrikeThrough, Boolean.valueOf(b));
  } 

  public static void setSubscript(MutableAttributeSet a, boolean b)
  {
    a.addAttribute(Subscript, Boolean.valueOf(b));
  } 

  public static void setSuperscript(MutableAttributeSet a, boolean b)
  {
    a.addAttribute(Superscript, Boolean.valueOf(b));
  } 

  public static void setTabSet(MutableAttributeSet a, javax.swing.text.TabSet tabs)
  {
    a.addAttribute(StyleConstants.TabSet, tabs);
  } 

  public static void setUnderline(MutableAttributeSet a, boolean b)
  {
    a.addAttribute(Underline, Boolean.valueOf(b));
  } 

  // The remainder are so-called "typesafe enumerations" which 
  // alias subsets of the above constants.
  public static class CharacterConstants
    extends StyleConstants
    implements AttributeSet.CharacterAttribute
  {
    private CharacterConstants(String k) 
    {
      super(k);
    }
    
    public static Object Background = ColorConstants.Background;
    public static Object BidiLevel = new CharacterConstants("bidiLevel");
    public static Object Bold = FontConstants.Bold;
    public static Object ComponentAttribute = new CharacterConstants("component");
    public static Object Family = FontConstants.Family;
    public static Object Size = FontConstants.Size;
    public static Object Foreground = ColorConstants.Foreground;
    public static Object IconAttribute = new CharacterConstants("icon");
    public static Object Italic = FontConstants.Italic;
    public static Object StrikeThrough = new CharacterConstants("strikethrough");
    public static Object Subscript = new CharacterConstants("subscript");
    public static Object Superscript = new CharacterConstants("superscript");
    public static Object Underline = new CharacterConstants("underline");
  }

  public static class ColorConstants
    extends StyleConstants
    implements AttributeSet.ColorAttribute, AttributeSet.CharacterAttribute
  {
    private ColorConstants(String k) 
    {
      super(k);
    }
    public static Object Foreground = new ColorConstants("foreground");
    public static Object Background = new ColorConstants("background");
  }

  public static class FontConstants
    extends StyleConstants
    implements AttributeSet.FontAttribute, AttributeSet.CharacterAttribute
  {
    private FontConstants(String k) 
    {
      super(k);
    }
    public static Object Bold = new FontConstants("bold");
    public static Object Family = new FontConstants("family");
    public static Object Italic = new FontConstants("italic");
    public static Object Size = new FontConstants("size");
  }

  public static class ParagraphConstants
    extends StyleConstants
    implements AttributeSet.ParagraphAttribute
  {
    private ParagraphConstants(String k) 
    {
      super(k);
    }
    public static Object Alignment = new ParagraphConstants("Alignment");
    public static Object FirstLineIndent = new ParagraphConstants("FirstLineIndent");
    public static Object LeftIndent = new ParagraphConstants("LeftIndent");
    public static Object LineSpacing = new ParagraphConstants("LineSpacing");
    public static Object Orientation = new ParagraphConstants("Orientation");
    public static Object RightIndent = new ParagraphConstants("RightIndent");
    public static Object SpaceAbove = new ParagraphConstants("SpaceAbove");
    public static Object SpaceBelow = new ParagraphConstants("SpaceBelow");
    public static Object TabSet = new ParagraphConstants("TabSet");
  }

}
OpenPOWER on IntegriCloud