1 |
/* TextAttribute.java -- |
/* TextAttribute.java -- |
2 |
Copyright (C) 2003, 2004 Free Software Foundation, Inc. |
Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
41 |
import java.io.InvalidObjectException; |
import java.io.InvalidObjectException; |
42 |
import java.text.AttributedCharacterIterator; |
import java.text.AttributedCharacterIterator; |
43 |
|
|
44 |
|
/** |
45 |
|
* Attributes (and associated values) that can be used to define an |
46 |
|
* {@link java.text.AttributedString}. |
47 |
|
*/ |
48 |
public final class TextAttribute extends AttributedCharacterIterator.Attribute |
public final class TextAttribute extends AttributedCharacterIterator.Attribute |
49 |
{ |
{ |
50 |
private static final long serialVersionUID = 7744112784117861702L; |
private static final long serialVersionUID = 7744112784117861702L; |
51 |
|
|
52 |
|
/** A key for the background paint attribute. */ |
53 |
public static final TextAttribute BACKGROUND = |
public static final TextAttribute BACKGROUND = |
54 |
new TextAttribute ("BACKGROUND"); |
new TextAttribute("background"); |
55 |
|
|
56 |
|
/** A key for the BIDI_EMBEDDING attribute. */ |
57 |
public static final TextAttribute BIDI_EMBEDDING = |
public static final TextAttribute BIDI_EMBEDDING = |
58 |
new TextAttribute ("BIDI_EMBEDDING"); |
new TextAttribute("bidi_embedding"); |
59 |
|
|
60 |
|
/** A key for the CHAR_REPLACEMENT attribute. */ |
61 |
public static final TextAttribute CHAR_REPLACEMENT = |
public static final TextAttribute CHAR_REPLACEMENT = |
62 |
new TextAttribute ("CHAR_REPLACEMENT"); |
new TextAttribute("char_replacement"); |
63 |
public static final TextAttribute FAMILY = new TextAttribute ("FAMILY"); |
|
64 |
public static final TextAttribute FONT = new TextAttribute ("FONT"); |
/** A key for the FAMILY attribute. */ |
65 |
public static final TextAttribute FOREGROUND = |
public static final TextAttribute FAMILY = new TextAttribute("family"); |
66 |
new TextAttribute ("FOREGROUND"); |
|
67 |
|
/** A key for the font attribute. */ |
68 |
|
public static final TextAttribute FONT = new TextAttribute("font"); |
69 |
|
|
70 |
|
/** A key for the foreground paint attribute. */ |
71 |
|
public static final TextAttribute FOREGROUND = |
72 |
|
new TextAttribute("foreground"); |
73 |
|
|
74 |
|
/** A key for the INPUT_METHOD_HIGHLIGHT attribute. */ |
75 |
public static final TextAttribute INPUT_METHOD_HIGHLIGHT = |
public static final TextAttribute INPUT_METHOD_HIGHLIGHT = |
76 |
new TextAttribute ("INPUT_METHOD_HIGHLIGHT"); |
new TextAttribute("input method highlight"); |
77 |
|
|
78 |
|
/** A key for the INPUT_METHOD_UNDERLINE attribute. */ |
79 |
public static final TextAttribute INPUT_METHOD_UNDERLINE = |
public static final TextAttribute INPUT_METHOD_UNDERLINE = |
80 |
new TextAttribute ("INPUT_METHOD_UNDERLINE"); |
new TextAttribute("input method underline"); |
81 |
|
|
82 |
|
/** A key for the text justification attribute. */ |
83 |
public static final TextAttribute JUSTIFICATION = |
public static final TextAttribute JUSTIFICATION = |
84 |
new TextAttribute ("JUSTIFICATION"); |
new TextAttribute("justification"); |
85 |
public static final Float JUSTIFICATION_FULL = new Float (1.0); |
|
86 |
public static final Float JUSTIFICATION_NONE = new Float (0.0); |
/** |
87 |
|
* A value that can be used with the {@link #JUSTIFICATION} attribute to |
88 |
|
* indicate full justification of the text. |
89 |
|
*/ |
90 |
|
public static final Float JUSTIFICATION_FULL = new Float(1.0); |
91 |
|
|
92 |
|
/** |
93 |
|
* A value that can be used with the {@link #JUSTIFICATION} attribute to |
94 |
|
* indicate no justification of the text. |
95 |
|
*/ |
96 |
|
public static final Float JUSTIFICATION_NONE = new Float(0.0); |
97 |
|
|
98 |
|
/** A key for the NUMERIC_SHAPING attribute. */ |
99 |
public static final TextAttribute NUMERIC_SHAPING = |
public static final TextAttribute NUMERIC_SHAPING = |
100 |
new TextAttribute ("NUMERIC_SHAPING"); |
new TextAttribute("numeric_shaping"); |
101 |
public static final TextAttribute POSTURE = new TextAttribute ("POSTURE"); |
|
102 |
public static final Float POSTURE_OBLIQUE = new Float (0.2); |
/** A key for the POSTURE attribute. */ |
103 |
public static final Float POSTURE_REGULAR = new Float (0.0); |
public static final TextAttribute POSTURE = new TextAttribute("posture"); |
104 |
|
|
105 |
|
/** A value that can be used with the {@link #POSTURE} attribute. */ |
106 |
|
public static final Float POSTURE_OBLIQUE = new Float(0.2); |
107 |
|
|
108 |
|
/** A value that can be used with the {@link #POSTURE} attribute. */ |
109 |
|
public static final Float POSTURE_REGULAR = new Float(0.0); |
110 |
|
|
111 |
|
/** A key for the RUN_DIRECTION attribute. */ |
112 |
public static final TextAttribute RUN_DIRECTION = |
public static final TextAttribute RUN_DIRECTION = |
113 |
new TextAttribute ("RUN_DIRECTION"); |
new TextAttribute("run_direction"); |
114 |
public static final Boolean RUN_DIRECTION_LTR = Boolean.TRUE; |
|
115 |
public static final Boolean RUN_DIRECTION_RTL = Boolean.FALSE; |
/** A value that can be used with the {@link #RUN_DIRECTION} attribute. */ |
116 |
public static final TextAttribute SIZE = new TextAttribute ("SIZE"); |
public static final Boolean RUN_DIRECTION_LTR = Boolean.FALSE; |
117 |
|
|
118 |
|
/** A value that can be used with the {@link #RUN_DIRECTION} attribute. */ |
119 |
|
public static final Boolean RUN_DIRECTION_RTL = Boolean.TRUE; |
120 |
|
|
121 |
|
/** A key for the text size attribute. */ |
122 |
|
public static final TextAttribute SIZE = new TextAttribute("size"); |
123 |
|
|
124 |
|
/** A key for the STRIKETHROUGH attribute. */ |
125 |
public static final TextAttribute STRIKETHROUGH = |
public static final TextAttribute STRIKETHROUGH = |
126 |
new TextAttribute ("STRIKETHROUGH"); |
new TextAttribute("strikethrough"); |
127 |
|
|
128 |
|
/** A value that can be used with the {@link #STRIKETHROUGH} attribute. */ |
129 |
public static final Boolean STRIKETHROUGH_ON = Boolean.TRUE; |
public static final Boolean STRIKETHROUGH_ON = Boolean.TRUE; |
130 |
|
|
131 |
|
/** A key for the SUPERSCRIPT attribute. */ |
132 |
public static final TextAttribute SUPERSCRIPT = |
public static final TextAttribute SUPERSCRIPT = |
133 |
new TextAttribute ("SUPERSCRIPT"); |
new TextAttribute("superscript"); |
134 |
public static final Integer SUPERSCRIPT_SUB = new Integer (-1); |
|
135 |
public static final Integer SUPERSCRIPT_SUPER = new Integer (1); |
/** A value that can be used with the {@link #SUPERSCRIPT} attribute. */ |
136 |
|
public static final Integer SUPERSCRIPT_SUB = new Integer(-1); |
137 |
|
|
138 |
|
/** A value that can be used with the {@link #SUPERSCRIPT} attribute. */ |
139 |
|
public static final Integer SUPERSCRIPT_SUPER = new Integer(1); |
140 |
|
|
141 |
|
/** A key for the SWAP_COLORS attribute. */ |
142 |
public static final TextAttribute SWAP_COLORS = |
public static final TextAttribute SWAP_COLORS = |
143 |
new TextAttribute ("SWAP_COLORS"); |
new TextAttribute("swap_colors"); |
144 |
|
|
145 |
|
/** A value that can be used with the {@link #SWAP_COLORS} attribute. */ |
146 |
public static final Boolean SWAP_COLORS_ON = Boolean.TRUE; |
public static final Boolean SWAP_COLORS_ON = Boolean.TRUE; |
147 |
public static final TextAttribute TRANSFORM = new TextAttribute ("TRANSFORM"); |
|
148 |
public static final TextAttribute UNDERLINE = new TextAttribute ("UNDERLINE"); |
/** A key for the TRANFORM attribute. */ |
149 |
public static final Integer UNDERLINE_LOW_DASHED = new Integer (0); |
public static final TextAttribute TRANSFORM = new TextAttribute("transform"); |
150 |
public static final Integer UNDERLINE_LOW_DOTTED = new Integer (0); |
|
151 |
public static final Integer UNDERLINE_LOW_GRAY = new Integer (0); |
/** A key for the UNDERLINE attribute. */ |
152 |
public static final Integer UNDERLINE_LOW_ONE_PIXEL = new Integer (0); |
public static final TextAttribute UNDERLINE = new TextAttribute("underline"); |
153 |
public static final Integer UNDERLINE_LOW_TWO_PIXEL = new Integer (0); |
|
154 |
public static final Integer UNDERLINE_ON = new Integer (0); |
/** A value that can be used with the {@link #UNDERLINE} attribute. */ |
155 |
public static final TextAttribute WEIGHT = new TextAttribute ("WEIGHT"); |
public static final Integer UNDERLINE_LOW_DASHED = new Integer(5); |
156 |
public static final Float WEIGHT_BOLD = new Float (2.0); |
|
157 |
public static final Float WEIGHT_DEMIBOLD = new Float (1.75); |
/** A value that can be used with the {@link #UNDERLINE} attribute. */ |
158 |
public static final Float WEIGHT_DEMILIGHT = new Float (0.875); |
public static final Integer UNDERLINE_LOW_DOTTED = new Integer(3); |
159 |
public static final Float WEIGHT_EXTRA_LIGHT = new Float (0.5); |
|
160 |
public static final Float WEIGHT_EXTRABOLD = new Float (2.5); |
/** A value that can be used with the {@link #UNDERLINE} attribute. */ |
161 |
public static final Float WEIGHT_HEAVY = new Float (2.25); |
public static final Integer UNDERLINE_LOW_GRAY = new Integer(4); |
162 |
public static final Float WEIGHT_LIGHT = new Float (0.75); |
|
163 |
public static final Float WEIGHT_MEDIUM = new Float (1.5); |
/** A value that can be used with the {@link #UNDERLINE} attribute. */ |
164 |
public static final Float WEIGHT_REGULAR = new Float (1.0); |
public static final Integer UNDERLINE_LOW_ONE_PIXEL = new Integer(1); |
165 |
public static final Float WEIGHT_SEMIBOLD = new Float (1.25); |
|
166 |
public static final Float WEIGHT_ULTRABOLD = new Float (2.75); |
/** A value that can be used with the {@link #UNDERLINE} attribute. */ |
167 |
public static final TextAttribute WIDTH = new TextAttribute (""); |
public static final Integer UNDERLINE_LOW_TWO_PIXEL = new Integer(2); |
168 |
public static final Float WIDTH_CONDENSED = new Float (0.75); |
|
169 |
public static final Float WIDTH_EXTENDED = new Float (1.5); |
/** A value that can be used with the {@link #UNDERLINE} attribute. */ |
170 |
public static final Float WIDTH_REGULAR = new Float (1.0); |
public static final Integer UNDERLINE_ON = new Integer(0); |
171 |
public static final Float WIDTH_SEMI_CONDENSED = new Float (0.875); |
|
172 |
public static final Float WIDTH_SEMI_EXTENDED = new Float (1.25); |
/** A key for the WEIGHT attribute. */ |
173 |
|
public static final TextAttribute WEIGHT = new TextAttribute("weight"); |
174 |
protected TextAttribute (String name) |
|
175 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
176 |
|
public static final Float WEIGHT_BOLD = new Float(2.0); |
177 |
|
|
178 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
179 |
|
public static final Float WEIGHT_DEMIBOLD = new Float(1.75); |
180 |
|
|
181 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
182 |
|
public static final Float WEIGHT_DEMILIGHT = new Float(0.875); |
183 |
|
|
184 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
185 |
|
public static final Float WEIGHT_EXTRA_LIGHT = new Float(0.5); |
186 |
|
|
187 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
188 |
|
public static final Float WEIGHT_EXTRABOLD = new Float(2.5); |
189 |
|
|
190 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
191 |
|
public static final Float WEIGHT_HEAVY = new Float(2.25); |
192 |
|
|
193 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
194 |
|
public static final Float WEIGHT_LIGHT = new Float(0.75); |
195 |
|
|
196 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
197 |
|
public static final Float WEIGHT_MEDIUM = new Float(1.5); |
198 |
|
|
199 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
200 |
|
public static final Float WEIGHT_REGULAR = new Float(1.0); |
201 |
|
|
202 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
203 |
|
public static final Float WEIGHT_SEMIBOLD = new Float(1.25); |
204 |
|
|
205 |
|
/** A value that can be used with the {@link #WEIGHT} attribute. */ |
206 |
|
public static final Float WEIGHT_ULTRABOLD = new Float(2.75); |
207 |
|
|
208 |
|
/** A key for the WIDTH attribute. */ |
209 |
|
public static final TextAttribute WIDTH = new TextAttribute("width"); |
210 |
|
|
211 |
|
/** A value that can be used with the {@link #WIDTH} attribute. */ |
212 |
|
public static final Float WIDTH_CONDENSED = new Float(0.75); |
213 |
|
|
214 |
|
/** A value that can be used with the {@link #WIDTH} attribute. */ |
215 |
|
public static final Float WIDTH_EXTENDED = new Float(1.5); |
216 |
|
|
217 |
|
/** A value that can be used with the {@link #WIDTH} attribute. */ |
218 |
|
public static final Float WIDTH_REGULAR = new Float(1.0); |
219 |
|
|
220 |
|
/** A value that can be used with the {@link #WIDTH} attribute. */ |
221 |
|
public static final Float WIDTH_SEMI_CONDENSED = new Float(0.875); |
222 |
|
|
223 |
|
/** A value that can be used with the {@link #WIDTH} attribute. */ |
224 |
|
public static final Float WIDTH_SEMI_EXTENDED = new Float(1.25); |
225 |
|
|
226 |
|
/** |
227 |
|
* Creates a new attribute. |
228 |
|
* |
229 |
|
* @param name the name. |
230 |
|
*/ |
231 |
|
protected TextAttribute(String name) |
232 |
{ |
{ |
233 |
super (name); |
super(name); |
234 |
} |
} |
235 |
|
|
236 |
protected Object readResolve () |
/** |
237 |
|
* After deserialization, this method ensures that only one instance of |
238 |
|
* each attribute is used. |
239 |
|
* |
240 |
|
* @return The (single) attribute instance. |
241 |
|
* |
242 |
|
* @throws InvalidObjectException if the attribute is not recognised. |
243 |
|
*/ |
244 |
|
protected Object readResolve() |
245 |
throws InvalidObjectException |
throws InvalidObjectException |
246 |
{ |
{ |
247 |
throw new Error ("not implemented"); |
if (this.getName().equals("background")) |
248 |
|
return BACKGROUND; |
249 |
|
|
250 |
|
if (this.getName().equals("bidi_embedding")) |
251 |
|
return BIDI_EMBEDDING; |
252 |
|
|
253 |
|
if (this.getName().equals("char_replacement")) |
254 |
|
return CHAR_REPLACEMENT; |
255 |
|
|
256 |
|
if (this.getName().equals("family")) |
257 |
|
return FAMILY; |
258 |
|
|
259 |
|
if (this.getName().equals("font")) |
260 |
|
return FONT; |
261 |
|
|
262 |
|
if (this.getName().equals("foreground")) |
263 |
|
return FOREGROUND; |
264 |
|
|
265 |
|
if (this.getName().equals("input method highlight")) |
266 |
|
return INPUT_METHOD_HIGHLIGHT; |
267 |
|
|
268 |
|
if (this.getName().equals("input method underline")) |
269 |
|
return INPUT_METHOD_UNDERLINE; |
270 |
|
|
271 |
|
if (this.getName().equals("justification")) |
272 |
|
return JUSTIFICATION; |
273 |
|
|
274 |
|
if (this.getName().equals("numeric_shaping")) |
275 |
|
return NUMERIC_SHAPING; |
276 |
|
|
277 |
|
if (this.getName().equals("posture")) |
278 |
|
return POSTURE; |
279 |
|
|
280 |
|
if (this.getName().equals("run_direction")) |
281 |
|
return RUN_DIRECTION; |
282 |
|
|
283 |
|
if (this.getName().equals("size")) |
284 |
|
return SIZE; |
285 |
|
|
286 |
|
if (this.getName().equals("strikethrough")) |
287 |
|
return STRIKETHROUGH; |
288 |
|
|
289 |
|
if (this.getName().equals("superscript")) |
290 |
|
return SUPERSCRIPT; |
291 |
|
|
292 |
|
if (this.getName().equals("swap_colors")) |
293 |
|
return SWAP_COLORS; |
294 |
|
|
295 |
|
if (this.getName().equals("transform")) |
296 |
|
return TRANSFORM; |
297 |
|
|
298 |
|
if (this.getName().equals("underline")) |
299 |
|
return UNDERLINE; |
300 |
|
|
301 |
|
if (this.getName().equals("weight")) |
302 |
|
return WEIGHT; |
303 |
|
|
304 |
|
if (this.getName().equals("width")) |
305 |
|
return WIDTH; |
306 |
|
|
307 |
|
throw new InvalidObjectException("Can't resolve Attribute: " + getName()); |
308 |
} |
} |
309 |
} |
} |