minor fixes

X-SVN-Rev: 13905
This commit is contained in:
Mark Davis 2003-11-27 02:31:48 +00:00
parent 1a5cefd085
commit 1ae340bc09
3 changed files with 152 additions and 61 deletions
icu4j/src/com/ibm/icu/dev/demo/chart

View file

@ -0,0 +1,16 @@
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 }

View file

@ -5,8 +5,8 @@
*******************************************************************************
*
* $Source: /xsrl/Nsvn/icu/icu4j/src/com/ibm/icu/dev/demo/chart/UnicodeChart.java,v $
* $Date: 2003/11/26 23:36:39 $
* $Revision: 1.1 $
* $Date: 2003/11/27 02:31:48 $
* $Revision: 1.2 $
*
*****************************************************************************************
*/
@ -23,27 +23,18 @@ public class UnicodeChart {
int rowWidth = 256;
PrintWriter pw = BagFormatter.openUTF8Writer("", "UnicodeChart.html", BagFormatter.CONSOLE);
pw.println("<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>");
pw.println("<title>Unicode 4.0 Chart</title><style><!--");
pw.println("th { width: 1%; font-family: monospace; font-size: 50%; text-align: Center; border: 1px solid black; margin: 0; padding: 0}");
pw.println("td { font-size: 50%; text-align: Center; border-right: 1px solid blue; border-top: 1px solid blue; margin: 0; padding: 0 }");
pw.println("table { border-spacing: 0; border-collapse: collapse; border: 1px solid black; margin: 0; padding: 0 }");
pw.println(".d { border-top: 2px double blue }");
pw.println(".u { background-color: #DDDDDD }");
pw.println(".du { border-top: 2px double blue; background-color: #DDDDDD }");
pw.println(".n { background-color: black }");
pw.println(".dn { border-top: 2px double blue; background-color: black }");
pw.println(".i { background-color: yellow }");
pw.println(".di { border-top: 2px double blue; background-color: yellow }");
pw.println("--></style></head><body bgcolor='#FFFFFF'>");
pw.println("<table border='1' cellspacing='0'>");
pw.println("<caption><h1>Unicode 4.0 Chart</h1></caption>");
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 4.0 Chart</title>");
pw.println("</head><body bgcolor='#FFFFFF'>");
pw.println("<table border='1' cellspacing='0'><caption><h1>Unicode 4.0 Chart</h1></caption>");
pw.println("<tr><th></th>");
/*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
int surrogateType = UCharacter.getType('\ud800');
@ -53,52 +44,48 @@ public class UnicodeChart {
boolean gotOne = true;
int columns = 0;
for (int i = 0; i < 0x10FFFF; i += rowWidth) {
boolean gotLast = gotOne;
gotOne = false;
int limit = i + rowWidth;
for (int j = i; j < limit; ++j) {
int type = UCharacter.getType(j);
if (type == Character.UNASSIGNED
&& !UCharacter.hasBinaryProperty(j, UProperty.NONCHARACTER_CODE_POINT)) continue;
if (type == surrogateType || type == privateUseType) continue;
gotOne = true;
}
if (!gotOne) {
if (false) {
System.out.println("Skipping: " + hex(i>>8,2) + "__");
for (int j = i; j < limit; ++j) {
System.out.print(UCharacter.getType(j) + ",");
}
System.out.println();
}
continue;
};
System.out.println(hex(i>>8,2) + "__");
int limit = 0x10FFFF;
char lastType = 'x';
int lastCount = 0;
pw.println("<script>");
pw.print("top();");
int itemCount = 1;
for (int i = 0; i <= limit; ++i) {
if ((i & 0xFF) == 0) System.out.println(hex(i>>8,2) + "__");
columns++;
pw.print("<tr><th>" + hex(i>>8,2) + "__</th>");
for (int j = i; j < limit; ++j) {
String value = "\u00a0";
String cellclass = gotLast ? "" : " class='d'";
if (UCharacter.hasBinaryProperty(j, UProperty.NONCHARACTER_CODE_POINT)) {
cellclass = gotLast ? " class='n'" : " class='dn'";
} else if (!UCharacter.isDefined(j)) {
cellclass = gotLast ? " class='u'" : " class='du'";
} else if (UCharacter.isUWhiteSpace(j)) {
// nothing
} else if (UCharacter.hasBinaryProperty(j, UProperty.DEFAULT_IGNORABLE_CODE_POINT)) {
cellclass = gotLast ? " class='i'" : " class='di'";
} else {
value = UTF16.valueOf(j);
}
pw.print("<td" + cellclass + ">" + value + "</td>");
if ((j & 0xF) == 0xF) {
pw.println();
}
//pw.print("<tr><th>" + hex(i>>8,2) + "__</th>");
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';
}
pw.println("</tr>");
if (type != lastType) {
if (lastCount != 0) pw.print(lastType + "(" + lastCount + ");");
lastType = type;
lastCount = 0;
++itemCount;
if ((itemCount & 0xF) == 0) pw.println();
}
++lastCount;
}
pw.println("</table><p>Copyright \u00A9 2003, Mark Davis. All Rights Reserved.</body></html>");
pw.println(lastType + "(" + lastCount + ");"); // finish last row
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'>&nbsp;</td><td class='left'>Other Default Ignorable</td></tr>");
pw.println("<tr><td class='u'>&nbsp;</td><td class='left'>Undefined, Private Use, or Surrogates</td></tr>");
pw.println("<tr><td class='n'>&nbsp;</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);
}

View file

@ -0,0 +1,88 @@
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);
}