Source Code Cross Referenced for CMapFormat0.java in  » PDF » PDF-Renderer » com » sun » pdfview » font » ttf » 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 » PDF Renderer » com.sun.pdfview.font.ttf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: CMapFormat0.java,v 1.2 2007/12/20 18:33:30 rbair Exp $
003:         *
004:         * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
005:         * Santa Clara, California 95054, U.S.A. All rights reserved.
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         * 
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         * 
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
020:         */
021:
022:        package com.sun.pdfview.font.ttf;
023:
024:        import java.nio.ByteBuffer;
025:
026:        /**
027:         *
028:         * @author  jkaplan
029:         */
030:        public class CMapFormat0 extends CMap {
031:
032:            /**
033:             * The glyph index array
034:             */
035:            private byte[] glyphIndex;
036:
037:            /** Creates a new instance of CMapFormat0 */
038:            protected CMapFormat0(short language) {
039:                super ((short) 0, language);
040:
041:                byte[] initialIndex = new byte[256];
042:                for (int i = 0; i < initialIndex.length; i++) {
043:                    initialIndex[i] = (byte) i;
044:                }
045:                setMap(initialIndex);
046:            }
047:
048:            /**
049:             * Get the length of this table
050:             */
051:            public short getLength() {
052:                return (short) 262;
053:            }
054:
055:            /** 
056:             * Map from a byte
057:             */
058:            public byte map(byte src) {
059:                int i = 0xff & src;
060:
061:                return glyphIndex[i];
062:            }
063:
064:            /**
065:             * Cannot map from short
066:             */
067:            public char map(char src) {
068:                if (src < 0 || src > 255) {
069:                    // out of range
070:                    return (char) 0;
071:                }
072:
073:                return (char) (map((byte) src) & 0xff);
074:            }
075:
076:            /**
077:             * Get the src code which maps to the given glyphID
078:             */
079:            public char reverseMap(short glyphID) {
080:                for (int i = 0; i < glyphIndex.length; i++) {
081:                    if ((glyphIndex[i] & 0xff) == glyphID) {
082:                        return (char) i;
083:                    }
084:                }
085:
086:                return (char) 0;
087:            }
088:
089:            /**
090:             * Set the entire map
091:             */
092:            public void setMap(byte[] glyphIndex) {
093:                if (glyphIndex.length != 256) {
094:                    throw new IllegalArgumentException(
095:                            "Glyph map must be size 256!");
096:                }
097:
098:                this .glyphIndex = glyphIndex;
099:            }
100:
101:            /**
102:             * Set a single mapping entry
103:             */
104:            public void setMap(byte src, byte dest) {
105:                int i = 0xff & src;
106:
107:                glyphIndex[i] = dest;
108:            }
109:
110:            /**
111:             * Get the whole map
112:             */
113:            protected byte[] getMap() {
114:                return glyphIndex;
115:            }
116:
117:            /**
118:             * Get the data in this map as a ByteBuffer
119:             */
120:            public ByteBuffer getData() {
121:                ByteBuffer buf = ByteBuffer.allocate(262);
122:
123:                buf.putShort(getFormat());
124:                buf.putShort(getLength());
125:                buf.putShort(getLanguage());
126:                buf.put(getMap());
127:
128:                // reset the position to the beginning of the buffer
129:                buf.flip();
130:
131:                return buf;
132:            }
133:
134:            /** 
135:             * Read the map in from a byte buffer
136:             */
137:            public void setData(int length, ByteBuffer data) {
138:                if (length != 262) {
139:                    throw new IllegalArgumentException(
140:                            "Bad length for CMap format 0");
141:                }
142:
143:                if (data.remaining() != 256) {
144:                    throw new IllegalArgumentException(
145:                            "Wrong amount of data for CMap format 0");
146:                }
147:
148:                byte[] map = new byte[256];
149:                data.get(map);
150:
151:                setMap(map);
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.