Source Code Cross Referenced for AFMChar.java in  » PDF » jPod » de » intarsys » font » afm » 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 » PDF » jPod » de.intarsys.font.afm 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2007, intarsys consulting GmbH
003:         *
004:         * Redistribution and use in source and binary forms, with or without
005:         * modification, are permitted provided that the following conditions are met:
006:         *
007:         * - Redistributions of source code must retain the above copyright notice,
008:         *   this list of conditions and the following disclaimer.
009:         *
010:         * - Redistributions in binary form must reproduce the above copyright notice,
011:         *   this list of conditions and the following disclaimer in the documentation
012:         *   and/or other materials provided with the distribution.
013:         *
014:         * - Neither the name of intarsys nor the names of its contributors may be used
015:         *   to endorse or promote products derived from this software without specific
016:         *   prior written permission.
017:         *
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
021:         * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
022:         * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
023:         * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
024:         * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
025:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
026:         * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
027:         * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
028:         * POSSIBILITY OF SUCH DAMAGE.
029:         */
030:        package de.intarsys.font.afm;
031:
032:        import java.util.StringTokenizer;
033:
034:        import de.intarsys.tools.string.StringTools;
035:
036:        /**
037:         * A simple implementation for an AFM char metric object
038:         * 
039:         * <p>
040:         * This implementation will hold the information needed for implementing a
041:         * simple pdf field layout mechanism. All attributes but name, code, and with
042:         * are ignored.
043:         * </p>
044:         * 
045:         * <p>
046:         * See the "Adobe Font Metrics File Format Specification"
047:         * </p>
048:         */
049:        public class AFMChar {
050:            /*
051:             * todo under construction
052:             */
053:
054:            //
055:            public static String AFM_TOKEN_WX = "WX"; //$NON-NLS-1$
056:
057:            public static String AFM_TOKEN_W = "W"; //$NON-NLS-1$
058:
059:            public static String AFM_TOKEN_W0X = "W0X"; //$NON-NLS-1$
060:
061:            public static String AFM_TOKEN_W0 = "W0"; //$NON-NLS-1$
062:
063:            public static String AFM_TOKEN_N = "N"; //$NON-NLS-1$
064:
065:            public static String AFM_TOKEN_CH = "CH"; //$NON-NLS-1$
066:
067:            public static String AFM_TOKEN_C = "C"; //$NON-NLS-1$
068:
069:            // the char name
070:            private String name;
071:
072:            // the char code or -1
073:            private int code;
074:
075:            // the char width or 0
076:            private int width;
077:
078:            /**
079:             * AFMChar constructor comment.
080:             * 
081:             * @param code
082:             *            docme
083:             * @param width
084:             *            docme
085:             * @param name
086:             *            docme
087:             */
088:            protected AFMChar(int code, int width, String name) {
089:                super ();
090:                setCode(code);
091:                setWidth(width);
092:                setName(name);
093:            }
094:
095:            /**
096:             * Create a new glyph representation from the definition parsed from
097:             * <code>glyph</code>.
098:             * 
099:             * @param glyph
100:             *            A string containing a definition for the glyph.
101:             * 
102:             * @return The new glyph representation.
103:             */
104:            public static AFMChar create(String glyph) {
105:                int code = -1;
106:                int width = -1;
107:                String name = StringTools.EMPTY;
108:                StringTokenizer to = new StringTokenizer(glyph, ";"); //$NON-NLS-1$
109:                while (to.hasMoreTokens()) {
110:                    StringTokenizer tf = new StringTokenizer(to.nextToken());
111:                    if (!tf.hasMoreTokens()) {
112:                        continue;
113:                    }
114:
115:                    String field = tf.nextToken();
116:                    if (field.equals(AFM_TOKEN_C)) {
117:                        code = Integer.parseInt(tf.nextToken());
118:                    } else if (field.equals(AFM_TOKEN_CH)) {
119:                        String value = tf.nextToken();
120:                        code = Integer.parseInt(value.substring(1, value
121:                                .length() - 1), 16);
122:                    } else if (field.equals(AFM_TOKEN_WX)) {
123:                        width = Integer.parseInt(tf.nextToken());
124:                    } else if (field.equals(AFM_TOKEN_W0X)) {
125:                        width = Integer.parseInt(tf.nextToken());
126:                    } else if (field.equals(AFM_TOKEN_W)) {
127:                        width = Integer.parseInt(tf.nextToken());
128:                    } else if (field.equals(AFM_TOKEN_W0)) {
129:                        width = Integer.parseInt(tf.nextToken());
130:                    } else if (field.equals(AFM_TOKEN_N)) {
131:                        name = tf.nextToken();
132:                    }
133:                }
134:                return new AFMChar(code, width, name);
135:            }
136:
137:            /**
138:             * The glyphs code.
139:             * 
140:             * @return The glyphs code.
141:             */
142:            public int getCode() {
143:                return code;
144:            }
145:
146:            /**
147:             * The glyphs name.
148:             * 
149:             * @return The glyphs name.
150:             */
151:            public java.lang.String getName() {
152:                return name;
153:            }
154:
155:            /**
156:             * The glyphs width.
157:             * 
158:             * @return The glyphs width.
159:             */
160:            public int getWidth() {
161:                return width;
162:            }
163:
164:            /*
165:             * (non-Javadoc)
166:             * 
167:             * @see java.lang.Object#toString()
168:             */
169:            public String toString() {
170:                return "<" + getCode() + ", " + getWidth() + ", " + getName() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
171:            }
172:
173:            private void setCode(int newCode) {
174:                code = newCode;
175:            }
176:
177:            private void setName(java.lang.String newName) {
178:                name = newName;
179:            }
180:
181:            private void setWidth(int newWidth) {
182:                width = newWidth;
183:            }
184:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.