Easter cleaning
This commit is contained in:
commit
9e36078b2e
1862 changed files with 270281 additions and 0 deletions
25
nx01-mushroom-mais-fc18/pom.xml
Normal file
25
nx01-mushroom-mais-fc18/pom.xml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>love.distributedrebirth.nx01</groupId>
|
||||
<artifactId>nx01</artifactId>
|
||||
<version>〇一。壬寅。一〄-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>nx01-mushroom-mais-fc18</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>love.distributedrebirth.nx01</groupId>
|
||||
<artifactId>nx01-mushroom-mais</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>love.distributedrebirth.nx01</groupId>
|
||||
<artifactId>nx01-x4o-fc18</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.fc18.FourCornerUnicodeDisplay;
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
|
||||
import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentCss;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentWriter;
|
||||
import org.x4o.maisdoc.model.MaisDocPage;
|
||||
import org.x4o.maisdoc.model.MaisDocPageWriter;
|
||||
import org.x4o.maisdoc.model.MaisDocWriteEvent;
|
||||
import org.x4o.sax3.SAX3WriterHtml.Tag;
|
||||
import org.x4o.sax3.io.ContentCloseable;
|
||||
|
||||
/**
|
||||
* Cake doc muffin page writer.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 17, 2025
|
||||
*/
|
||||
public class FCDocPageWriterBaklava implements MaisDocPageWriter, FCDocSegmentWriter {
|
||||
|
||||
public static MaisDocPage createDocPage() {
|
||||
return new MaisDocPage("overview-baklave","Baklava","Overview of all 6 bit baklava NCR1632 fractions.",new FCDocPageWriterBaklava());
|
||||
}
|
||||
|
||||
// TODO: make all symbols href links
|
||||
|
||||
@Override
|
||||
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
|
||||
MaisDocContentWriter writer = e.getWriter();
|
||||
try (ContentCloseable content = writer.docPageContent()) {
|
||||
try (ContentCloseable table = writer.docTable(FourCornerDotCake.FC_NCR1632_XD.nameSpec().replaceAll("XD", "baklava"), null, MaisDocContentCss.overviewSummary)) {
|
||||
writeTableBoxHeaderNumeric(writer, 28);
|
||||
writePIN(writer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writePIN(MaisDocContentWriter writer) throws IOException {
|
||||
for (int t = 0; t < 27; t++) {
|
||||
try (ContentCloseable tableRow = writer.docTableRow()) {
|
||||
String prefixNCR = String.format("T%03d", t + 1);
|
||||
writer.printTagStart(Tag.td, MaisDocContentCss.colOne);
|
||||
writer.printCharacters(prefixNCR);
|
||||
writer.printTagEnd(Tag.td);
|
||||
for (int i = 0; i < 27; i++) {
|
||||
if (i + 1 < 27) {
|
||||
writer.printTagStart(Tag.td);
|
||||
} else {
|
||||
writer.printTagStart(Tag.td, MaisDocContentCss.colLast);
|
||||
}
|
||||
if (i > t) {
|
||||
writer.printTagEnd(Tag.td);
|
||||
continue;
|
||||
}
|
||||
List<Integer> piNum = new ArrayList<>();
|
||||
//piNum.add(FCDotCDC1604DashP6.__NCR68.ordinal());\
|
||||
for (int letter : FCDotDEC2701DashPX0.ESC68_NCR.baklavaPointSequence()) {
|
||||
piNum.add(letter);
|
||||
}
|
||||
piNum.add(FCDotCDC1604DashP6.NX01_A.ordinal() + t);
|
||||
piNum.add(FCDotCDC1604DashP6.NX01_A.ordinal() + i);
|
||||
String char18Str = FourCornerUnicodeDisplay.text().renderFromInt18(piNum);
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int c : char18Str.codePoints().toArray()) {
|
||||
if (c == '\u0000') {
|
||||
buf.append("␀");
|
||||
} else {
|
||||
buf.appendCodePoint(c);
|
||||
}
|
||||
}
|
||||
writer.printCharacters(buf.toString());
|
||||
writer.printTagEnd(Tag.td);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,190 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.fc18.FourCornerUnicodeDisplay;
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotAPL0127DashP7A;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotAPL0127DashP7B;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotAPL0127DashP7C;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotBYD0127DashP7D;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotBYD0127DashP7E;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotBYD0127DashP7F;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentCss;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentWriter;
|
||||
import org.x4o.maisdoc.model.MaisDocPage;
|
||||
import org.x4o.maisdoc.model.MaisDocPageWriter;
|
||||
import org.x4o.maisdoc.model.MaisDocWriteEvent;
|
||||
import org.x4o.sax3.SAX3WriterHtml.Tag;
|
||||
import org.x4o.sax3.io.ContentCloseable;
|
||||
|
||||
/**
|
||||
* Cake doc muffin page writer.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 17, 2025
|
||||
*/
|
||||
public class FCDocPageWriterMuffin implements MaisDocPageWriter, FCDocSegmentWriter {
|
||||
|
||||
public static MaisDocPage createDocPage() {
|
||||
return new MaisDocPage("overview-muffin","Muffins","Overview of all muffin symbols.",new FCDocPageWriterMuffin());
|
||||
}
|
||||
|
||||
// TODO: make all symbols href links
|
||||
|
||||
@Override
|
||||
public void writePageContent(MaisDocWriteEvent<MaisDocPage> e) throws IOException {
|
||||
MaisDocContentWriter writer = e.getWriter();
|
||||
try (ContentCloseable content = writer.docPageContent()) {
|
||||
try (ContentCloseable table = writer.docTable(FourCornerDotCake.FC_CDC1604_P6.nameSpec(), null, MaisDocContentCss.overviewSummary)) {
|
||||
writeTableBoxHeaderNumeric(writer, 17);
|
||||
writeCDC(writer, 0x00);
|
||||
writeCDC(writer, 0x10);
|
||||
writeCDC(writer, 0x20);
|
||||
writeCDC(writer, 0x30);
|
||||
}
|
||||
}
|
||||
try (ContentCloseable content = writer.docPageContent()) {
|
||||
String xSpec = FourCornerDotCake.FC_APL0127_P7A.nameSpec().replaceAll("P7A", "P7x");
|
||||
try (ContentCloseable table = writer.docTable(xSpec, null, MaisDocContentCss.overviewSummary)) {
|
||||
writeTableBoxHeaderNumeric(writer, 28, true);
|
||||
writeP7x(writer, FourCornerDotCake.FC_APL0127_P7A, v -> FCDotAPL0127DashP7A.valueOf(v).codePointDotIndex());
|
||||
writeP7x(writer, FourCornerDotCake.FC_APL0127_P7B, v -> FCDotAPL0127DashP7B.valueOf(v).codePointDotIndex());
|
||||
writeP7x(writer, FourCornerDotCake.FC_APL0127_P7C, v -> FCDotAPL0127DashP7C.valueOf(v).codePointDotIndex());
|
||||
}
|
||||
}
|
||||
try (ContentCloseable content = writer.docPageContent()) {
|
||||
String xSpec = FourCornerDotCake.FC_BYD0127_P7D.nameSpec().replaceAll("P7D", "P7x");
|
||||
try (ContentCloseable table = writer.docTable(xSpec, null, MaisDocContentCss.overviewSummary)) {
|
||||
writeTableBoxHeaderNumeric(writer, 28, true);
|
||||
writeP7x(writer, FourCornerDotCake.FC_BYD0127_P7D, v -> FCDotBYD0127DashP7D.valueOf(v).codePointDotIndex());
|
||||
writeP7x(writer, FourCornerDotCake.FC_BYD0127_P7E, v -> FCDotBYD0127DashP7E.valueOf(v).codePointDotIndex());
|
||||
writeP7x(writer, FourCornerDotCake.FC_BYD0127_P7F, v -> FCDotBYD0127DashP7F.valueOf(v).codePointDotIndex());
|
||||
}
|
||||
}
|
||||
try (ContentCloseable content = writer.docPageContent()) {
|
||||
String xSpec = FourCornerDotCake.FC_PIE9C_01.nameSpec().replaceAll("01", "Left");
|
||||
try (ContentCloseable table = writer.docTable(xSpec, null, MaisDocContentCss.overviewSummary)) {
|
||||
writeTableBoxHeaderNumeric(writer, 28, true);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_01);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_02);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_03);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_04);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_05);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_06);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_07);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_08);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_09);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_10);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_11);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_12);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_13);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_14);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_15);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_16);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_17);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_18);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_19);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_20);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_21);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_22);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_23);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_24);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_25);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_26);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9C_27);
|
||||
}
|
||||
}
|
||||
try (ContentCloseable content = writer.docPageContent()) {
|
||||
String xSpec = FourCornerDotCake.FC_PIE9D_01.nameSpec().replaceAll("01", "Right");
|
||||
try (ContentCloseable table = writer.docTable(xSpec, null, MaisDocContentCss.overviewSummary)) {
|
||||
writeTableBoxHeaderNumeric(writer, 28, true);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_01);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_02);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_03);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_04);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_05);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_06);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_07);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_08);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_09);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_10);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_11);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_12);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_13);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_14);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_15);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_16);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_17);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_18);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_19);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_20);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_21);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_22);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_23);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_24);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_25);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_26);
|
||||
writePIE(writer, FourCornerDotCake.FC_PIE9D_27);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writePIE(MaisDocContentWriter writer, FourCornerDotCake slice) throws IOException {
|
||||
try (ContentCloseable tableRow = writer.docTableRow()) {
|
||||
String prefixHex = String.format("0x%06X", slice.getStart());
|
||||
writer.printTagStart(Tag.td, MaisDocContentCss.colFirst);
|
||||
writer.printCharacters(prefixHex);
|
||||
writer.printTagEnd(Tag.td);
|
||||
writer.printTagStart(Tag.td, MaisDocContentCss.colOne);
|
||||
writer.printCharacters(slice.nameSpec());
|
||||
writer.printTagEnd(Tag.td);
|
||||
for (int i = 0; i < 27; i++) {
|
||||
if (i + 1 < 27) {
|
||||
writer.printTagStart(Tag.td);
|
||||
} else {
|
||||
writer.printTagStart(Tag.td, MaisDocContentCss.colLast);
|
||||
}
|
||||
if (i >= slice.getLength()) {
|
||||
writer.printTagEnd(Tag.td);
|
||||
continue;
|
||||
}
|
||||
int char18 = slice.getStart() + i;
|
||||
String char18Str = FourCornerUnicodeDisplay.text().renderFromInt18(List.of(char18));
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int c : char18Str.codePoints().toArray()) {
|
||||
if (c == '\u0000') {
|
||||
buf.append("␀");
|
||||
} else {
|
||||
buf.appendCodePoint(c);
|
||||
}
|
||||
}
|
||||
writer.printCharacters(buf.toString());
|
||||
writer.printTagEnd(Tag.td);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,158 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentCss;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentWriter;
|
||||
import org.x4o.sax3.SAX3WriterHtml.Tag;
|
||||
import org.x4o.sax3.io.ContentCloseable;
|
||||
import org.xml.sax.helpers.AttributesImpl;
|
||||
|
||||
/**
|
||||
* Cake doc generic page writer.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 18, 2025
|
||||
*/
|
||||
public interface FCDocSegmentWriter {
|
||||
|
||||
default void writeP7x(MaisDocContentWriter writer, FourCornerDotCake slice, Function<Integer, Integer> conv) throws IOException {
|
||||
String prefixHex = String.format("0x%06X", slice.getStart());
|
||||
try (ContentCloseable tableRow = writer.docTableRow()) {
|
||||
try (ContentCloseable td = writer.printTag(Tag.td, MaisDocContentCss.colFirst)) {
|
||||
writer.printCharacters(prefixHex);
|
||||
}
|
||||
try (ContentCloseable td = writer.printTag(Tag.td, MaisDocContentCss.colOne)) {
|
||||
writer.printCharacters(slice.nameSpec());
|
||||
}
|
||||
for (int i = 0; i < 27; i++) {
|
||||
int codePoint = conv.apply(i);
|
||||
if (i + 1 < 27) {
|
||||
writer.printTagStart(Tag.td);
|
||||
} else {
|
||||
writer.printTagStart(Tag.td, MaisDocContentCss.colLast);
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (codePoint == '\u0000') {
|
||||
buf.append("␀");
|
||||
} else {
|
||||
buf.appendCodePoint(codePoint);
|
||||
}
|
||||
writer.printCharacters(buf.toString());
|
||||
writer.printTagEnd(Tag.td);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default void writeCDC(MaisDocContentWriter writer, int off) throws IOException {
|
||||
String prefixHex = String.format("0x%05X0", off >> 4);
|
||||
try (ContentCloseable tableRow = writer.docTableRow()) {
|
||||
writer.printTagStart(Tag.td, MaisDocContentCss.colOne);
|
||||
writer.printCharacters(prefixHex);
|
||||
writer.printTagEnd(Tag.td);
|
||||
for (int i = off; i < 16 + off; i++) {
|
||||
FCDotCDC1604DashP6 cdc = FCDotCDC1604DashP6.valueOf(i);
|
||||
int codePoint = cdc.codePointDotIndex();
|
||||
if (i + 1 < 16 + off) {
|
||||
writer.printTagStart(Tag.td);
|
||||
} else {
|
||||
writer.printTagStart(Tag.td, MaisDocContentCss.colLast);
|
||||
}
|
||||
StringBuilder buf = new StringBuilder();
|
||||
if (codePoint == '\u0000') {
|
||||
buf.append("␀");
|
||||
} else if (codePoint == '\u0001') {
|
||||
buf.append("␁");
|
||||
} else if (codePoint == '\u0002') {
|
||||
buf.append("␂");
|
||||
} else if (codePoint == '\u0003') {
|
||||
buf.append("␃");
|
||||
} else if (codePoint == ' ') {
|
||||
buf.append("␠");
|
||||
} else if (codePoint == '\n') {
|
||||
buf.append("␊");
|
||||
} else {
|
||||
buf.appendCodePoint(codePoint);
|
||||
}
|
||||
writer.printCharacters(buf.toString());
|
||||
writer.printTagEnd(Tag.td);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default void writeTableBoxHeader(MaisDocContentWriter writer, String[] headers) throws IOException {
|
||||
try (ContentCloseable td = writer.printTag(Tag.tr)) {
|
||||
AttributesImpl atts;
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
atts = new AttributesImpl();
|
||||
if (i == 0) {
|
||||
atts.addAttribute("", "class", "", "", MaisDocContentCss.colFirst.name());
|
||||
} else if (i == 1) {
|
||||
atts.addAttribute("", "class", "", "", MaisDocContentCss.colOne.name());
|
||||
} else {
|
||||
atts.addAttribute("", "class", "", "", MaisDocContentCss.colLast.name());
|
||||
}
|
||||
atts.addAttribute("", "scope", "", "", "col");
|
||||
try (ContentCloseable th = writer.printTag(Tag.th, atts)) {
|
||||
writer.printCharacters(headers[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default void writeTableBoxHeaderNumeric(MaisDocContentWriter writer, int num) throws IOException {
|
||||
writeTableBoxHeaderNumeric(writer, num, false);
|
||||
}
|
||||
|
||||
default void writeTableBoxHeaderNumeric(MaisDocContentWriter writer, int num, boolean colFirst) throws IOException {
|
||||
writer.printTagStart(Tag.tr);
|
||||
AttributesImpl atts;
|
||||
if (colFirst) {
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute("", "class", "", "", MaisDocContentCss.colFirst.name());
|
||||
atts.addAttribute("", "scope", "", "", "col");
|
||||
writer.printTagStart(Tag.th, atts);
|
||||
writer.printTagEnd(Tag.th);
|
||||
}
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute("", "class", "", "", MaisDocContentCss.colOne.name());
|
||||
atts.addAttribute("", "scope", "", "", "col");
|
||||
writer.printTagStart(Tag.th, atts);
|
||||
writer.printTagEnd(Tag.th);
|
||||
for (int i = 0; i < num - 1; i++) {
|
||||
atts = new AttributesImpl();
|
||||
atts.addAttribute("", "class", "", "", MaisDocContentCss.colLast.name());
|
||||
atts.addAttribute("", "scope", "", "", "col");
|
||||
writer.printTagStart(Tag.th, atts);
|
||||
writer.printCharacters("0x");
|
||||
writer.printCharacters(Integer.toHexString(i).toUpperCase());
|
||||
writer.printTagEnd(Tag.th);
|
||||
}
|
||||
writer.printTagEnd(Tag.tr);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,209 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentCss;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentWriter;
|
||||
import org.x4o.maisdoc.flake.MaisDocNodeWriterMethod;
|
||||
import org.x4o.maisdoc.model.MaisDocConcept;
|
||||
import org.x4o.maisdoc.model.MaisDocNode;
|
||||
import org.x4o.maisdoc.model.MaisDocNodeBody;
|
||||
import org.x4o.maisdoc.model.MaisDocWriteEvent;
|
||||
import org.x4o.sax3.SAX3WriterHtml.Tag;
|
||||
import org.x4o.sax3.io.ContentCloseable;
|
||||
|
||||
/**
|
||||
* Cake doc slice writer.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 17, 2025
|
||||
*/
|
||||
public class FCDocSegmentWriterCake implements FCDocSegmentWriter {
|
||||
|
||||
private static final String[] FC_FEATURES = new String[] {
|
||||
"Text format design to write computer code and abstract file/resource names",
|
||||
"Code from chinees child can be extended by indian child or spanish child in local local",
|
||||
"VT-06 terminal control for CDC1604(1960) 6 bit main frames",
|
||||
"Has underscored letters to migrate EBCDIC(1963) APL code from z/OS",
|
||||
"Program with (local) words not with lettersssss",
|
||||
"New Counting Rods, 1152 bit fractions with two 576 bit numbers",
|
||||
"Use datagrams for decimals/octals/hex/bits to render in monkey language",
|
||||
"Supports HolyC sand worms in your text for undefined octal data",
|
||||
"Embed 21 bit unicode for 6/8 and 18 bit computers",
|
||||
"The lower 6/8 bit part is pattern graphic renderable with optional kerning",
|
||||
"Contains the BIP0039(2013) keyword encoding too",
|
||||
"Render on 6 bit(baklave point) or 8(muffin point) bit as KANJI + BraSCII + PIE",
|
||||
"Render with 21 bit unicode(code point) + fonts drawings",
|
||||
"Render on 18 bit(cake point) with 72 bit unicode4D drawings"
|
||||
};
|
||||
|
||||
private static final String[] FC_TODO = new String[] {
|
||||
"DOC: Add all needed info into word/pie/pages doc",
|
||||
"Write rules; no candy(0x3F3--) for grown up computer languages",
|
||||
"Finish ESC sequences",
|
||||
"Add doctype for 6,8,18 AND allow candy AND XDBX/etc",
|
||||
"Add binary XML support, maybe also doc tags and MD structure",
|
||||
"Move APL candy to PIE towers",
|
||||
"Replace APL with BraSCII 0xC0++ candies",
|
||||
"Fillup PIE math symbol candy towers",
|
||||
"Fillup languages in CLK9P word cake (in all human languages)",
|
||||
"Request new 'Japanese Industrial Standard X 0214', Add full CJK,BraSCII++,PIE",
|
||||
"Define unicode+4D and 'JIS X 0208' text or symbols for txt-grams (in all human languages)",
|
||||
"Define unicode+4D and 'JIS X 0208' words for four corner words (in all human languages)",
|
||||
};
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.DESCRIPTION_NODE, targetClasses = {TDocCake.class}, nodeBodyOrders = 30)
|
||||
public void writeTodoList(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
writer.printCharacters("TODO;");
|
||||
try (ContentCloseable content = writer.docPageContent()) {
|
||||
try (ContentCloseable ul = writer.printTag(Tag.ul)) {
|
||||
for (String feature : FC_TODO) {
|
||||
try (ContentCloseable li = writer.printTag(Tag.li, "", null, "circle")) {
|
||||
writer.printCharacters(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.DESCRIPTION_NODE, targetClasses = {TDocCake.class}, nodeBodyOrders = 20)
|
||||
public void writeFeatureListing(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
writer.printCharacters("Features;");
|
||||
try (ContentCloseable content = writer.docPageContent()) {
|
||||
try (ContentCloseable ul = writer.printTag(Tag.ul)) {
|
||||
for (String feature : FC_FEATURES) {
|
||||
try (ContentCloseable li = writer.printTag(Tag.li, "", null, "circle")) {
|
||||
writer.printCharacters(feature);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.DESCRIPTION_NODE, targetClasses = {TDocCake.class}, nodeBodyOrders = 1)
|
||||
public void writeIntro(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
writer.printCharacters("Four corner is 18 bit text encoding for 144 bit computers.");
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.DESCRIPTION_NODE, targetClasses = {TDocCake.class}, nodeBodyOrders = 100)
|
||||
public void writeOutro(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
writer.printCharacters("Allow a chineese child to use a computer without any british legacy.");
|
||||
try (ContentCloseable content = writer.docPageContent()) {
|
||||
writer.printCharacters("Unicode bad monkey, real china computer is strong, eat MSX baklava with brazilian ROM v1.1 and KANJI JIS1&2 ROM together.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = {TDocCake.class}, nodeBodyOrders = 20)
|
||||
public void writeDefaultSummary(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||
// NOTE: copyed from defaultWriteSummary as that only called with zero summaries
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
MaisDocNode parent = event.getEventObject();
|
||||
MaisDocConcept concept = event.getDoc().findConceptByClass(parent.getUserData().getClass());
|
||||
List<MaisDocNode> nodes = parent.getNodes();
|
||||
if (nodes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String name = concept.getName()+" Summary";
|
||||
writer.docTableStart(name, "All childeren in "+name, MaisDocContentCss.overviewSummary);
|
||||
writer.docTableHeader("Name", "Description");
|
||||
for (MaisDocNode child : nodes) {
|
||||
String link = MaisDocContentWriter.toSafeUri(child.getId())+"/index.html";
|
||||
if (parent.getParent() == null) {
|
||||
link = MaisDocContentWriter.toSafeUri(parent.getId())+"/"+link; // root node
|
||||
}
|
||||
writer.docTableRowLink(link,child.getName(),child.getDescription());
|
||||
}
|
||||
writer.docTableEnd();
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody = MaisDocNodeBody.SUMMARY, targetClasses = {TDocCake.class}, nodeBodyOrders = 30)
|
||||
public void writeTowerSummary(MaisDocWriteEvent<MaisDocNode> e) throws IOException {
|
||||
String rootId = e.getDoc().getRootNode().getId();
|
||||
MaisDocConcept concept = e.getDoc().findConceptByClass(e.getEventObject().getUserData().getClass());
|
||||
String tableName = concept.getName() + " Elevator";
|
||||
MaisDocContentWriter writer = e.getWriter();
|
||||
try (ContentCloseable table = writer.docTable(tableName, null, MaisDocContentCss.overviewSummary)) {
|
||||
writeTableBoxHeader(writer, new String[] {"Cake", "Tower", "Start", "Stop", "Size", "External"});
|
||||
Set<FourCornerDotCake> linkableSlices = new HashSet<>();
|
||||
for (MaisDocNode towerNode : e.getEventObject().getNodes()) {
|
||||
for (MaisDocNode sliceNode : towerNode.getNodes()) {
|
||||
FourCornerDotCake slice = sliceNode.toUserData(TDocCakeSlice.class).getSlice();
|
||||
linkableSlices.add(slice);
|
||||
StringBuilder buf = new StringBuilder();
|
||||
buf.append(MaisDocContentWriter.toSafeUri(rootId)); // TODO: add full tree node ID href version of toSafeUri
|
||||
buf.append("/");
|
||||
buf.append(MaisDocContentWriter.toSafeUri(towerNode.getId()));
|
||||
buf.append("/");
|
||||
buf.append(MaisDocContentWriter.toSafeUri(sliceNode.getId()));
|
||||
buf.append("/index.html");
|
||||
writeCake(writer, slice, Optional.of(buf.toString()));
|
||||
}
|
||||
}
|
||||
for (FourCornerDotCake slice : FourCornerDotCake.values()) {
|
||||
if (linkableSlices.contains(slice)) {
|
||||
continue;
|
||||
}
|
||||
writeCake(writer, slice, Optional.empty());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeCake(MaisDocContentWriter writer, FourCornerDotCake slice, Optional<String> href) throws IOException {
|
||||
try (ContentCloseable tableRow = writer.docTableRow()) {
|
||||
try (ContentCloseable td = writer.printTag(Tag.td, MaisDocContentCss.colFirst)) {
|
||||
if (href.isEmpty()) {
|
||||
writer.printCharacters(slice.nameSpec());
|
||||
} else {
|
||||
writer.printHref(href.get(), slice.nameSpec(), slice.description(), "strong");
|
||||
}
|
||||
}
|
||||
try (ContentCloseable td = writer.printTag(Tag.td, MaisDocContentCss.colOne)) {
|
||||
writer.printCharacters(slice.tower().nameNice());
|
||||
}
|
||||
try (ContentCloseable td = writer.printTag(Tag.td, MaisDocContentCss.colLast)) {
|
||||
writer.printCharacters(String.format("0x%06X", slice.getStart()));
|
||||
}
|
||||
try (ContentCloseable td = writer.printTag(Tag.td, MaisDocContentCss.colLast)) {
|
||||
writer.printCharacters(String.format("0x%06X", slice.getStop()));
|
||||
}
|
||||
try (ContentCloseable td = writer.printTag(Tag.td, MaisDocContentCss.colLast)) {
|
||||
writer.printCharacters(String.format("%d", slice.getLength()));
|
||||
}
|
||||
try (ContentCloseable td = writer.printTag(Tag.td, MaisDocContentCss.colLast)) {
|
||||
writer.printCharacters(Boolean.toString(slice.isExternWord()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentCss;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentWriter;
|
||||
import org.x4o.maisdoc.flake.MaisDocNodeWriterMethod;
|
||||
import org.x4o.maisdoc.model.MaisDocConcept;
|
||||
import org.x4o.maisdoc.model.MaisDocNode;
|
||||
import org.x4o.maisdoc.model.MaisDocNodeBody;
|
||||
import org.x4o.maisdoc.model.MaisDocWriteEvent;
|
||||
import org.x4o.sax3.io.ContentCloseable;
|
||||
|
||||
/**
|
||||
* Cake doc segment slice writer.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 17, 2025
|
||||
*/
|
||||
public class FCDocSegmentWriterCakeSlice implements FCDocSegmentWriter {
|
||||
|
||||
// NOTE: Table are not allowed in details
|
||||
// @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL, targetClasses={TDocCakeSlice.class}, nodeBodyOrders=20)
|
||||
public void writeDefaultSummary(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||
// NOTE: copyed from defaultWriteSummary as that only called with zero summaries + changes name end in; Words
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
MaisDocNode parent = event.getEventObject();
|
||||
MaisDocConcept concept = event.getDoc().findConceptByClass(parent.getUserData().getClass());
|
||||
List<MaisDocNode> nodes = parent.getNodes();
|
||||
if (nodes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String name = concept.getName()+" Words";
|
||||
writer.docTableStart(name, "All childeren in "+name,MaisDocContentCss.overviewSummary);
|
||||
writer.docTableHeader("Name", "Description");
|
||||
for (MaisDocNode child : nodes) {
|
||||
String link = MaisDocContentWriter.toSafeUri(child.getId())+"/index.html";
|
||||
if (parent.getParent()==null) {
|
||||
link = MaisDocContentWriter.toSafeUri(parent.getId())+"/"+link; // root node
|
||||
}
|
||||
writer.docTableRowLink(link,child.getName(),child.getDescription());
|
||||
}
|
||||
writer.docTableEnd();
|
||||
}
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY, targetClasses={TDocCakeSlice.class}, nodeBodyOrders=1)
|
||||
public void writeCakeSliceDetails(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
FourCornerDotCake slice = event.getEventObject().toUserData(TDocCakeSlice.class).getSlice();
|
||||
try (ContentCloseable table = writer.docTable("Cake Slice", null, MaisDocContentCss.overviewSummary)) {
|
||||
writer.docTableHeader("Information", "Value");
|
||||
writer.docTableRow("Start index", String.format("0x%06X", slice.getStart()));
|
||||
writer.docTableRow("Stop index", String.format("0x%06X", slice.getStop()));
|
||||
writer.docTableRow("Size", Integer.toString(slice.getLength()));
|
||||
writer.docTableRow("External word", Boolean.toString(slice.isExternWord()));
|
||||
}
|
||||
writeDefaultSummary(event);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.PrimitiveIterator;
|
||||
|
||||
import org.x4o.fc18.cake2.FourCornerX00PetitVideCoinCarne;
|
||||
import org.x4o.fc18.cake2.FourCornerX06BaklavaPointSequence;
|
||||
import org.x4o.fc18.cake2.FourCornerX08MuffinPointSequence;
|
||||
import org.x4o.fc18.cake2.FourCornerX18CakePointDotName;
|
||||
import org.x4o.fc18.cake2.FourCornerX18CakePointSequence;
|
||||
import org.x4o.fc18.cake2.FourCornerX21CodePointSequence;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentCss;
|
||||
import org.x4o.maisdoc.flake.MaisDocContentWriter;
|
||||
import org.x4o.maisdoc.flake.MaisDocNodeWriterMethod;
|
||||
import org.x4o.maisdoc.model.MaisDocNode;
|
||||
import org.x4o.maisdoc.model.MaisDocNodeBody;
|
||||
import org.x4o.maisdoc.model.MaisDocWriteEvent;
|
||||
import org.x4o.fc18.cake2.FourCornerX00PetitVide;
|
||||
import org.x4o.sax3.SAX3WriterHtml.Tag;
|
||||
|
||||
/**
|
||||
* Cake doc word writer.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 17, 2025
|
||||
*/
|
||||
public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter {
|
||||
|
||||
@MaisDocNodeWriterMethod(nodeBody=MaisDocNodeBody.SUMMARY,targetClasses={TDocCakeWord.class})
|
||||
public void writeCakeWordSummary(MaisDocWriteEvent<MaisDocNode> event) throws IOException {
|
||||
MaisDocContentWriter writer = event.getWriter();
|
||||
TDocCakeWord word = event.getEventObject().toUserData(TDocCakeWord.class);
|
||||
FourCornerX00PetitVide[] videPoints = word.getSlice().getVidePoints();
|
||||
if (videPoints.length == 0) {
|
||||
writer.printTagStart(Tag.pre);
|
||||
writer.printCharacters("No PetitVide data for: " + word.toString());
|
||||
writer.printTagEnd(Tag.pre);
|
||||
return;
|
||||
}
|
||||
FourCornerX00PetitVide videPoint = videPoints[word.getOffset()];
|
||||
Optional<FourCornerX21CodePointSequence> x21CodeDisplay = videPoint.kaasX21CodeSequence();
|
||||
Optional<FourCornerX06BaklavaPointSequence> x06BaklavaSequence = videPoint.kaasX06BaklavaSequence();
|
||||
Optional<FourCornerX08MuffinPointSequence> x08MuffinSequence = videPoint.kaasX08MuffinSequence();
|
||||
Optional<FourCornerX18CakePointSequence> x18CakeSequence = videPoint.kaasX18CakeSequence();
|
||||
Optional<FourCornerX18CakePointDotName> x18DotName = videPoint.kaasX18CakeDotName();
|
||||
|
||||
writer.docTableStart("Word Summary", "The cake word point value information.",MaisDocContentCss.overviewSummary);
|
||||
writer.docTableHeader("Point", "Value");
|
||||
String name = word.toString();
|
||||
String value = "";
|
||||
if (x18DotName.isPresent()) {
|
||||
name = x18DotName.get().name();
|
||||
}
|
||||
if (x21CodeDisplay.isPresent()) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
x21CodeDisplay.get().codePointSequence().forEach(v -> buf.appendCodePoint(v));
|
||||
value = buf.toString();
|
||||
}
|
||||
writer.docTableRow(name, value);
|
||||
|
||||
if (x06BaklavaSequence.isPresent()) {
|
||||
writeSequence(writer, "Sequence-X06", 2, x06BaklavaSequence.get().baklavaPointSequence());
|
||||
}
|
||||
if (x08MuffinSequence.isPresent()) {
|
||||
writeSequence(writer, "Sequence-X08", 2, x08MuffinSequence.get().muffinPointSequence());
|
||||
}
|
||||
if (x18CakeSequence.isPresent()) {
|
||||
writeSequence(writer, "Sequence-X18", 6, x18CakeSequence.get().cakePointSequence());
|
||||
}
|
||||
if (x21CodeDisplay.isPresent()) {
|
||||
writeSequence(writer, "Sequence-X21", 6, x21CodeDisplay.get().codePointSequence());
|
||||
StringBuilder bufUTF8 = new StringBuilder();
|
||||
x21CodeDisplay.get().codePointSequence().forEach(v -> bufUTF8.appendCodePoint(v));
|
||||
byte[] sequenceUTF8Bytes = bufUTF8.toString().getBytes(StandardCharsets.UTF_8);
|
||||
List<Integer> sequenceUTF8 = new ArrayList<>();
|
||||
for (int i = 0; i < sequenceUTF8Bytes.length; i++) {
|
||||
sequenceUTF8.add(Byte.toUnsignedInt(sequenceUTF8Bytes[i]));
|
||||
}
|
||||
writeSequence(writer, "Sequence-X21-UTF8", 2, sequenceUTF8);
|
||||
|
||||
StringBuilder bufXML = new StringBuilder();
|
||||
PrimitiveIterator.OfInt codePoints = bufUTF8.codePoints().iterator();
|
||||
while (codePoints.hasNext()) {
|
||||
int codePoint = codePoints.nextInt();
|
||||
bufXML.append("&#x"); // manual & to show literal escape string
|
||||
bufXML.append(Integer.toHexString(codePoint));
|
||||
bufXML.append(";");
|
||||
}
|
||||
writer.docTableRow("Sequence-X21-XML", bufXML.toString());
|
||||
}
|
||||
writer.docTableEnd();
|
||||
// }
|
||||
// // TODO: merge summary to one content block
|
||||
//
|
||||
// @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY,targetClasses={TDocCakeWord.class})
|
||||
// public void writeCakeWordSummary2(ApiDocWriteEvent<ApiDocNode> event) throws IOException {
|
||||
// ApiDocContentWriter writer = event.getWriter();
|
||||
// TDocCakeWord word = event.getEventObject().toUserData(TDocCakeWord.class);
|
||||
// FourCornerX00PetitVide[] videPoints = word.getSlice().getVidePoints();
|
||||
// if (videPoints.length == 0) {
|
||||
// return;
|
||||
// }
|
||||
// FourCornerX00PetitVide videPoint = videPoints[word.getOffset()];
|
||||
Optional<FourCornerX00PetitVideCoinCarne> x00CoinCarne = videPoint.kaasX00CoinCarne();
|
||||
if (x00CoinCarne.isPresent()) {
|
||||
FourCornerX00PetitVideCoinCarne cornerKerning = x00CoinCarne.get();
|
||||
writer.docTableStart("Kerning Summary", "Kerning all pattern displays.",MaisDocContentCss.overviewSummary);
|
||||
writer.docTableHeader("Location", "Corner dents");
|
||||
writer.docTableRow("Top", cornerKerning.coinCarneFrapper().kerningTop().name());
|
||||
writer.docTableRow("Bottom", cornerKerning.coinCarneFrapper().kerningBottom().name());
|
||||
writer.docTableEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void writeSequence(MaisDocContentWriter writer, String system, int minHex, List<Integer> sequence) throws IOException {
|
||||
String displayFormat = "0x%0" + minHex + "X";
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (int i = 0; i < sequence.size(); i++) {
|
||||
int seq = sequence.get(i);
|
||||
String hex = String.format(displayFormat, seq);
|
||||
buf.append(hex);
|
||||
if (i + 1 < sequence.size()) {
|
||||
buf.append(" - ");
|
||||
}
|
||||
}
|
||||
writer.docTableRow(system, buf.toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
import org.x4o.fc18.cake2.FourCornerDotCakeTower;
|
||||
import org.x4o.fc18.cake2.FourCornerX00PetitVide;
|
||||
import org.x4o.fc18.cake2.FourCornerX18CakePointDotName;
|
||||
import org.x4o.fc18.cake2.FourCornerX21CodePointSequence;
|
||||
import org.x4o.maisdoc.flake.MaisDocGenerator;
|
||||
import org.x4o.maisdoc.flake.DefaultPageWriterHelp;
|
||||
import org.x4o.maisdoc.flake.DefaultPageWriterTree;
|
||||
import org.x4o.maisdoc.model.MaisDoc;
|
||||
import org.x4o.maisdoc.model.MaisDocConcept;
|
||||
import org.x4o.maisdoc.model.MaisDocNode;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
/**
|
||||
* Cake doc writer.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 17, 2025
|
||||
*/
|
||||
public class FCDocWriter {
|
||||
|
||||
private static final String[] C_FC_ROOT = {"fc-root","Wedding","All cake levels.","The cake tower of the four corner wedding cake."};
|
||||
private static final String[] C_FC_TOWER = {"fc-tower","Tower","All cake slices.","The cake slices of the four corner cake tower."};
|
||||
private static final String[] C_FC_SLICE = {"fc-slice","Cake","The cake slice information.","The four corner cake slice provides the layout of boundries."};
|
||||
private static final String[] C_FC_WORD = {"fc-word","Word","An FC18 word.","The word of an number."};
|
||||
|
||||
private MaisDocGenerator writer = null;
|
||||
private MaisDoc doc = null;
|
||||
|
||||
static public void main(String[] args) {
|
||||
Iterator<String> arguments = Arrays.asList(args).iterator();
|
||||
String outputFolder = null;
|
||||
Integer stopCakePoint = null;
|
||||
while (arguments.hasNext()) {
|
||||
String arg = arguments.next();
|
||||
if ("-output".equals(arg)) {
|
||||
if (!arguments.hasNext()) {
|
||||
System.err.println("No output folder given.");
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
outputFolder = arguments.next();
|
||||
}
|
||||
if ("-stop".equals(arg)) {
|
||||
if (!arguments.hasNext()) {
|
||||
System.err.println("No stop argument given, try; 255 or 2048");
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
String stopNum = arguments.next();
|
||||
stopCakePoint = Integer.parseInt(stopNum);
|
||||
}
|
||||
}
|
||||
if (outputFolder == null) {
|
||||
System.err.println("Missing output argument");
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
System.out.println("Writing fcdoc, ... it takes a while ...");
|
||||
if (stopCakePoint != null) {
|
||||
System.out.println("Writing fcdoc, stop requested at: " + stopCakePoint);
|
||||
}
|
||||
FCDocWriter run = new FCDocWriter(stopCakePoint);
|
||||
try {
|
||||
File out = new File(outputFolder);
|
||||
//out.mkdir();
|
||||
run.writeModelDoc(out);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
System.out.println("Writing fcdoc, DONE");
|
||||
}
|
||||
|
||||
public FCDocWriter(Integer stopCakePoint) {
|
||||
this.doc = buildApiDoc(new TDocCake(), stopCakePoint);
|
||||
this.writer = new MaisDocGenerator();
|
||||
}
|
||||
|
||||
public MaisDoc getApiDoc() {
|
||||
return doc;
|
||||
}
|
||||
|
||||
public void writeModelDoc(File basePath) throws IOException, SAXException {
|
||||
doc.checkModel();
|
||||
writer.write(doc,basePath);
|
||||
}
|
||||
|
||||
private MaisDoc buildApiDoc(TDocCake docCake, Integer stopCakePoint) {
|
||||
MaisDoc doc = new MaisDoc();
|
||||
doc.setName("FourCorner");
|
||||
doc.setDescription("FourCorner 18 bit text encoding format.");
|
||||
doc.setDocAbout("FourCorner Indexes\nThe World Of Words™");
|
||||
doc.createDocCopyright("𑀳𑁂𑀮𑀺𑀉𑁄𑀤𑁄𑀭𑁂𑀡𑀪𑀸𑀕", "תשפ״ה"); // use hebrew quotation mark, the interweb uses latin which break unicode rendering
|
||||
doc.setDocPageSubTitle("FC18-Alpha1");
|
||||
doc.addMetaKeywordAll(List.of("FC18", "documentation", "four-corner", "china", "MSX4"));
|
||||
doc.setNoFrameAllName("All cake slices");
|
||||
doc.setFrameNavOverviewPrintParent(true);
|
||||
doc.setFrameNavPrintParent(true);
|
||||
doc.setFrameNavPrintParentParent(true);
|
||||
doc.setGroupTypeName("summary", "Summary",1);
|
||||
doc.setGroupTypeName("overview", "Overview",2);
|
||||
|
||||
doc.addTreeNodeClassExclude(TDocCakeWord.class);
|
||||
doc.setFrameNavConceptClass(TDocCakeSlice.class);
|
||||
|
||||
doc.addTreeNodePageModeClass(TDocCake.class);
|
||||
doc.addTreeNodePageModeClass(TDocCakeTower.class);
|
||||
|
||||
doc.addAnnotatedClasses(FCDocSegmentWriterCake.class);
|
||||
doc.addAnnotatedClasses(FCDocSegmentWriterCakeWord.class);
|
||||
doc.addAnnotatedClasses(FCDocSegmentWriterCakeSlice.class);
|
||||
|
||||
MaisDocConcept adc1 = doc.addConcept(new MaisDocConcept(null,C_FC_ROOT,TDocCake.class));
|
||||
MaisDocConcept adc2 = doc.addConcept(new MaisDocConcept(adc1,C_FC_TOWER,TDocCakeTower.class));
|
||||
MaisDocConcept adc3 = doc.addConcept(new MaisDocConcept(adc2,C_FC_SLICE,TDocCakeSlice.class));
|
||||
/*ApiDocConcept adc4 = */doc.addConcept(new MaisDocConcept(adc3,C_FC_WORD,TDocCakeWord.class));
|
||||
|
||||
//ApiDocConcept adc4 = doc.addConcept(new ApiDocConcept(adc3,C_TABLE,Table.class));
|
||||
//adc4.addChildConcepts(new ApiDocConcept(adc4, CC_RS, Relationship.class));
|
||||
|
||||
doc.addDocPage(FCDocPageWriterMuffin.createDocPage());
|
||||
doc.addDocPage(FCDocPageWriterBaklava.createDocPage());
|
||||
doc.addDocPage(DefaultPageWriterTree.createDocPage());
|
||||
//doc.addDocPage(DefaultPageWriterIndexAll.createDocPage());
|
||||
doc.addDocPage(DefaultPageWriterHelp.createDocPage());
|
||||
|
||||
MaisDocNode rootNode = new MaisDocNode(docCake,"fc-root","Tower","All cake tower floors.");
|
||||
doc.setRootNode(rootNode);
|
||||
|
||||
for (FourCornerDotCakeTower tower : FourCornerDotCakeTower.values()) {
|
||||
MaisDocNode towerNode = rootNode.addNode(createNodeCakeTower(tower));
|
||||
for (FourCornerDotCake dotCake : FourCornerDotCake.valuesByTower(tower)) {
|
||||
if (stopCakePoint != null && dotCake.getStart() > stopCakePoint) {
|
||||
break;
|
||||
}
|
||||
MaisDocNode sliceNode = towerNode.addNode(createNodeCakeSlice(dotCake));
|
||||
for (int i = 0; i < dotCake.getLength(); i++) {
|
||||
/*ApiDocNode wordNode =*/ sliceNode.addNode(createNodeCakeWord(dotCake, i));
|
||||
}
|
||||
|
||||
// TODO: print full 21 bit unicode range too
|
||||
}
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeCakeTower(FourCornerDotCakeTower tower) {
|
||||
return new MaisDocNode(new TDocCakeTower(tower), tower.name(), tower.nameNice(), tower.description());
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeCakeSlice(FourCornerDotCake slice) {
|
||||
return new MaisDocNode(new TDocCakeSlice(slice), slice.name(), slice.nameSpec(), slice.description());
|
||||
}
|
||||
|
||||
private MaisDocNode createNodeCakeWord(FourCornerDotCake dotCake, int offset) {
|
||||
int cakePoint = dotCake.getStart() + offset;
|
||||
String idStr = String.format("0x%06X", cakePoint);
|
||||
String name = idStr;
|
||||
String desc = name;
|
||||
FourCornerX00PetitVide[] videPoints = dotCake.getVidePoints();
|
||||
if (videPoints.length != 0) {
|
||||
FourCornerX00PetitVide videPoint = videPoints[offset];
|
||||
Optional<FourCornerX18CakePointDotName> x18DotName = videPoint.kaasX18CakeDotName();
|
||||
if (x18DotName.isPresent()) {
|
||||
name = x18DotName.get().name();
|
||||
}
|
||||
Optional<FourCornerX21CodePointSequence> x21CodeDisplay = videPoint.kaasX21CodeSequence();
|
||||
if (x21CodeDisplay.isPresent()) {
|
||||
StringBuilder buf = new StringBuilder();
|
||||
x21CodeDisplay.get().codePointSequence().forEach(v -> buf.appendCodePoint(v));
|
||||
desc = buf.toString();
|
||||
}
|
||||
}
|
||||
return new MaisDocNode(new TDocCakeWord(dotCake, offset), idStr, name, desc);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
/**
|
||||
* Cake root doc model type.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 17, 2025
|
||||
*/
|
||||
public class TDocCake {
|
||||
|
||||
public TDocCake() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
|
||||
/**
|
||||
* Cake slice doc model type.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 19, 2025
|
||||
*/
|
||||
public class TDocCakeSlice {
|
||||
|
||||
private final FourCornerDotCake slice;
|
||||
|
||||
public TDocCakeSlice(FourCornerDotCake slice) {
|
||||
this.slice = slice;
|
||||
}
|
||||
|
||||
public FourCornerDotCake getSlice() {
|
||||
return slice;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
import org.x4o.fc18.cake2.FourCornerDotCakeTower;
|
||||
|
||||
/**
|
||||
* Cake slice doc model type.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 19, 2025
|
||||
*/
|
||||
public class TDocCakeTower {
|
||||
|
||||
private final FourCornerDotCakeTower tower;
|
||||
|
||||
public TDocCakeTower(FourCornerDotCakeTower tower) {
|
||||
this.tower = tower;
|
||||
}
|
||||
|
||||
public FourCornerDotCakeTower getTower() {
|
||||
return tower;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
|
||||
/**
|
||||
* Cake word doc model type.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 17, 2025
|
||||
*/
|
||||
public class TDocCakeWord {
|
||||
|
||||
private final FourCornerDotCake slice;
|
||||
private final int offset;
|
||||
|
||||
public TDocCakeWord(FourCornerDotCake slice, int offset) {
|
||||
this.slice = Objects.requireNonNull(slice);
|
||||
this.offset = offset;
|
||||
}
|
||||
|
||||
public FourCornerDotCake getSlice() {
|
||||
return slice;
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
return offset;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return String.format("%s.0x%06X", slice.nameSpec(), slice.getStart() + offset);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,182 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18.kanji;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ContentHandler;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.Locator;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
/**
|
||||
* Simple dict to lookup kanji.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 23, 2025
|
||||
*/
|
||||
public class KanjiDict {
|
||||
|
||||
Map<String, KanjiDictLiteral> mapKuTen208 = new HashMap<>();
|
||||
Map<String, KanjiDictLiteral> mapKuTen213 = new HashMap<>();
|
||||
Map<Integer, KanjiDictLiteral> mapFourCorner = new HashMap<>();
|
||||
|
||||
public KanjiDict() {
|
||||
}
|
||||
|
||||
public void parseXML(InputStream input) throws ParserConfigurationException, SAXException, IOException {
|
||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
SAXParser parser = factory.newSAXParser();
|
||||
XMLReader reader = parser.getXMLReader();
|
||||
KanjiDictContentHandler handler = new KanjiDictContentHandler();
|
||||
reader.setContentHandler(handler);
|
||||
InputSource inputSource = new InputSource(input);
|
||||
reader.parse(inputSource);
|
||||
}
|
||||
|
||||
class KanjiDictContentHandler implements ContentHandler {
|
||||
|
||||
StringBuilder bufChar = new StringBuilder();
|
||||
KanjiDictLiteral literal;
|
||||
String cpType;
|
||||
String qcType;
|
||||
String mLang;
|
||||
|
||||
private void addLiteral() {
|
||||
if (literal.getKuTen208() != null) {
|
||||
mapKuTen208.put(literal.getKuTen208(), literal);
|
||||
}
|
||||
if (literal.getKuTen213() != null) {
|
||||
mapKuTen213.put(literal.getKuTen213(), literal);
|
||||
}
|
||||
if (literal.getFourCorner() != null) {
|
||||
mapFourCorner.put(literal.getFourCorner(), literal);
|
||||
}
|
||||
literal = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||
bufChar.append(new String(ch,start,length));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endDocument() throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
|
||||
if ("character".equals(qName)) {
|
||||
addLiteral();
|
||||
} else if ("cp_value".equals(qName)) {
|
||||
if ("ucs".equals(cpType)) {
|
||||
literal.setCodePoint(Integer.parseInt(bufChar.toString(), 16));
|
||||
} else if ("jis208".equals(cpType)) {
|
||||
literal.setKuTen208(bufChar.toString());
|
||||
} else if ("jis213".equals(cpType)) {
|
||||
literal.setKuTen213(bufChar.toString());
|
||||
}
|
||||
} else if ("q_code".equals(qName)) {
|
||||
if ("four_corner".equals(qcType)) {
|
||||
literal.setFourCorner(Integer.parseInt(bufChar.toString().replaceAll("\\.", "")));
|
||||
}
|
||||
} else if ("meaning".equals(qName)) {
|
||||
String mean = bufChar.toString();
|
||||
if (mean.startsWith("(")) {
|
||||
mean = mean.replaceAll("\\(", "");
|
||||
mean = mean.replaceAll("\\)", "");
|
||||
}
|
||||
mean = mean.replaceAll("\\(.*\\)", "");
|
||||
mean = mean.replaceAll("\\?", "");
|
||||
mean = mean.replaceAll("\\!", "");
|
||||
mean = mean.replaceAll("\\-", "");
|
||||
mean = mean.split(",")[0];
|
||||
mean = mean.split("\'")[0];
|
||||
mean = mean.split("&")[0];
|
||||
mean = mean.split("/")[0];
|
||||
mean = mean.trim();
|
||||
mean = mean.toLowerCase();
|
||||
for (String rm : new String[] {"*","."}) {
|
||||
if (mean.contains(rm)) {
|
||||
mean = "";
|
||||
}
|
||||
}
|
||||
if (!mean.isEmpty()) {
|
||||
literal.addMeaning(mLang ,mean);
|
||||
}
|
||||
mLang = null;
|
||||
}
|
||||
bufChar = new StringBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endPrefixMapping(String arg0) throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignorableWhitespace(char[] arg0, int arg1, int arg2) throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processingInstruction(String arg0, String arg1) throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDocumentLocator(Locator arg0) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skippedEntity(String arg0) throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startDocument() throws SAXException {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
|
||||
if ("character".equals(qName)) {
|
||||
literal = new KanjiDictLiteral();
|
||||
} else if ("cp_value".equals(qName)) {
|
||||
cpType = atts.getValue("cp_type");
|
||||
} else if ("q_code".equals(qName)) {
|
||||
qcType = atts.getValue("qc_type");
|
||||
} else if ("meaning".equals(qName)) {
|
||||
mLang = atts.getValue("m_lang");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPrefixMapping(String arg0, String arg1) throws SAXException {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18.kanji;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Kanji KuTen and FourCorner and codePoint and meaning of a literal.
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 23, 2025
|
||||
*/
|
||||
public class KanjiDictLiteral {
|
||||
|
||||
private String kuTen208;
|
||||
private String kuTen213;
|
||||
private Integer fourCorner;
|
||||
private Integer codePoint;
|
||||
private final Map<String, List<String>> meaning = new HashMap<>();
|
||||
|
||||
public KanjiDictLiteral() {
|
||||
}
|
||||
|
||||
public String getKuTen208() {
|
||||
return kuTen208;
|
||||
}
|
||||
|
||||
public void setKuTen208(String kuTen208) {
|
||||
this.kuTen208 = kuTen208;
|
||||
}
|
||||
|
||||
public String getKuTen213() {
|
||||
return kuTen213;
|
||||
}
|
||||
|
||||
public void setKuTen213(String kuTen213) {
|
||||
this.kuTen213 = kuTen213;
|
||||
}
|
||||
|
||||
public Integer getFourCorner() {
|
||||
return fourCorner;
|
||||
}
|
||||
|
||||
public void setFourCorner(Integer fourCorner) {
|
||||
this.fourCorner = fourCorner;
|
||||
}
|
||||
|
||||
public Integer getCodePoint() {
|
||||
return codePoint;
|
||||
}
|
||||
|
||||
public void setCodePoint(Integer codePoint) {
|
||||
this.codePoint = codePoint;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getMeaning() {
|
||||
return meaning;
|
||||
}
|
||||
|
||||
public List<String> getMeaningDefault() {
|
||||
return meaning.get("");
|
||||
}
|
||||
|
||||
public void addMeaning(String locale, String text) {
|
||||
String key = locale==null?"":locale;
|
||||
List<String> data = meaning.get(key);
|
||||
if (data == null) {
|
||||
data = new ArrayList<>();
|
||||
meaning.put(key, data);
|
||||
}
|
||||
data.add(text);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,180 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2014, Willem Cazander
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
|
||||
* the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
||||
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package love.distributedrebirth.nx01.mushroom.mais.fc18.kanji;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.x4o.fc18.FourCornerUnicodeDisplay;
|
||||
import org.x4o.fc18.FourCornerUnicodeImport;
|
||||
import org.x4o.fc18.FourCornerUnicodeMapper;
|
||||
import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6;
|
||||
import org.x4o.fc18.cake2.zero33.dec1.FCDotCMD5401Dash2D;
|
||||
import org.x4o.fc18.octal8.PrimordialOctalOrangeString;
|
||||
|
||||
/**
|
||||
* Write data files from "kanjidic2.xml"
|
||||
*
|
||||
* @author Willem Cazander
|
||||
* @version 1.0 Jan 23, 2025
|
||||
*/
|
||||
public class KanjiDictTest {
|
||||
|
||||
static public void main(String[] args) throws Exception {
|
||||
if (args.length == 0) {
|
||||
System.err.println("No argument file given");
|
||||
System.exit(1);
|
||||
return;
|
||||
}
|
||||
KanjiDict dict = new KanjiDict();
|
||||
try (InputStream in = new FileInputStream(new File(args[0]))) {
|
||||
dict.parseXML(in);
|
||||
}
|
||||
System.out.println("=======================================");
|
||||
for (Integer key : dict.mapFourCorner.keySet()) {
|
||||
KanjiDictLiteral lit = dict.mapFourCorner.get(key);
|
||||
int meanCnt = lit.getMeaningDefault().size();
|
||||
String meaning = lit.getMeaningDefault().stream().map(v -> v.replaceAll(" ", "\u3000")).collect(Collectors.joining(" - "));
|
||||
System.out.print(new StringBuilder().appendCodePoint(lit.getCodePoint()).toString());
|
||||
System.out.println(String.format(" %s FC %5d = %2d %s", lit.getKuTen208(), lit.getFourCorner(), meanCnt, meaning));
|
||||
for (String locale : lit.getMeaning().keySet()) {
|
||||
if (!"es".equals(locale)) {
|
||||
continue;
|
||||
}
|
||||
List<String> texts = lit.getMeaning().get(locale);
|
||||
String text = texts.stream().map(v -> v.replaceAll(" ", "\u3000")).collect(Collectors.joining(" - "));
|
||||
System.out.println("\t\tLOCALE: " + locale + " TEXT: " + text);
|
||||
}
|
||||
}
|
||||
|
||||
List<Integer> kuTen2UNI2K = new ArrayList<>();
|
||||
for (String key : dict.mapKuTen208.keySet()) {
|
||||
KanjiDictLiteral lit = dict.mapKuTen208.get(key);
|
||||
String valueUnicode = new StringBuilder().appendCodePoint(lit.getCodePoint()).toString();
|
||||
kuTen2UNI2K.addAll(FourCornerUnicodeImport.strict().convertToInt18(key));
|
||||
kuTen2UNI2K.add(FCDotCDC1604DashP6.NY09_EQUALS.cakePointDotIndex());
|
||||
kuTen2UNI2K.addAll(FourCornerUnicodeMapper.DICTIONARY.embedUNI2K(valueUnicode));
|
||||
kuTen2UNI2K.addAll(FCDotCMD5401Dash2D.CMD_F4TTY0001_NL.cakePointSequence());
|
||||
}
|
||||
for (String key : dict.mapKuTen213.keySet()) {
|
||||
KanjiDictLiteral lit = dict.mapKuTen213.get(key);
|
||||
String valueUnicode = new StringBuilder().appendCodePoint(lit.getCodePoint()).toString();
|
||||
kuTen2UNI2K.addAll(FourCornerUnicodeImport.strict().convertToInt18(key));
|
||||
kuTen2UNI2K.add(FCDotCDC1604DashP6.NY09_EQUALS.cakePointDotIndex());
|
||||
kuTen2UNI2K.addAll(FourCornerUnicodeMapper.DICTIONARY.embedUNI2K(valueUnicode));
|
||||
kuTen2UNI2K.addAll(FCDotCMD5401Dash2D.CMD_F4TTY0001_NL.cakePointSequence());
|
||||
}
|
||||
// size 316575 (baklave TTY)
|
||||
// size 271350 (cake/muffin TTY)
|
||||
|
||||
PrimordialOctalOrangeString mappingFileStr;
|
||||
File outputFile = new File("target/Q10_UNI2K.FC18");
|
||||
try (OutputStream output = new FileOutputStream(outputFile)) {
|
||||
mappingFileStr = PrimordialOctalOrangeString.ioSmurfRead18List(kuTen2UNI2K);
|
||||
PrimordialOctalOrangeString.ioSmurfWrite8Stream(output, mappingFileStr);
|
||||
}
|
||||
|
||||
List<Integer> test = new ArrayList<>();
|
||||
PrimordialOctalOrangeString result = null;
|
||||
try (InputStream input = new FileInputStream(outputFile)) {
|
||||
result = PrimordialOctalOrangeString.ioSmurfRead8Stream(input);
|
||||
PrimordialOctalOrangeString.ioSmurfWrite18List(test, result);
|
||||
}
|
||||
|
||||
String testStr = FourCornerUnicodeDisplay.text().renderFromInt18(test);
|
||||
System.out.println(testStr);
|
||||
System.out.println("kuTen2UNI2K.wr: " + kuTen2UNI2K.size());
|
||||
System.out.println("kuTen2UNI2K.rd: " + test.size());
|
||||
|
||||
int meanEmpty = 0;
|
||||
int meanFail = 0;
|
||||
int meanUse2 = 0;
|
||||
int meanUse1 = 0;
|
||||
Map<String, KanjiDictLiteral> uniqMean = new HashMap<>();
|
||||
for (Integer key : dict.mapFourCorner.keySet()) {
|
||||
KanjiDictLiteral lit = dict.mapFourCorner.get(key);
|
||||
if (lit.getMeaningDefault().isEmpty()) {
|
||||
meanEmpty++;
|
||||
continue;
|
||||
}
|
||||
String meanLast = lit.getMeaningDefault().get(lit.getMeaningDefault().size() - 1);
|
||||
if (!uniqMean.containsKey(meanLast)) {
|
||||
uniqMean.put(meanLast, lit);
|
||||
continue;
|
||||
}
|
||||
if (lit.getMeaningDefault().size() > 1) {
|
||||
String meanSecond = lit.getMeaningDefault().get(1);
|
||||
if (!uniqMean.containsKey(meanSecond)) {
|
||||
uniqMean.put(meanSecond, lit);
|
||||
meanUse2++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
String meanFirst = lit.getMeaningDefault().get(0);
|
||||
if (!uniqMean.containsKey(meanFirst)) {
|
||||
uniqMean.put(meanFirst, lit);
|
||||
meanUse1++;
|
||||
continue;
|
||||
}
|
||||
meanFail++;
|
||||
}
|
||||
// for (String litMean : uniqMean.keySet()) {
|
||||
// KanjiDictLiteral lit = uniqMean.get(litMean);
|
||||
// System.out.print(new StringBuilder().appendCodePoint(lit.codePoint).toString());
|
||||
// System.out.println(" = " + litMean);
|
||||
// }
|
||||
|
||||
// JIS X 0208 prescribes a set of 6879 graphical characters
|
||||
// JIS X 0213 + 0208 have total characters 11233
|
||||
// Japanese engineers have defined
|
||||
System.out.println("=======================================");
|
||||
System.out.println("mapFourCorner: " + dict.mapFourCorner.size());
|
||||
System.out.println("mapKuTen208: " + dict.mapKuTen208.size());
|
||||
System.out.println("mapKuTen213: " + dict.mapKuTen213.size());
|
||||
System.out.println("=======================================");
|
||||
System.out.println("meanUniq: " + uniqMean.size());
|
||||
System.out.println("meanEmpty: " + meanEmpty);
|
||||
System.out.println("meanFail: " + meanFail);
|
||||
System.out.println("meanUse2: " + meanUse2);
|
||||
System.out.println("meanUse1: " + meanUse1);
|
||||
// 15642334 bytes or 538402 lines gives;
|
||||
// =======================================
|
||||
// mapFourCorner: 3936
|
||||
// mapKuTen208: 6355
|
||||
// mapKuTen213: 3695
|
||||
// =======================================
|
||||
// meanUniq: 3440
|
||||
// meanEmpty: 0
|
||||
// meanFail: 496
|
||||
// meanUse2: 233
|
||||
// meanUse1: 300
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue