Source Code Cross Referenced for SFont.java in  » Swing-Library » Swinglets » com » javelin » swinglets » 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 » Swing Library » Swinglets » com.javelin.swinglets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Javelin Software, All rights reserved.
003:         */
004:
005:        package com.javelin.swinglets;
006:
007:        import java.util.*;
008:
009:        /**
010:         * SFont is used to cache fonts. 
011:         * 
012:         * @author Robin Sharp
013:         */
014:
015:        public class SFont {
016:            /**
017:             * Style PLAIN
018:             */
019:            public static final int PLAIN = 0;
020:            /**
021:             * Style BOLD
022:             */
023:            public static final int BOLD = 1;
024:            /**
025:             * Style ITALIC
026:             */
027:            public static final int ITALIC = 2;
028:            /**
029:             * Style MONOSPACED
030:             */
031:            public static final int MONOSPACED = 4;
032:            /**
033:             * Style BIG
034:             */
035:            public static final int BIG = 8;
036:
037:            /**
038:             * Style SMALL
039:             */
040:            public static final int SMALL = 16;
041:
042:            /**
043:             * Style UNDERLINED
044:             */
045:            public static final int UNDERLINED = 32;
046:
047:            /**
048:             * Style HEADING1
049:             */
050:            public static final int HEADING1 = 64;
051:
052:            /**
053:             * Style STRIKE
054:             */
055:            public static final int STRIKE = 128;
056:
057:            /**
058:             * Get a font with the format "name:style:size" (String,int,int)
059:             */
060:            public synchronized static SFont getFont(String font)
061:                    throws IllegalArgumentException {
062:                try {
063:                    return getFont(font.substring(0, font.indexOf(':')),
064:                            Integer.parseInt(font.substring(
065:                                    font.indexOf(':') + 1, font
066:                                            .lastIndexOf(':'))), Integer
067:                                    .parseInt(font.substring(font
068:                                            .lastIndexOf(':') + 1)));
069:                } catch (Exception e) {
070:                    throw new IllegalArgumentException(
071:                            "Cannot parse font string " + font);
072:                }
073:            }
074:
075:            /**
076:             * Get a cached font
077:             */
078:            public synchronized static SFont getFont(String fontName,
079:                    int style, int size) {
080:                if (fontName == null)
081:                    fontName = "";
082:
083:                Integer key = new Integer(fontName.hashCode() ^ style ^ size);
084:
085:                SFont font = (SFont) fonts.get(key);
086:
087:                if (font == null) {
088:                    font = new SFont(fontName, style, size);
089:                    fonts.put(key, font);
090:                }
091:
092:                return font;
093:            }
094:
095:            /**
096:             * Construct a fully qualified SFont.
097:             */
098:            protected SFont(String name, int style, int size) {
099:                this .name = name;
100:                this .style = style;
101:                this .size = size;
102:            }
103:
104:            /**
105:             * Get the Name.
106:             */
107:            public String getName() {
108:                return name;
109:            }
110:
111:            /**
112:             * Get the SFont Style.
113:             */
114:            public int getStyle() {
115:                return style;
116:            }
117:
118:            /**
119:             * Get the SFont Size.
120:             */
121:            public int getSize() {
122:                return size;
123:            }
124:
125:            public boolean isPlain() {
126:                return style == 0;
127:            }
128:
129:            public boolean isBold() {
130:                return (style & BOLD) != 0;
131:            }
132:
133:            public boolean isItalic() {
134:                return (style & ITALIC) != 0;
135:            }
136:
137:            public boolean isMonoSpaced() {
138:                return (style & MONOSPACED) != 0;
139:            }
140:
141:            public boolean isBig() {
142:                return (style & BIG) != 0;
143:            }
144:
145:            public boolean isSmall() {
146:                return (style & SMALL) != 0;
147:            }
148:
149:            public boolean isUnderlined() {
150:                return (style & UNDERLINED) != 0;
151:            }
152:
153:            public boolean isHeading1() {
154:                return (style & HEADING1) != 0;
155:            }
156:
157:            public boolean isStrike() {
158:                return (style & STRIKE) != 0;
159:            }
160:
161:            protected String name;
162:            protected int style;
163:            protected int size;
164:            protected int phrase;
165:
166:            protected static Hashtable fonts = new Hashtable();
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.