Source Code Cross Referenced for Font.java in  » Ajax » NextApp-Echo2 » nextapp » echo2 » app » 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 » Ajax » NextApp Echo2 » nextapp.echo2.app 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* 
002:         * This file is part of the Echo Web Application Framework (hereinafter "Echo").
003:         * Copyright (C) 2002-2005 NextApp, Inc.
004:         *
005:         * Version: MPL 1.1/GPL 2.0/LGPL 2.1
006:         *
007:         * The contents of this file are subject to the Mozilla Public License Version
008:         * 1.1 (the "License"); you may not use this file except in compliance with
009:         * the License. You may obtain a copy of the License at
010:         * http://www.mozilla.org/MPL/
011:         *
012:         * Software distributed under the License is distributed on an "AS IS" basis,
013:         * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
014:         * for the specific language governing rights and limitations under the
015:         * License.
016:         *
017:         * Alternatively, the contents of this file may be used under the terms of
018:         * either the GNU General Public License Version 2 or later (the "GPL"), or
019:         * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
020:         * in which case the provisions of the GPL or the LGPL are applicable instead
021:         * of those above. If you wish to allow use of your version of this file only
022:         * under the terms of either the GPL or the LGPL, and not to allow others to
023:         * use your version of this file under the terms of the MPL, indicate your
024:         * decision by deleting the provisions above and replace them with the notice
025:         * and other provisions required by the GPL or the LGPL. If you do not delete
026:         * the provisions above, a recipient may use your version of this file under
027:         * the terms of any one of the MPL, the GPL or the LGPL.
028:         */
029:
030:        package nextapp.echo2.app;
031:
032:        import java.io.Serializable;
033:
034:        /**
035:         * An immutable representation of a text font, including typeface, size, and 
036:         * style.
037:         */
038:        public class Font implements  Serializable {
039:
040:            /**
041:             * An immutable representation of a type face.
042:             * A typeface may specify an alternate <code>TypeFace</code> object
043:             * in the event that the primary one is not available on a given
044:             * client.  In this way, a chain of alternates may be created for
045:             * a very specific face, e.g.:
046:             * &quot;Verdana-&gt;Arial-&gt;Helvetica-&gt;Sans-Serif&quot;
047:             */
048:            public static class Typeface implements  Serializable {
049:
050:                private String name;
051:                private Typeface alternate;
052:
053:                /**
054:                 * Creates a new <code>Typeface</code>.
055:                 * 
056:                 * @param name the typeface name
057:                 */
058:                public Typeface(String name) {
059:                    this (name, null);
060:                }
061:
062:                /**
063:                 * Creates a new <code>Typeface</code>.
064:                 * 
065:                 * @param name the typeface name
066:                 * @param alternate the alternate typeface which should be used, in
067:                 *        case the client does not support the specified typeface
068:                 */
069:                public Typeface(String name, Typeface alternate) {
070:                    super ();
071:                    if (name == null) {
072:                        throw new IllegalArgumentException(
073:                                "'name' argument cannot be null.");
074:                    }
075:                    this .name = name;
076:                    this .alternate = alternate;
077:                }
078:
079:                /**
080:                 * @see java.lang.Object#equals(java.lang.Object)
081:                 */
082:                public boolean equals(Object o) {
083:                    if (this  == o) {
084:                        return true;
085:                    }
086:                    if (!(o instanceof  Typeface)) {
087:                        return false;
088:                    }
089:                    Typeface that = (Typeface) o;
090:                    if (!this .name.equals(that.name)) {
091:                        return false;
092:                    }
093:                    if (this .alternate == null) {
094:                        return that.alternate == null;
095:                    }
096:                    return this .alternate.equals(that.alternate);
097:                }
098:
099:                /**
100:                 * Returns the alternate typeface.
101:                 * This method should be queried recursively until it returns null
102:                 * in order to determine all alternate typefaces.
103:                 * 
104:                 * @return the alternate <code>Typeface</code>
105:                 */
106:                public Typeface getAlternate() {
107:                    return alternate;
108:                }
109:
110:                /**
111:                 * Returns the name of the typeface.
112:                 * 
113:                 * @return the name of the typeface, e.g., 'Helvetica'
114:                 */
115:                public String getName() {
116:                    return name;
117:                }
118:
119:                /**
120:                 * Renders a debug representation of the object.
121:                 * 
122:                 * @see java.lang.Object#toString()
123:                 */
124:                public String toString() {
125:                    return alternate == null ? name : name + ", " + alternate;
126:                }
127:            }
128:
129:            public static final Typeface SANS_SERIF = new Typeface("Sans-Serif");
130:            public static final Typeface SERIF = new Typeface("Serif");
131:            public static final Typeface MONOSPACE = new Typeface("Monospace");
132:            public static final Typeface HELVETICA = new Typeface("Helvetica",
133:                    SANS_SERIF);
134:            public static final Typeface ARIAL = new Typeface("Arial",
135:                    HELVETICA);
136:            public static final Typeface VERDANA = new Typeface("Verdana",
137:                    ARIAL);
138:            public static final Typeface TIMES = new Typeface("Times", SERIF);
139:            public static final Typeface TIMES_ROMAN = new Typeface(
140:                    "Times Roman", TIMES);
141:            public static final Typeface TIMES_NEW_ROMAN = new Typeface(
142:                    "Times New Roman", TIMES_ROMAN);
143:            public static final Typeface COURIER = new Typeface("Courier",
144:                    MONOSPACE);
145:            public static final Typeface COURIER_NEW = new Typeface(
146:                    "Courier New", COURIER);
147:
148:            /**
149:             * A style value indicating no text attributes.
150:             */
151:            public static final int PLAIN = 0x0;
152:
153:            /**
154:             * A style value indicating bold.
155:             */
156:            public static final int BOLD = 0x1;
157:
158:            /**
159:             * A style value indicating bold.
160:             */
161:            public static final int ITALIC = 0x2;
162:
163:            /**
164:             * A style value indicating underline.
165:             */
166:            public static final int UNDERLINE = 0x4;
167:
168:            /**
169:             * A style value indicating overline.
170:             */
171:            public static final int OVERLINE = 0x8;
172:
173:            /**
174:             * A style value indicating line-through.
175:             */
176:            public static final int LINE_THROUGH = 0x10;
177:
178:            private Typeface typeface;
179:            private Extent size;
180:            private int style;
181:
182:            /**
183:             * Creates a new <code>Font</code> with the specified <code>Typeface</code>,
184:             * size, and style.
185:             * 
186:             * @param typeface a <code>Typeface</code> describing the typeface of the font.
187:             * @param style the style of the font, one or more of the following values:
188:             *        <ul>
189:             *        <li>PLAIN</li>
190:             *        <li>BOLD</li>
191:             *        <li>ITALIC</li>
192:             *        <li>OVERLINE</li>
193:             *        <li>LINE_THROUGH</li>
194:             *        <li>UNDERLINE</li>
195:             *        </ul>
196:             *        If it is necessary create a font with multiple style attributes,
197:             *        they should be bitwise-ORed together, using an expression such as
198:             *        <code>BOLD | UNDERLINE</code>.
199:             * @param size the size of the font as a <code>Extent</code>
200:             */
201:            public Font(Typeface typeface, int style, Extent size) {
202:                super ();
203:                this .typeface = typeface;
204:                this .style = style;
205:                this .size = size;
206:            }
207:
208:            /**
209:             * @see java.lang.Object#equals(java.lang.Object)
210:             */
211:            public boolean equals(Object o) {
212:                if (this  == o) {
213:                    return true;
214:                }
215:                if (!(o instanceof  Font)) {
216:                    return false;
217:                }
218:                Font that = (Font) o;
219:                if (this .style != that.style) {
220:                    return false;
221:                }
222:                if (typeface == null) {
223:                    if (that.typeface != null) {
224:                        return false;
225:                    }
226:                } else {
227:                    if (!this .typeface.equals(that.typeface)) {
228:                        return false;
229:                    }
230:                }
231:                if (size == null) {
232:                    if (that.size != null) {
233:                        return false;
234:                    }
235:                } else {
236:                    if (!this .size.equals(that.size)) {
237:                        return false;
238:                    }
239:                }
240:                return true;
241:            }
242:
243:            /**
244:             * Returns the size of the font.
245:             * 
246:             * @return the size of the font
247:             */
248:            public Extent getSize() {
249:                return size;
250:            }
251:
252:            /**
253:             * Returns the typeface of the font.
254:             * 
255:             * @return the typeface of the font
256:             */
257:            public Typeface getTypeface() {
258:                return typeface;
259:            }
260:
261:            /**
262:             * Determines whether the font is bold.
263:             *
264:             * @return true if the font is bold
265:             */
266:            public boolean isBold() {
267:                return (style & BOLD) != 0;
268:            }
269:
270:            /**
271:             * Determines whether the font is italicized.
272:             *
273:             * @return true if the font is italicized
274:             */
275:            public boolean isItalic() {
276:                return (style & ITALIC) != 0;
277:            }
278:
279:            /**
280:             * Determines whether the font has line-through enabled.
281:             *
282:             * @return true if the font has line-through enabled
283:             */
284:            public boolean isLineThrough() {
285:                return (style & LINE_THROUGH) != 0;
286:            }
287:
288:            /**
289:             * Determines whether the font is plain (i.e., the font has no style
290:             * attributes set).
291:             *
292:             * @return true if the font is plain
293:             */
294:            public boolean isPlain() {
295:                return style == 0;
296:            }
297:
298:            /**
299:             * Determines whether the font has an overline.
300:             *
301:             * @return true if the font has an overline
302:             */
303:            public boolean isOverline() {
304:                return (style & OVERLINE) != 0;
305:            }
306:
307:            /**
308:             * Determines whether the font is underlined.
309:             *
310:             * @return true if the font is underlined
311:             */
312:            public boolean isUnderline() {
313:                return (style & UNDERLINE) != 0;
314:            }
315:
316:            /**
317:             * Renders a debug representation of the object.
318:             * 
319:             * @see java.lang.Object#toString()
320:             */
321:            public String toString() {
322:                StringBuffer out = new StringBuffer(Font.class.getName());
323:                out.append(" (");
324:                out.append(getTypeface());
325:                out.append(" /");
326:                if (isPlain()) {
327:                    out.append(" Plain");
328:                }
329:                if (isBold()) {
330:                    out.append(" Bold");
331:                }
332:                if (isItalic()) {
333:                    out.append(" Italic");
334:                }
335:                if (isLineThrough()) {
336:                    out.append(" LineThrough");
337:                }
338:                if (isOverline()) {
339:                    out.append(" Overline");
340:                }
341:                if (isUnderline()) {
342:                    out.append(" Underline");
343:                }
344:                out.append(" / ");
345:                out.append(getSize());
346:                out.append(")");
347:                return out.toString();
348:            }
349:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.