Source Code Cross Referenced for Kern.java in  » Graphic-Library » batik » org » apache » batik » gvt » 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 » Graphic Library » batik » org.apache.batik.gvt.font 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Licensed to the Apache Software Foundation (ASF) under one or more
004:           contributor license agreements.  See the NOTICE file distributed with
005:           this work for additional information regarding copyright ownership.
006:           The ASF licenses this file to You under the Apache License, Version 2.0
007:           (the "License"); you may not use this file except in compliance with
008:           the License.  You may obtain a copy of the License at
009:
010:               http://www.apache.org/licenses/LICENSE-2.0
011:
012:           Unless required by applicable law or agreed to in writing, software
013:           distributed under the License is distributed on an "AS IS" BASIS,
014:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:           See the License for the specific language governing permissions and
016:           limitations under the License.
017:
018:         */
019:        package org.apache.batik.gvt.font;
020:
021:        import java.util.Arrays;
022:
023:        /**
024:         * The Kern class describes an entry in the "kerning table". It provides
025:         * a kerning value to be used when laying out characters side
026:         * by side. It may be used for either horizontal or vertical kerning.
027:         *
028:         * @author <a href="mailto:dean.jackson@cmis.csiro.au">Dean Jackson</a>
029:         * @version $Id: Kern.java 475685 2006-11-16 11:16:05Z cam $
030:         */
031:        public class Kern {
032:
033:            private int[] firstGlyphCodes;
034:            private int[] secondGlyphCodes;
035:            private UnicodeRange[] firstUnicodeRanges;
036:            private UnicodeRange[] secondUnicodeRanges;
037:            private float kerningAdjust;
038:
039:            /**
040:             * Creates a Kern object with the given glyph arrays
041:             * and kerning value. The first and second sets of glyphs for this kerning
042:             * entry consist of the union of glyphs in the glyph code arrays and the
043:             * unicode ranges.
044:             *
045:             * @param firstGlyphCodes An array of glyph codes that are part of the first
046:             * set of glyphs in this kerning entry.
047:             * @param secondGlyphCodes An array of glyph codes that are part of the
048:             * second set of glyphs in this kerning entry.
049:             * @param firstUnicodeRanges An array of unicode ranges that are part of the
050:             * first set of glyphs in this kerning entry.
051:             * @param secondUnicodeRanges An array of unicode ranges that are part of
052:             * the second set of glyphs in this kerning entry.
053:             * @param adjustValue The kerning adjustment (positive value means the space
054:             * between glyphs should decrease).  
055:             */
056:            public Kern(int[] firstGlyphCodes, int[] secondGlyphCodes,
057:                    UnicodeRange[] firstUnicodeRanges,
058:                    UnicodeRange[] secondUnicodeRanges, float adjustValue) {
059:                this .firstGlyphCodes = firstGlyphCodes;
060:                this .secondGlyphCodes = secondGlyphCodes;
061:                this .firstUnicodeRanges = firstUnicodeRanges;
062:                this .secondUnicodeRanges = secondUnicodeRanges;
063:                this .kerningAdjust = adjustValue;
064:
065:                if (firstGlyphCodes != null)
066:                    Arrays.sort(this .firstGlyphCodes);
067:                if (secondGlyphCodes != null)
068:                    Arrays.sort(this .secondGlyphCodes);
069:            }
070:
071:            /**
072:             * Returns true if the specified glyph is one of the glyphs considered
073:             * as first by this kerning entry. Returns false otherwise.
074:             *
075:             * @param glyphCode The id of the glyph to test.
076:             * @param glyphUnicode The unicode value of the glyph to test.
077:             * @return True if this glyph is in the list of first glyphs for
078:             * the kerning entry
079:             */
080:            public boolean matchesFirstGlyph(int glyphCode, String glyphUnicode) {
081:                if (firstGlyphCodes != null) {
082:                    int pt = Arrays.binarySearch(firstGlyphCodes, glyphCode);
083:                    if (pt >= 0)
084:                        return true;
085:                }
086:                if (glyphUnicode.length() < 1)
087:                    return false;
088:                char glyphChar = glyphUnicode.charAt(0);
089:                for (int i = 0; i < firstUnicodeRanges.length; i++) {
090:                    if (firstUnicodeRanges[i].contains(glyphChar))
091:                        return true;
092:                }
093:                return false;
094:            }
095:
096:            /**
097:             * Returns true if the specified glyph is one of the glyphs considered
098:             * as first by this kerning entry. Returns false otherwise.
099:             *
100:             * @param glyphCode The id of the glyph to test.
101:             * @param glyphUnicode The unicode value of the glyph to test.
102:             * @return True if this glyph is in the list of first glyphs for
103:             *         the kerning entry
104:             */
105:            public boolean matchesFirstGlyph(int glyphCode, char glyphUnicode) {
106:                if (firstGlyphCodes != null) {
107:                    int pt = Arrays.binarySearch(firstGlyphCodes, glyphCode);
108:                    if (pt >= 0)
109:                        return true;
110:                }
111:                for (int i = 0; i < firstUnicodeRanges.length; i++) {
112:                    if (firstUnicodeRanges[i].contains(glyphUnicode))
113:                        return true;
114:                }
115:                return false;
116:            }
117:
118:            /**
119:             * Returns true if the specified glyph is one of the glyphs considered
120:             * as second by this kerning entry. Returns false otherwise.
121:             *
122:             * @param glyphCode The id of the glyph to test.
123:             * @param glyphUnicode The unicode value of the glyph to test.
124:
125:             * @return True if this glyph is in the list of second glyphs for the
126:             * kerning entry 
127:             */
128:            public boolean matchesSecondGlyph(int glyphCode, String glyphUnicode) {
129:                if (secondGlyphCodes != null) {
130:                    int pt = Arrays.binarySearch(secondGlyphCodes, glyphCode);
131:                    if (pt >= 0)
132:                        return true;
133:                }
134:                if (glyphUnicode.length() < 1)
135:                    return false;
136:                char glyphChar = glyphUnicode.charAt(0);
137:                for (int i = 0; i < secondUnicodeRanges.length; i++) {
138:                    if (secondUnicodeRanges[i].contains(glyphChar))
139:                        return true;
140:                }
141:                return false;
142:            }
143:
144:            /**
145:             * Returns true if the specified glyph is one of the glyphs considered
146:             * as second by this kerning entry. Returns false otherwise.
147:             *
148:             * @param glyphCode The id of the glyph to test.
149:             * @param glyphUnicode The unicode value of the glyph to test.
150:
151:             * @return True if this glyph is in the list of second glyphs for the
152:             * kerning entry 
153:             */
154:            public boolean matchesSecondGlyph(int glyphCode, char glyphUnicode) {
155:                if (secondGlyphCodes != null) {
156:                    int pt = Arrays.binarySearch(secondGlyphCodes, glyphCode);
157:                    if (pt >= 0)
158:                        return true;
159:                }
160:                for (int i = 0; i < secondUnicodeRanges.length; i++) {
161:                    if (secondUnicodeRanges[i].contains(glyphUnicode))
162:                        return true;
163:                }
164:                return false;
165:            }
166:
167:            /**
168:             * Returns the kerning adjustment value for this kerning entry (a positive
169:             * value means the space between characters should decrease).
170:             *
171:             * @return The kerning adjustment for this kerning entry.
172:             */
173:            public float getAdjustValue() {
174:                return kerningAdjust;
175:            }
176:
177:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.