Source Code Cross Referenced for FontMetrics.java in  » Apache-Harmony-Java-SE » java-package » java » awt » 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 » java package » java.awt 
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 Ilya S. Okomin
019:         * @version $Revision$
020:         */package java.awt;
021:
022:        import java.awt.font.FontRenderContext;
023:        import java.awt.font.LineMetrics;
024:        import java.awt.geom.Rectangle2D;
025:        import java.io.Serializable;
026:        import java.text.CharacterIterator;
027:
028:        import org.apache.harmony.awt.internal.nls.Messages;
029:
030:        public abstract class FontMetrics implements  Serializable {
031:            private static final long serialVersionUID = 1681126225205050147L;
032:
033:            protected Font font;
034:
035:            protected FontMetrics(Font fnt) {
036:                this .font = fnt;
037:            }
038:
039:            @Override
040:            public String toString() {
041:                return this .getClass().getName() + "[font=" + this .getFont() + //$NON-NLS-1$
042:                        "ascent=" + this .getAscent() + //$NON-NLS-1$
043:                        ", descent=" + this .getDescent() + //$NON-NLS-1$
044:                        ", height=" + this .getHeight() + "]"; //$NON-NLS-1$ //$NON-NLS-2$
045:            }
046:
047:            public Font getFont() {
048:                return font;
049:            }
050:
051:            public int getHeight() {
052:                return this .getAscent() + this .getDescent() + this .getLeading();
053:            }
054:
055:            public int getAscent() {
056:                return 0;
057:            }
058:
059:            public int getDescent() {
060:                return 0;
061:            }
062:
063:            public int getLeading() {
064:                return 0;
065:            }
066:
067:            public LineMetrics getLineMetrics(CharacterIterator ci,
068:                    int beginIndex, int limit, Graphics context) {
069:                return font.getLineMetrics(ci, beginIndex, limit, this 
070:                        .getFRCFromGraphics(context));
071:            }
072:
073:            public LineMetrics getLineMetrics(String str, Graphics context) {
074:                return font.getLineMetrics(str, this 
075:                        .getFRCFromGraphics(context));
076:            }
077:
078:            public LineMetrics getLineMetrics(char[] chars, int beginIndex,
079:                    int limit, Graphics context) {
080:                return font.getLineMetrics(chars, beginIndex, limit, this 
081:                        .getFRCFromGraphics(context));
082:            }
083:
084:            public LineMetrics getLineMetrics(String str, int beginIndex,
085:                    int limit, Graphics context) {
086:                return font.getLineMetrics(str, beginIndex, limit, this 
087:                        .getFRCFromGraphics(context));
088:            }
089:
090:            public Rectangle2D getMaxCharBounds(Graphics context) {
091:                return this .font.getMaxCharBounds(this 
092:                        .getFRCFromGraphics(context));
093:            }
094:
095:            public Rectangle2D getStringBounds(CharacterIterator ci,
096:                    int beginIndex, int limit, Graphics context) {
097:                return font.getStringBounds(ci, beginIndex, limit, this 
098:                        .getFRCFromGraphics(context));
099:            }
100:
101:            public Rectangle2D getStringBounds(String str, int beginIndex,
102:                    int limit, Graphics context) {
103:                return font.getStringBounds(str, beginIndex, limit, this 
104:                        .getFRCFromGraphics(context));
105:            }
106:
107:            public Rectangle2D getStringBounds(char[] chars, int beginIndex,
108:                    int limit, Graphics context) {
109:                return font.getStringBounds(chars, beginIndex, limit, this 
110:                        .getFRCFromGraphics(context));
111:            }
112:
113:            public Rectangle2D getStringBounds(String str, Graphics context) {
114:                return font.getStringBounds(str, this 
115:                        .getFRCFromGraphics(context));
116:            }
117:
118:            public boolean hasUniformLineMetrics() {
119:                return this .font.hasUniformLineMetrics();
120:            }
121:
122:            public int bytesWidth(byte[] data, int off, int len) {
123:                int width = 0;
124:                if ((off >= data.length) || (off < 0)) {
125:                    // awt.13B=offset off is out of range
126:                    throw new IllegalArgumentException(Messages
127:                            .getString("awt.13B")); //$NON-NLS-1$
128:                }
129:
130:                if ((off + len > data.length)) {
131:                    // awt.13C=number of elements len is out of range
132:                    throw new IllegalArgumentException(Messages
133:                            .getString("awt.13C")); //$NON-NLS-1$
134:                }
135:
136:                for (int i = off; i < off + len; i++) {
137:                    width += charWidth(data[i]);
138:                }
139:
140:                return width;
141:            }
142:
143:            public int charsWidth(char[] data, int off, int len) {
144:                int width = 0;
145:                if ((off >= data.length) || (off < 0)) {
146:                    // awt.13B=offset off is out of range
147:                    throw new IllegalArgumentException(Messages
148:                            .getString("awt.13B")); //$NON-NLS-1$
149:                }
150:
151:                if ((off + len > data.length)) {
152:                    // awt.13C=number of elements len is out of range
153:                    throw new IllegalArgumentException(Messages
154:                            .getString("awt.13C")); //$NON-NLS-1$
155:                }
156:
157:                for (int i = off; i < off + len; i++) {
158:                    width += charWidth(data[i]);
159:                }
160:
161:                return width;
162:            }
163:
164:            public int charWidth(int ch) {
165:                return 0;
166:            }
167:
168:            public int charWidth(char ch) {
169:                return 0;
170:            }
171:
172:            public int getMaxAdvance() {
173:                return 0;
174:            }
175:
176:            public int getMaxAscent() {
177:                return 0;
178:            }
179:
180:            /**
181:             * @deprecated
182:             */
183:            @Deprecated
184:            public int getMaxDecent() {
185:                return 0;
186:            }
187:
188:            public int getMaxDescent() {
189:                return 0;
190:            }
191:
192:            public int[] getWidths() {
193:                return null;
194:            }
195:
196:            public int stringWidth(String str) {
197:                return 0;
198:            }
199:
200:            /**
201:             * Returns FontRenderContext instance of the Graphics context specified.
202:             * @param context the specified Graphics context
203:             * 
204:             * @return a FontRenderContext of the specified Graphics context.
205:             */
206:            private FontRenderContext getFRCFromGraphics(Graphics context) {
207:                FontRenderContext frc;
208:                if (context instanceof  Graphics2D) {
209:                    frc = ((Graphics2D) context).getFontRenderContext();
210:                } else {
211:                    frc = new FontRenderContext(null, false, false);
212:                }
213:
214:                return frc;
215:
216:            }
217:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.