Source Code Cross Referenced for StyleConstants.java in  » Apache-Harmony-Java-SE » javax-package » javax » swing » text » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Apache Harmony Java SE » javax package » javax.swing.text 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:        /**
018:         * @author Alexey A. Ivanov
019:         * @version $Revision$
020:         */package javax.swing.text;
021:
022:        import java.awt.Color;
023:        import java.awt.Component;
024:        import javax.swing.Icon;
025:
026:        public class StyleConstants {
027:
028:            public static class CharacterConstants extends StyleConstants
029:                    implements  AttributeSet.CharacterAttribute {
030:
031:                private CharacterConstants(final String key) {
032:                    super (key);
033:                }
034:            }
035:
036:            public static class ColorConstants extends StyleConstants implements 
037:                    AttributeSet.ColorAttribute,
038:                    AttributeSet.CharacterAttribute {
039:                private ColorConstants(final String key) {
040:                    super (key);
041:                }
042:            }
043:
044:            public static class FontConstants extends StyleConstants implements 
045:                    AttributeSet.FontAttribute, AttributeSet.CharacterAttribute {
046:
047:                private FontConstants(final String key) {
048:                    super (key);
049:                }
050:            }
051:
052:            public static class ParagraphConstants extends StyleConstants
053:                    implements  AttributeSet.ParagraphAttribute {
054:
055:                private ParagraphConstants(final String key) {
056:                    super (key);
057:                }
058:            }
059:
060:            public static final String ComponentElementName = "component";
061:            public static final String IconElementName = "icon";
062:
063:            // CharacterConstants
064:
065:            public static final Object Underline = new CharacterConstants(
066:                    "underline");
067:
068:            public static final Object StrikeThrough = new CharacterConstants(
069:                    "strikethrough");
070:
071:            public static final Object Superscript = new CharacterConstants(
072:                    "superscript");
073:
074:            public static final Object Subscript = new CharacterConstants(
075:                    "subscript");
076:
077:            public static final Object ComponentAttribute = new CharacterConstants(
078:                    "component");
079:
080:            public static final Object IconAttribute = new CharacterConstants(
081:                    "icon");
082:
083:            public static final Object BidiLevel = new CharacterConstants(
084:                    "bidiLevel");
085:
086:            // ColorConstants
087:
088:            public static final Object Foreground = new ColorConstants(
089:                    "foreground");
090:            public static final Object Background = new ColorConstants(
091:                    "background");
092:
093:            // FontConstants
094:
095:            public static final Object Family = new FontConstants("family");
096:            public static final Object Size = new FontConstants("size");
097:            public static final Object Bold = new FontConstants("bold");
098:            public static final Object Italic = new FontConstants("italic");
099:
100:            public static final Object FontFamily = Family;
101:            public static final Object FontSize = Size;
102:
103:            // ParagraphConstants
104:
105:            public static final Object FirstLineIndent = new ParagraphConstants(
106:                    "FirstLineIndent");
107:
108:            public static final Object LeftIndent = new ParagraphConstants(
109:                    "LeftIndent");
110:
111:            public static final Object RightIndent = new ParagraphConstants(
112:                    "RightIndent");
113:
114:            public static final Object LineSpacing = new ParagraphConstants(
115:                    "LineSpacing");
116:
117:            public static final Object SpaceAbove = new ParagraphConstants(
118:                    "SpaceAbove");
119:
120:            public static final Object SpaceBelow = new ParagraphConstants(
121:                    "SpaceBelow");
122:
123:            public static final Object Alignment = new ParagraphConstants(
124:                    "Alignment");
125:
126:            public static final Object TabSet = new ParagraphConstants("TabSet");
127:
128:            public static final Object Orientation = new ParagraphConstants(
129:                    "orientation");
130:
131:            public static final Object NameAttribute = new StyleConstants(
132:                    "name");
133:
134:            public static final Object ResolveAttribute = new StyleConstants(
135:                    "resolver");
136:
137:            public static final Object ModelAttribute = new StyleConstants(
138:                    "model");
139:
140:            public static final Object ComposedTextAttribute = new StyleConstants(
141:                    "composed text");
142:
143:            public static final int ALIGN_LEFT = 0;
144:            public static final int ALIGN_CENTER = 1;
145:            public static final int ALIGN_RIGHT = 2;
146:            public static final int ALIGN_JUSTIFIED = 3;
147:
148:            /**
149:             * Contains attribute name.
150:             */
151:            private String attrKey;
152:
153:            StyleConstants(final String key) {
154:                this .attrKey = key;
155:            }
156:
157:            public String toString() {
158:                return attrKey;
159:            }
160:
161:            public static void setTabSet(final MutableAttributeSet a,
162:                    final TabSet tabs) {
163:                a.addAttribute(TabSet, tabs);
164:            }
165:
166:            public static TabSet getTabSet(final AttributeSet a) {
167:                return (TabSet) a.getAttribute(TabSet);
168:            }
169:
170:            public static void setIcon(final MutableAttributeSet a, final Icon c) {
171:                a.addAttribute(IconAttribute, c);
172:                a.addAttribute(AbstractDocument.ElementNameAttribute,
173:                        IconElementName);
174:            }
175:
176:            public static Icon getIcon(final AttributeSet a) {
177:                return (Icon) a.getAttribute(IconAttribute);
178:            }
179:
180:            public static void setFontFamily(final MutableAttributeSet a,
181:                    final String fam) {
182:                a.addAttribute(FontFamily, fam);
183:            }
184:
185:            public static String getFontFamily(final AttributeSet a) {
186:                String val = (String) a.getAttribute(FontFamily);
187:                return (val == null) ? "Monospaced" : val;
188:            }
189:
190:            public static void setComponent(final MutableAttributeSet a,
191:                    final Component c) {
192:                a.addAttribute(ComponentAttribute, c);
193:                a.addAttribute(AbstractDocument.ElementNameAttribute,
194:                        ComponentElementName);
195:            }
196:
197:            public static Component getComponent(final AttributeSet a) {
198:                return (Component) a.getAttribute(ComponentAttribute);
199:            }
200:
201:            public static void setForeground(final MutableAttributeSet a,
202:                    final Color fg) {
203:                a.addAttribute(Foreground, fg);
204:            }
205:
206:            public static void setBackground(final MutableAttributeSet a,
207:                    final Color bg) {
208:                a.addAttribute(Background, bg);
209:            }
210:
211:            public static Color getForeground(final AttributeSet a) {
212:                Color val = (Color) a.getAttribute(Foreground);
213:                return (val == null) ? Color.black : val;
214:            }
215:
216:            public static Color getBackground(final AttributeSet a) {
217:                Color val = (Color) a.getAttribute(Background);
218:                return (val == null) ? Color.black : val;
219:            }
220:
221:            public static void setUnderline(final MutableAttributeSet a,
222:                    final boolean b) {
223:                a.addAttribute(Underline, Boolean.valueOf(b));
224:            }
225:
226:            public static void setSuperscript(final MutableAttributeSet a,
227:                    final boolean b) {
228:                a.addAttribute(Superscript, Boolean.valueOf(b));
229:            }
230:
231:            public static void setSubscript(final MutableAttributeSet a,
232:                    final boolean b) {
233:                a.addAttribute(Subscript, Boolean.valueOf(b));
234:            }
235:
236:            public static void setStrikeThrough(final MutableAttributeSet a,
237:                    final boolean b) {
238:                a.addAttribute(StrikeThrough, Boolean.valueOf(b));
239:            }
240:
241:            public static void setItalic(final MutableAttributeSet a,
242:                    final boolean b) {
243:                a.addAttribute(Italic, Boolean.valueOf(b));
244:            }
245:
246:            public static void setBold(final MutableAttributeSet a,
247:                    final boolean b) {
248:                a.addAttribute(Bold, Boolean.valueOf(b));
249:            }
250:
251:            public static void setFontSize(final MutableAttributeSet a,
252:                    final int s) {
253:                // TODO in version 1.5.0 use Integer.valueOf instead of constructor
254:                a.addAttribute(FontSize, new Integer(s));
255:            }
256:
257:            public static void setBidiLevel(final MutableAttributeSet a,
258:                    final int o) {
259:                a.addAttribute(BidiLevel, new Integer(o));
260:            }
261:
262:            public static void setAlignment(final MutableAttributeSet a,
263:                    final int align) {
264:                a.addAttribute(Alignment, new Integer(align));
265:            }
266:
267:            public static void setSpaceBelow(final MutableAttributeSet a,
268:                    final float i) {
269:                // TODO in version 1.5.0 use Float.valueOf instead of constructor
270:                a.addAttribute(SpaceBelow, new Float(i));
271:            }
272:
273:            public static void setSpaceAbove(final MutableAttributeSet a,
274:                    final float i) {
275:                a.addAttribute(SpaceAbove, new Float(i));
276:            }
277:
278:            public static void setRightIndent(final MutableAttributeSet a,
279:                    final float i) {
280:                a.addAttribute(RightIndent, new Float(i));
281:            }
282:
283:            public static void setLineSpacing(final MutableAttributeSet a,
284:                    final float i) {
285:                a.addAttribute(LineSpacing, new Float(i));
286:            }
287:
288:            public static void setLeftIndent(final MutableAttributeSet a,
289:                    final float i) {
290:                a.addAttribute(LeftIndent, new Float(i));
291:            }
292:
293:            public static void setFirstLineIndent(final MutableAttributeSet a,
294:                    final float i) {
295:                a.addAttribute(FirstLineIndent, new Float(i));
296:            }
297:
298:            public static boolean isUnderline(final AttributeSet a) {
299:                Boolean val = (Boolean) a.getAttribute(Underline);
300:                return (val == null) ? false : val.booleanValue();
301:            }
302:
303:            public static boolean isSuperscript(final AttributeSet a) {
304:                Boolean val = (Boolean) a.getAttribute(Superscript);
305:                return (val == null) ? false : val.booleanValue();
306:            }
307:
308:            public static boolean isSubscript(final AttributeSet a) {
309:                Boolean val = (Boolean) a.getAttribute(Subscript);
310:                return (val == null) ? false : val.booleanValue();
311:            }
312:
313:            public static boolean isStrikeThrough(final AttributeSet a) {
314:                Boolean val = (Boolean) a.getAttribute(StrikeThrough);
315:                return (val == null) ? false : val.booleanValue();
316:            }
317:
318:            public static boolean isItalic(final AttributeSet a) {
319:                Boolean val = (Boolean) a.getAttribute(Italic);
320:                return (val == null) ? false : val.booleanValue();
321:            }
322:
323:            public static boolean isBold(final AttributeSet a) {
324:                Boolean val = (Boolean) a.getAttribute(Bold);
325:                return (val == null) ? false : val.booleanValue();
326:            }
327:
328:            public static int getFontSize(final AttributeSet a) {
329:                Integer size = (Integer) a.getAttribute(FontSize);
330:                return (size == null) ? 12 : size.intValue();
331:            }
332:
333:            public static int getBidiLevel(final AttributeSet a) {
334:                Integer level = (Integer) a.getAttribute(BidiLevel);
335:                return (level == null) ? 0 : level.intValue();
336:            }
337:
338:            public static int getAlignment(final AttributeSet a) {
339:                Integer align = (Integer) a.getAttribute(Alignment);
340:                return (align == null) ? ALIGN_LEFT : align.intValue();
341:            }
342:
343:            public static float getSpaceBelow(final AttributeSet a) {
344:                Float f = (Float) a.getAttribute(SpaceBelow);
345:                return (f == null) ? 0.f : f.floatValue();
346:            }
347:
348:            public static float getSpaceAbove(final AttributeSet a) {
349:                Float f = (Float) a.getAttribute(SpaceAbove);
350:                return (f == null) ? 0.f : f.floatValue();
351:            }
352:
353:            public static float getRightIndent(final AttributeSet a) {
354:                Float f = (Float) a.getAttribute(RightIndent);
355:                return (f == null) ? 0.f : f.floatValue();
356:            }
357:
358:            public static float getLineSpacing(final AttributeSet a) {
359:                Float f = (Float) a.getAttribute(LineSpacing);
360:                return (f == null) ? 0.f : f.floatValue();
361:            }
362:
363:            public static float getLeftIndent(final AttributeSet a) {
364:                Float f = (Float) a.getAttribute(LeftIndent);
365:                return (f == null) ? 0.f : f.floatValue();
366:            }
367:
368:            public static float getFirstLineIndent(final AttributeSet a) {
369:                Float f = (Float) a.getAttribute(FirstLineIndent);
370:                return (f == null) ? 0.f : f.floatValue();
371:            }
372:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.