Source Code Cross Referenced for X11FontMetrics.java in  » 6.0-JDK-Platform » solaris » sun » awt » motif » 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 » 6.0 JDK Platform » solaris » sun.awt.motif 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1995-2004 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package sun.awt.motif;
027:
028:        import java.awt.*;
029:        import java.util.Hashtable;
030:        import sun.awt.PlatformFont;
031:
032:        /** 
033:         * A font metrics object for a WServer font.
034:         * 
035:         * @version 1.34, 05/05/07
036:         * @author Jim Graham
037:         */
038:        public class X11FontMetrics extends FontMetrics {
039:            /**
040:             * The widths of the first 256 characters.
041:             */
042:            int widths[];
043:
044:            /** 
045:             * The standard ascent of the font.  This is the logical height
046:             * above the baseline for the Alphanumeric characters and should
047:             * be used for determining line spacing.  Note, however, that some
048:             * characters in the font may extend above this height.
049:             */
050:            int ascent;
051:
052:            /** 
053:             * The standard descent of the font.  This is the logical height
054:             * below the baseline for the Alphanumeric characters and should
055:             * be used for determining line spacing.  Note, however, that some
056:             * characters in the font may extend below this height.
057:             */
058:            int descent;
059:
060:            /** 
061:             * The standard leading for the font.  This is the logical amount
062:             * of space to be reserved between the descent of one line of text
063:             * and the ascent of the next line.  The height metric is calculated
064:             * to include this extra space.
065:             */
066:            int leading;
067:
068:            /** 
069:             * The standard height of a line of text in this font.  This is
070:             * the distance between the baseline of adjacent lines of text.
071:             * It is the sum of the ascent+descent+leading.  There is no
072:             * guarantee that lines of text spaced at this distance will be
073:             * disjoint; such lines may overlap if some characters overshoot
074:             * the standard ascent and descent metrics.
075:             */
076:            int height;
077:
078:            /** 
079:             * The maximum ascent for all characters in this font.  No character
080:             * will extend further above the baseline than this metric.
081:             */
082:            int maxAscent;
083:
084:            /** 
085:             * The maximum descent for all characters in this font.  No character
086:             * will descend further below the baseline than this metric.
087:             */
088:            int maxDescent;
089:
090:            /** 
091:             * The maximum possible height of a line of text in this font.
092:             * Adjacent lines of text spaced this distance apart will be
093:             * guaranteed not to overlap.  Note, however, that many paragraphs
094:             * that contain ordinary alphanumeric text may look too widely
095:             * spaced if this metric is used to determine line spacing.  The
096:             * height field should be preferred unless the text in a given
097:             * line contains particularly tall characters.
098:             */
099:            int maxHeight;
100:
101:            /** 
102:             * The maximum advance width of any character in this font. 
103:             */
104:            int maxAdvance;
105:
106:            static {
107:                initIDs();
108:            }
109:
110:            /**
111:             * Initialize JNI field and method IDs for fields that may be
112:               accessed from C.
113:             */
114:            private static native void initIDs();
115:
116:            /**
117:             * Calculate the metrics from the given WServer and font.
118:             */
119:            public X11FontMetrics(Font font) {
120:                super (font);
121:                init();
122:            }
123:
124:            /**
125:             * Get leading
126:             */
127:            public int getLeading() {
128:                return leading;
129:            }
130:
131:            /**
132:             * Get ascent.
133:             */
134:            public int getAscent() {
135:                return ascent;
136:            }
137:
138:            /**
139:             * Get descent
140:             */
141:            public int getDescent() {
142:                return descent;
143:            }
144:
145:            /**
146:             * Get height
147:             */
148:            public int getHeight() {
149:                return height;
150:            }
151:
152:            /**
153:             * Get maxAscent
154:             */
155:            public int getMaxAscent() {
156:                return maxAscent;
157:            }
158:
159:            /**
160:             * Get maxDescent
161:             */
162:            public int getMaxDescent() {
163:                return maxDescent;
164:            }
165:
166:            /**
167:             * Get maxAdvance
168:             */
169:            public int getMaxAdvance() {
170:                return maxAdvance;
171:            }
172:
173:            /** 
174:             * Return the width of the specified string in this Font. 
175:             */
176:            public int stringWidth(String string) {
177:                return charsWidth(string.toCharArray(), 0, string.length());
178:            }
179:
180:            /**
181:             * Return the width of the specified char[] in this Font.
182:             */
183:            public int charsWidth(char chars[], int offset, int length) {
184:                Font font = getFont();
185:                PlatformFont pf = ((PlatformFont) font.getPeer());
186:                if (pf.mightHaveMultiFontMetrics()) {
187:                    return getMFCharsWidth(chars, offset, length, font);
188:                } else {
189:                    if (widths != null) {
190:                        int w = 0;
191:                        for (int i = offset; i < offset + length; i++) {
192:                            int ch = chars[i];
193:                            if (ch < 0 || ch >= widths.length) {
194:                                w += maxAdvance;
195:                            } else {
196:                                w += widths[ch];
197:                            }
198:                        }
199:                        return w;
200:                    } else {
201:                        return maxAdvance * length;
202:                    }
203:                }
204:            }
205:
206:            private native int getMFCharsWidth(char chars[], int offset,
207:                    int length, Font font);
208:
209:            /**
210:             * Return the width of the specified byte[] in this Font. 
211:             */
212:            public native int bytesWidth(byte data[], int off, int len);
213:
214:            /**
215:             * Get the widths of the first 256 characters in the font.
216:             */
217:            public int[] getWidths() {
218:                return widths;
219:            }
220:
221:            native void init();
222:
223:            static Hashtable table = new Hashtable();
224:
225:            static synchronized FontMetrics getFontMetrics(Font font) {
226:                FontMetrics fm = (FontMetrics) table.get(font);
227:                if (fm == null) {
228:                    table.put(font, fm = new X11FontMetrics(font));
229:                }
230:                return fm;
231:            }
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.