ICU-5892 Delete UnicodeChart demo from trunk. This demo code is not completed and we have no plan to finish it.
X-SVN-Rev: 22566
This commit is contained in:
parent
5ab7ce0aa5
commit
42188d3e3d
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003-2004, International Business Machines Corporation
|
||||
* and others. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
th { font-size: 60%; text-align: Center;
|
||||
width: 0.39%; font-family: monospace;
|
||||
border: 1px solid black; margin: 0; padding: 1px }
|
||||
td { font-size: 60%; text-align: Center;
|
||||
border-right: 1px solid #9999FF; border-top: 1px solid #9999FF; margin: 0; padding: 1px }
|
||||
table { border-spacing: 0; border-collapse: collapse;
|
||||
border: 1px solid black; margin: 0; padding: 0 }
|
||||
.d { border-top: 2px double blue }
|
||||
.u { background-color: #DDDDDD }
|
||||
.du { background-color: #DDDDDD; border-top: 2px double blue }
|
||||
.n { background-color: black }
|
||||
.dn { background-color: black; border-top: 2px double blue }
|
||||
.i { background-color: yellow }
|
||||
.di { background-color: yellow; border-top: 2px double blue }
|
||||
p { font-size: 50%; text-align: Right }
|
||||
.left { font-size: 75%; text-align: Left }
|
@ -1,157 +0,0 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1997-2006, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
package com.ibm.icu.dev.demo.chart;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import com.ibm.icu.dev.test.util.*;
|
||||
import com.ibm.icu.lang.*;
|
||||
import com.ibm.icu.util.VersionInfo;
|
||||
|
||||
public class UnicodeChart {
|
||||
static int surrogateType = UCharacter.getType('\ud800');
|
||||
static int privateUseType = UCharacter.getType('\ue000');
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
//int rowWidth = 256;
|
||||
VersionInfo vi = UCharacter.getUnicodeVersion();
|
||||
String version = vi.getMajor() + "." + vi.getMinor() + "." + vi.getMilli();
|
||||
PrintWriter pw = BagFormatter.openUTF8Writer("C:\\DATA\\GEN\\", "UnicodeChart.html");
|
||||
pw.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
|
||||
pw.println("<script type='text/javascript' src='UnicodeChart.js'></script>");
|
||||
pw.println("<link rel='stylesheet' type='text/css' href='UnicodeChart.css'>");
|
||||
pw.println("<title>Unicode " + version + " Chart</title>");
|
||||
pw.println("</head><body bgcolor='#FFFFFF'>");
|
||||
pw.println("<table border='1' cellspacing='0'><caption><h1>Unicode " + version + " Chart</h1></caption>");
|
||||
|
||||
/*pw.println("<tr><th></th>");
|
||||
for (int j = 0; j < rowWidth; ++j) {
|
||||
pw.print("<th>" + hex(j,2) + "</th>");
|
||||
}
|
||||
pw.println("</tr>");
|
||||
*/
|
||||
// TODO: fix Utility to take ints
|
||||
|
||||
System.out.println("//Surrogate Type: Java=" + Character.SURROGATE + ", ICU=" + surrogateType);
|
||||
System.out.println("//Private-Use Type: Java=" + Character.PRIVATE_USE + ", ICU=" + privateUseType);
|
||||
|
||||
//boolean gotOne = true;
|
||||
int columns = 0;
|
||||
int limit = 0x110000/16;
|
||||
pw.println("<script>");
|
||||
pw.print("top();");
|
||||
// an array that maps String (containing column information) to UnicodeSet (containing column numbers)
|
||||
Map info_number = new TreeMap();
|
||||
List number_info = new ArrayList();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int lastInfo = -1;
|
||||
int sameCount = 0;
|
||||
System.out.println("var charRanges = [");
|
||||
for (int i = 0; i < limit; ++i) {
|
||||
// get the string of info, and get its number
|
||||
sb.setLength(0);
|
||||
for (int j = 0; j < 16; ++j) {
|
||||
int cp = i*16+j;
|
||||
char type = getType(cp);
|
||||
sb.append(type);
|
||||
}
|
||||
String info = sb.toString();
|
||||
Integer s = (Integer) info_number.get(info);
|
||||
if (s == null) {
|
||||
info_number.put(info, s=new Integer(number_info.size()));
|
||||
number_info.add(info);
|
||||
}
|
||||
|
||||
// write a line whenever the value changes
|
||||
if (lastInfo == s.intValue()) {
|
||||
sameCount++;
|
||||
} else {
|
||||
if (lastInfo != -1) System.out.println(sameCount + "," + lastInfo + ",");
|
||||
sameCount = 1;
|
||||
lastInfo = s.intValue();
|
||||
}
|
||||
}
|
||||
// write last line
|
||||
System.out.println(sameCount + "," + lastInfo);
|
||||
System.out.println("];");
|
||||
|
||||
// now write out array
|
||||
System.out.println("var charInfo = [");
|
||||
for (Iterator it = number_info.iterator(); it.hasNext();) {
|
||||
String info = (String) it.next();
|
||||
System.out.println("'" + info + "',");
|
||||
}
|
||||
System.out.println("];");
|
||||
|
||||
// write out blocks
|
||||
Map blockMap = new TreeMap();
|
||||
int startValue = -1;
|
||||
int lastEnum = -1;
|
||||
for (int i = 0; i <= 0x10FFFF; ++i) {
|
||||
int prop = UCharacter.getIntPropertyValue(i,UProperty.BLOCK);
|
||||
if (prop == lastEnum) continue;
|
||||
if (lastEnum != -1) {
|
||||
String s = UCharacter.getPropertyValueName(UProperty.BLOCK, lastEnum, UProperty.NameChoice.LONG);
|
||||
blockMap.put(s, hex(startValue,0) + "/" + hex(i - startValue,0));
|
||||
System.out.println(s + ": " + blockMap.get(s));
|
||||
}
|
||||
lastEnum = prop;
|
||||
startValue = i;
|
||||
}
|
||||
String s = UCharacter.getPropertyValueName(UProperty.BLOCK, lastEnum, UProperty.NameChoice.LONG);
|
||||
blockMap.put(s, hex(startValue,0) + "/" + hex(0x110000 - startValue,0));
|
||||
blockMap.remove("No_Block");
|
||||
for (Iterator it = blockMap.keySet().iterator(); it.hasNext();) {
|
||||
String blockName = (String)it.next();
|
||||
String val = (String) blockMap.get(blockName);
|
||||
System.out.println("<option value='" + val + "'>" + blockName + "</option>");
|
||||
}
|
||||
|
||||
// <option value="4DC0">Yijing Hexagram Symbols</option>
|
||||
|
||||
|
||||
pw.println("</script></tr></table><p></p>");
|
||||
pw.println("<table><caption>Key</caption>");
|
||||
pw.println("<tr><td>X</td><td class='left'>Graphic characters</td></tr>");
|
||||
pw.println("<tr><td>\u00A0</td><td class='left'>Whitespace</td></tr>");
|
||||
pw.println("<tr><td class='i'>\u00A0</td><td class='left'>Other Default Ignorable</td></tr>");
|
||||
pw.println("<tr><td class='u'>\u00A0</td><td class='left'>Undefined, Private Use, or Surrogates</td></tr>");
|
||||
pw.println("<tr><td class='n'>\u00A0</td><td class='left'>Noncharacter</td></tr>");
|
||||
pw.println("</table>");
|
||||
pw.println("<p>Copyright \u00A9 2003, Mark Davis. All Rights Reserved.</body></html>");
|
||||
pw.close();
|
||||
System.out.println("//columns: " + columns);
|
||||
}
|
||||
|
||||
private static char getType(int i) {
|
||||
char type = 'v';
|
||||
int cat = UCharacter.getType(i);
|
||||
if (UCharacter.hasBinaryProperty(i, UProperty.NONCHARACTER_CODE_POINT)) {
|
||||
type = 'n';
|
||||
} else if (cat == Character.UNASSIGNED || cat == surrogateType || cat == privateUseType) {
|
||||
type = 'u';
|
||||
} else if (UCharacter.isUWhiteSpace(i)) {
|
||||
type = 'w';
|
||||
} else if (UCharacter.hasBinaryProperty(i, UProperty.DEFAULT_IGNORABLE_CODE_POINT)) {
|
||||
type = 'i';
|
||||
} else {
|
||||
type = 'v';
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
static String hex(int i, int padTo) {
|
||||
String result = Integer.toHexString(i).toUpperCase(java.util.Locale.ENGLISH);
|
||||
while (result.length() < padTo) result = "0" + result;
|
||||
return result;
|
||||
}
|
||||
}
|
@ -1,93 +0,0 @@
|
||||
//**************************************************************************
|
||||
// Copyright (C) 1997-2004, International Business Machines Corporation and
|
||||
// others. All Rights Reserved.
|
||||
//**************************************************************************
|
||||
|
||||
var columnBits = 8; // 8
|
||||
|
||||
var columnCount = Math.pow(2,columnBits);
|
||||
var columnMask = columnCount-1;
|
||||
var columnShift = Math.floor(columnBits/4);
|
||||
var columnGap = repeat('_', columnShift);
|
||||
var columnPad = 4-columnShift;
|
||||
|
||||
var gotLast = true;
|
||||
var current = 0;
|
||||
var haveFirst = false;
|
||||
|
||||
function top(count) {
|
||||
document.writeln("<th></th>");
|
||||
for (var i = 0; i < columnCount; ++i) {
|
||||
document.writeln("<th>", hex(i,2), "</th>");
|
||||
}
|
||||
}
|
||||
|
||||
function writeCell(cellclass, value) {
|
||||
if (!gotLast) cellclass = 'd' + cellclass;
|
||||
if (value) {
|
||||
value = current <= 0xFFFF
|
||||
? String.fromCharCode(current)
|
||||
: String.fromCharCode(0xD800 + (current >> 10), 0xDC00 + (current & 0x3FF));
|
||||
} else {
|
||||
value = '\u00A0'
|
||||
}
|
||||
if (cellclass!="") cellclass = " class='" + cellclass + "'";
|
||||
document.writeln("<td", cellclass, ">", value, "</td>");
|
||||
++current;
|
||||
}
|
||||
|
||||
function writeCells(count,cellclass,value) {
|
||||
for (var i = 0; i < count; ++i) {
|
||||
if ((current & columnMask) == 0) {
|
||||
if (cellclass!='u' || count - i < columnCount) {
|
||||
gotLast = true
|
||||
} else {
|
||||
gotLast = false;
|
||||
var rem = (count - i) & ~columnMask;
|
||||
current += rem;
|
||||
i += rem;
|
||||
if (i == count) break;
|
||||
}
|
||||
newRow();
|
||||
}
|
||||
writeCell(cellclass,value);
|
||||
}
|
||||
}
|
||||
|
||||
function newRow() {
|
||||
if (haveFirst) document.write("</tr>");
|
||||
else haveFirst = true;
|
||||
var hclass = (gotLast) ? "" : " class='d'";
|
||||
document.writeln("<tr><th", hclass, ">", hex(current>>(columnShift*4),columnPad), columnGap, "</th>");
|
||||
}
|
||||
|
||||
// Utilities
|
||||
|
||||
function hex(value, pad) {
|
||||
var result = value.toString(16).toUpperCase();
|
||||
while (result.length < pad) result = '0' + result;
|
||||
return result;
|
||||
}
|
||||
|
||||
function repeat(str, count) {
|
||||
var result = "";
|
||||
for (var i = 0; i < count; ++i) result += str;
|
||||
return result;
|
||||
}
|
||||
|
||||
// used in the body. single letters to save bytes.
|
||||
function u(count) { // undefined, private use, or surrogates
|
||||
writeCells(count,'u',false);
|
||||
}
|
||||
function n(count) { // noncharacter
|
||||
writeCells(count,'n',false);
|
||||
}
|
||||
function i(count) { // ignorable
|
||||
writeCells(count,'i',false);
|
||||
}
|
||||
function w(count) { // whitespace
|
||||
writeCells(count,'',false);
|
||||
}
|
||||
function v(count) { // normal visible graphic
|
||||
writeCells(count,'',true);
|
||||
}
|
Loading…
Reference in New Issue
Block a user