Source Code Cross Referenced for UnicodeChart.java in  » Internationalization-Localization » icu4j » com » ibm » icu » dev » demo » chart » 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 » Internationalization Localization » icu4j » com.ibm.icu.dev.demo.chart 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *******************************************************************************
003:         * Copyright (C) 1997-2006, International Business Machines Corporation and    *
004:         * others. All Rights Reserved.                                                *
005:         *******************************************************************************
006:         */
007:
008:        package com.ibm.icu.dev.demo.chart;
009:
010:        import java.io.*;
011:        import java.util.ArrayList;
012:        import java.util.Iterator;
013:        import java.util.List;
014:        import java.util.Map;
015:        import java.util.TreeMap;
016:
017:        import com.ibm.icu.dev.test.util.*;
018:        import com.ibm.icu.lang.*;
019:        import com.ibm.icu.util.VersionInfo;
020:
021:        public class UnicodeChart {
022:            static int surrogateType = UCharacter.getType('\ud800');
023:            static int privateUseType = UCharacter.getType('\ue000');
024:
025:            public static void main(String[] args) throws IOException {
026:                //int rowWidth = 256;
027:                VersionInfo vi = UCharacter.getUnicodeVersion();
028:                String version = vi.getMajor() + "." + vi.getMinor() + "."
029:                        + vi.getMilli();
030:                PrintWriter pw = BagFormatter.openUTF8Writer("C:\\DATA\\GEN\\",
031:                        "UnicodeChart.html");
032:                pw
033:                        .println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
034:                pw
035:                        .println("<script type='text/javascript' src='UnicodeChart.js'></script>");
036:                pw
037:                        .println("<link rel='stylesheet' type='text/css' href='UnicodeChart.css'>");
038:                pw.println("<title>Unicode " + version + " Chart</title>");
039:                pw.println("</head><body bgcolor='#FFFFFF'>");
040:                pw
041:                        .println("<table border='1' cellspacing='0'><caption><h1>Unicode "
042:                                + version + " Chart</h1></caption>");
043:
044:                /*pw.println("<tr><th></th>");
045:                for (int j = 0; j < rowWidth; ++j) {
046:                    pw.print("<th>" + hex(j,2) + "</th>");
047:                }
048:                pw.println("</tr>");
049:                 */
050:                // TODO: fix Utility to take ints
051:                System.out.println("//Surrogate Type: Java="
052:                        + Character.SURROGATE + ", ICU=" + surrogateType);
053:                System.out.println("//Private-Use Type: Java="
054:                        + Character.PRIVATE_USE + ", ICU=" + privateUseType);
055:
056:                //boolean gotOne = true;
057:                int columns = 0;
058:                int limit = 0x110000 / 16;
059:                pw.println("<script>");
060:                pw.print("top();");
061:                // an array that maps String (containing column information) to UnicodeSet (containing column numbers)
062:                Map info_number = new TreeMap();
063:                List number_info = new ArrayList();
064:                StringBuffer sb = new StringBuffer();
065:                int lastInfo = -1;
066:                int sameCount = 0;
067:                System.out.println("var charRanges = [");
068:                for (int i = 0; i < limit; ++i) {
069:                    // get the string of info, and get its number
070:                    sb.setLength(0);
071:                    for (int j = 0; j < 16; ++j) {
072:                        int cp = i * 16 + j;
073:                        char type = getType(cp);
074:                        sb.append(type);
075:                    }
076:                    String info = sb.toString();
077:                    Integer s = (Integer) info_number.get(info);
078:                    if (s == null) {
079:                        info_number.put(info, s = new Integer(number_info
080:                                .size()));
081:                        number_info.add(info);
082:                    }
083:
084:                    // write a line whenever the value changes
085:                    if (lastInfo == s.intValue()) {
086:                        sameCount++;
087:                    } else {
088:                        if (lastInfo != -1)
089:                            System.out
090:                                    .println(sameCount + "," + lastInfo + ",");
091:                        sameCount = 1;
092:                        lastInfo = s.intValue();
093:                    }
094:                }
095:                // write last line
096:                System.out.println(sameCount + "," + lastInfo);
097:                System.out.println("];");
098:
099:                // now write out array
100:                System.out.println("var charInfo = [");
101:                for (Iterator it = number_info.iterator(); it.hasNext();) {
102:                    String info = (String) it.next();
103:                    System.out.println("'" + info + "',");
104:                }
105:                System.out.println("];");
106:
107:                // write out blocks
108:                Map blockMap = new TreeMap();
109:                int startValue = -1;
110:                int lastEnum = -1;
111:                for (int i = 0; i <= 0x10FFFF; ++i) {
112:                    int prop = UCharacter.getIntPropertyValue(i,
113:                            UProperty.BLOCK);
114:                    if (prop == lastEnum)
115:                        continue;
116:                    if (lastEnum != -1) {
117:                        String s = UCharacter.getPropertyValueName(
118:                                UProperty.BLOCK, lastEnum,
119:                                UProperty.NameChoice.LONG);
120:                        blockMap.put(s, hex(startValue, 0) + "/"
121:                                + hex(i - startValue, 0));
122:                        System.out.println(s + ": " + blockMap.get(s));
123:                    }
124:                    lastEnum = prop;
125:                    startValue = i;
126:                }
127:                String s = UCharacter.getPropertyValueName(UProperty.BLOCK,
128:                        lastEnum, UProperty.NameChoice.LONG);
129:                blockMap.put(s, hex(startValue, 0) + "/"
130:                        + hex(0x110000 - startValue, 0));
131:                blockMap.remove("No_Block");
132:                for (Iterator it = blockMap.keySet().iterator(); it.hasNext();) {
133:                    String blockName = (String) it.next();
134:                    String val = (String) blockMap.get(blockName);
135:                    System.out.println("<option value='" + val + "'>"
136:                            + blockName + "</option>");
137:                }
138:
139:                //      <option value="4DC0">Yijing Hexagram Symbols</option>
140:
141:                pw.println("</script></tr></table><p></p>");
142:                pw.println("<table><caption>Key</caption>");
143:                pw
144:                        .println("<tr><td>X</td><td class='left'>Graphic characters</td></tr>");
145:                pw
146:                        .println("<tr><td>\u00A0</td><td class='left'>Whitespace</td></tr>");
147:                pw
148:                        .println("<tr><td class='i'>\u00A0</td><td class='left'>Other Default Ignorable</td></tr>");
149:                pw
150:                        .println("<tr><td class='u'>\u00A0</td><td class='left'>Undefined, Private Use, or Surrogates</td></tr>");
151:                pw
152:                        .println("<tr><td class='n'>\u00A0</td><td class='left'>Noncharacter</td></tr>");
153:                pw.println("</table>");
154:                pw
155:                        .println("<p>Copyright \u00A9 2003, Mark Davis. All Rights Reserved.</body></html>");
156:                pw.close();
157:                System.out.println("//columns: " + columns);
158:            }
159:
160:            private static char getType(int i) {
161:                char type = 'v';
162:                int cat = UCharacter.getType(i);
163:                if (UCharacter.hasBinaryProperty(i,
164:                        UProperty.NONCHARACTER_CODE_POINT)) {
165:                    type = 'n';
166:                } else if (cat == Character.UNASSIGNED || cat == surrogateType
167:                        || cat == privateUseType) {
168:                    type = 'u';
169:                } else if (UCharacter.isUWhiteSpace(i)) {
170:                    type = 'w';
171:                } else if (UCharacter.hasBinaryProperty(i,
172:                        UProperty.DEFAULT_IGNORABLE_CODE_POINT)) {
173:                    type = 'i';
174:                } else {
175:                    type = 'v';
176:                }
177:                return type;
178:            }
179:
180:            static String hex(int i, int padTo) {
181:                String result = Integer.toHexString(i).toUpperCase(
182:                        java.util.Locale.ENGLISH);
183:                while (result.length() < padTo)
184:                    result = "0" + result;
185:                return result;
186:            }
187:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.