Source Code Cross Referenced for Glyph.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » awt » gl » font » 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 » org package » org.apache.harmony.awt.gl.font 
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 org.apache.harmony.awt.gl.font;
021:
022:        import java.awt.Shape;
023:        import java.awt.font.GlyphJustificationInfo;
024:        import java.awt.font.GlyphMetrics;
025:        import java.awt.image.BufferedImage;
026:
027:        public abstract class Glyph {
028:
029:            // character of the glyph
030:            protected char glChar;
031:
032:            // precise glyph metrics
033:            protected GlyphMetrics glMetrics;
034:
035:            // glyph metrics in pixels
036:            protected GlyphMetrics glPointMetrics;
037:
038:            //  glyph code of this Glyph
039:            int glCode;
040:
041:            // justification info of this glyph
042:            GlyphJustificationInfo glJustInfo;
043:
044:            // native font handle of the font corresponding to this glyph
045:            long pFont;
046:
047:            // size of the font corresponding to this glyph
048:            int fontSize;
049:
050:            // bitmap representation of the glyph
051:            byte[] bitmap = null;
052:
053:            // Buffered image representation of the glyph
054:            BufferedImage image;
055:
056:            // shape that representing the outline of this glyph
057:            protected Shape glOutline = null;
058:
059:            /**
060:             * image bitmap parameters
061:             */
062:
063:            //  top side bearing
064:            public int bmp_top = 0;
065:
066:            // left side bearing
067:            public int bmp_left = 0;
068:
069:            // number of bytes in row
070:            public int bmp_pitch;
071:
072:            // number of rows
073:            public int bmp_rows;
074:
075:            // width of the row
076:            public int bmp_width;
077:
078:            /**
079:             *  Retruns handle to Native Font object
080:             */
081:            public long getPFont() {
082:                return this .pFont;
083:            }
084:
085:            /**
086:             *  Retruns char value of this glyph object
087:             */
088:            public char getChar() {
089:                return glChar;
090:            }
091:
092:            /**
093:             *  Retruns precise width of this glyph object
094:             */
095:            public int getWidth() {
096:                return Math.round((float) getGlyphMetrics().getBounds2D()
097:                        .getWidth());
098:            }
099:
100:            /**
101:             *  Retruns precise height of this glyph object
102:             */
103:            public int getHeight() {
104:                return Math.round((float) getGlyphMetrics().getBounds2D()
105:                        .getHeight());
106:            }
107:
108:            /**
109:             *  Retruns glyph code of this glyph object
110:             */
111:            public int getGlyphCode() {
112:                return glCode;
113:            }
114:
115:            /**
116:             *  Retruns GlyphMetrics of this glyph object with precise metrics.
117:             */
118:            public GlyphMetrics getGlyphMetrics() {
119:                return glMetrics;
120:            }
121:
122:            /**
123:             *  Retruns GlyphMetrics of this glyph object in pixels.
124:             */
125:            public GlyphMetrics getGlyphPointMetrics() {
126:                return glPointMetrics;
127:            }
128:
129:            /**
130:             *  Retruns GlyphJustificationInfo of this glyph object
131:             */
132:            public GlyphJustificationInfo getGlyphJustificationInfo() {
133:                return glJustInfo;
134:            }
135:
136:            /**
137:             *  Sets JustificationInfo of this glyph object
138:             * 
139:             * @param newJustInfo GlyphJustificationInfo object to set to the Glyph object 
140:             */
141:            public void setGlyphJustificationInfo(
142:                    GlyphJustificationInfo newJustInfo) {
143:                this .glJustInfo = newJustInfo;
144:            }
145:
146:            /**
147:             * Returns an int array of 3 elements, so-called ABC structure that contains 
148:             * the width of the character:
149:             * 1st element = left side bearing of the glyph
150:             * 2nd element = width of the glyph
151:             * 3d element = right side bearing of the glyph 
152:             */
153:            public int[] getABC() {
154:                int[] abc = new int[3];
155:                abc[0] = (int) getGlyphMetrics().getLSB();
156:                abc[1] = (int) getGlyphMetrics().getBounds2D().getWidth();
157:                abc[2] = (int) getGlyphMetrics().getRSB();
158:
159:                return abc;
160:            }
161:
162:            /**
163:             * Sets BufferedImage representation of this glyph to the specified parameter.
164:             * 
165:             * @param newImage new BufferedImage object to be set as BufferedImage 
166:             * representation.
167:             */
168:            public void setImage(BufferedImage newImage) {
169:                this .image = newImage;
170:            }
171:
172:            /**
173:             * Returns true if this Glyph and specified object are equal.
174:             */
175:            @Override
176:            public boolean equals(Object obj) {
177:                if (obj == this ) {
178:                    return true;
179:                }
180:
181:                if (obj != null) {
182:                    try {
183:                        Glyph gl = (Glyph) obj;
184:
185:                        return ((this .getChar() == gl.getChar())
186:                                && (this .getGlyphMetrics().equals(gl
187:                                        .getGlyphMetrics())) && (this 
188:                                .getGlyphCode() == gl.getGlyphCode()));
189:                    } catch (ClassCastException e) {
190:                    }
191:                }
192:
193:                return false;
194:            }
195:
196:            /**
197:             * Returns height of the glyph in points. 
198:             */
199:            public int getPointHeight() {
200:                return (int) getGlyphPointMetrics().getBounds2D().getHeight();
201:            }
202:
203:            /**
204:             * Returns width of the glyph in points. 
205:             */
206:            public int getPointWidth() {
207:                return (int) getGlyphPointMetrics().getBounds2D().getWidth();
208:            }
209:
210:            public Shape getShape() {
211:                if (glOutline == null) {
212:                    glOutline = initOutline(this .glChar);
213:                }
214:                return glOutline;
215:            }
216:
217:            /**
218:             * Sets BufferedImage representation of this glyph.
219:             */
220:            public BufferedImage getImage() {
221:                //!! Implementation classes must override this method
222:                return null;
223:            }
224:
225:            /**
226:             *  Returns array of bytes, representing image of this glyph
227:             */
228:            public abstract byte[] getBitmap();
229:
230:            /**
231:             * Returns shape that represents outline of the specified character. 
232:             * 
233:             * @param c specified character
234:             */
235:            public abstract Shape initOutline(char c);
236:
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.