FCDoc split 6 bit NCR1632 baklava to separate page

This commit is contained in:
Willem Cazander 2025-01-18 00:39:23 +01:00
parent e8811b39df
commit 30ab39395d
5 changed files with 213 additions and 110 deletions

View file

@ -0,0 +1,92 @@
/*
* 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 org.x4o.fc18.cake2.fcdoc;
import java.io.IOException;
import org.x4o.o2o.io.ContentWriterHtml.Tag;
import org.x4o.o2o.io.sax3.ContentCloseable;
import org.x4o.o2o.tdoc.ApiDocContentCss;
import org.x4o.o2o.tdoc.ApiDocContentWriter;
import org.x4o.o2o.tdoc.dom.ApiDocPageWriter;
import org.xml.sax.helpers.AttributesImpl;
/**
* Cake doc generic page writer.
*
* @author Willem Cazander
* @version 1.0 Jan 18, 2025
*/
public interface FCDocPageWriter extends ApiDocPageWriter {
default void writeTableBoxHeader(ApiDocContentWriter 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", "", "", ApiDocContentCss.colFirst.name());
} else if (i == 1) {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colOne.name());
} else {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name());
}
atts.addAttribute ("", "scope", "", "", "col");
try (ContentCloseable th = writer.printTag(Tag.th, atts)) {
writer.printCharacters(headers[i]);
}
}
}
}
default void writeTableBoxHeaderNumeric(ApiDocContentWriter writer, int num) throws IOException {
writeTableBoxHeaderNumeric(writer, num, false);
}
default void writeTableBoxHeaderNumeric(ApiDocContentWriter writer, int num, boolean colFirst) throws IOException {
writer.printTagStart(Tag.tr);
AttributesImpl atts;
if (colFirst) {
atts = new AttributesImpl();
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colFirst.name());
atts.addAttribute ("", "scope", "", "", "col");
writer.printTagStart(Tag.th, atts);
writer.printTagEnd(Tag.th);
}
atts = new AttributesImpl();
atts.addAttribute ("", "class", "", "", ApiDocContentCss.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", "", "", ApiDocContentCss.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);
}
}

View file

@ -0,0 +1,111 @@
/*
* 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 org.x4o.fc18.cake2.fcdoc;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
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.fc18.cake2.zero33.FCDotCDC1604DashP6;
import org.x4o.fc18.cake2.zero33.FCDotDEC0127DashPX0;
import org.x4o.o2o.io.ContentWriterHtml.Tag;
import org.x4o.o2o.io.sax3.ContentCloseable;
import org.x4o.o2o.tdoc.ApiDocContentCss;
import org.x4o.o2o.tdoc.ApiDocContentWriter;
import org.x4o.o2o.tdoc.dom.ApiDocPage;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
/**
* Cake doc muffin page writer.
*
* @author Willem Cazander
* @version 1.0 Jan 17, 2025
*/
public class FCDocPageWriterBaklava implements FCDocPageWriter {
public static ApiDocPage createDocPage() {
return new ApiDocPage("overview-baklave","Baklava","Overview of all 6 bit baklava NCR1632 fractions.",new FCDocPageWriterBaklava());
}
// TODO: make all symbols href links
@Override
public void writePageContent(ApiDocWriteEvent<ApiDocPage> e) throws IOException {
ApiDocContentWriter writer = e.getWriter();
try (ContentCloseable content = writer.docPageContent()) {
try (ContentCloseable table = writer.docTable(FourCornerDotCake.FC_NCR1632_XD.nameSpec().replaceAll("XD", "baklava"), null, ApiDocContentCss.overviewSummary)) {
writeTableBoxHeaderNumeric(writer, 28);
writePIN(writer);
}
}
}
private void writePIN(ApiDocContentWriter 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, ApiDocContentCss.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, ApiDocContentCss.colLast);
}
if (i > t) {
writer.printTagEnd(Tag.td);
continue;
}
List<Integer> piNum = new ArrayList<>();
//piNum.add(FCDotCDC1604DashP6.__NCR68.ordinal());\
for (int letter : FCDotDEC0127DashPX0.ESC68_NCR.baklavaPoints()) {
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);
}
}
}
}
}

View file

@ -30,9 +30,7 @@ import org.x4o.o2o.io.sax3.ContentCloseable;
import org.x4o.o2o.tdoc.ApiDocContentCss;
import org.x4o.o2o.tdoc.ApiDocContentWriter;
import org.x4o.o2o.tdoc.dom.ApiDocPage;
import org.x4o.o2o.tdoc.dom.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.helpers.AttributesImpl;
/**
* Cake doc stack page writer.
@ -40,7 +38,7 @@ import org.xml.sax.helpers.AttributesImpl;
* @author Willem Cazander
* @version 1.0 Jan 17, 2025
*/
public class FCDocPageWriterCakeTower implements ApiDocPageWriter {
public class FCDocPageWriterCakeTower implements FCDocPageWriter {
public static ApiDocPage createDocPage() {
return new ApiDocPage("overview-tower","Tower","Overview of the cake tower.",new FCDocPageWriterCakeTower());
@ -87,24 +85,4 @@ public class FCDocPageWriterCakeTower implements ApiDocPageWriter {
}
}
}
private void writeTableBoxHeader(ApiDocContentWriter 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", "", "", ApiDocContentCss.colFirst.name());
} else if (i == 1) {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colOne.name());
} else {
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colLast.name());
}
atts.addAttribute ("", "scope", "", "", "col");
try (ContentCloseable th = writer.printTag(Tag.th, atts)) {
writer.printCharacters(headers[i]);
}
}
}
}
}

View file

@ -42,9 +42,7 @@ import org.x4o.o2o.io.sax3.ContentCloseable;
import org.x4o.o2o.tdoc.ApiDocContentCss;
import org.x4o.o2o.tdoc.ApiDocContentWriter;
import org.x4o.o2o.tdoc.dom.ApiDocPage;
import org.x4o.o2o.tdoc.dom.ApiDocPageWriter;
import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent;
import org.xml.sax.helpers.AttributesImpl;
/**
* Cake doc muffin page writer.
@ -52,7 +50,7 @@ import org.xml.sax.helpers.AttributesImpl;
* @author Willem Cazander
* @version 1.0 Jan 17, 2025
*/
public class FCDocPageWriterMuffin implements ApiDocPageWriter {
public class FCDocPageWriterMuffin implements FCDocPageWriter {
public static ApiDocPage createDocPage() {
return new ApiDocPage("overview-muffin","Muffins","Overview of all muffin symbols.",new FCDocPageWriterMuffin());
@ -65,7 +63,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
ApiDocContentWriter writer = e.getWriter();
try (ContentCloseable content = writer.docPageContent()) {
try (ContentCloseable table = writer.docTable(FourCornerDotCake.FC_CDC1604_P6.nameSpec(), null, ApiDocContentCss.overviewSummary)) {
writeTableBoxHeader(writer, 17);
writeTableBoxHeaderNumeric(writer, 17);
writeCDC(writer, 0x00);
writeCDC(writer, 0x10);
writeCDC(writer, 0x20);
@ -75,7 +73,7 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
try (ContentCloseable content = writer.docPageContent()) {
String xSpec = FourCornerDotCake.FC_APL0127_P7A.nameSpec().replaceAll("P7A", "P7x");
try (ContentCloseable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) {
writeTableBoxHeader(writer, 28, true);
writeTableBoxHeaderNumeric(writer, 28, true);
writeP7x(writer, FourCornerDotCake.FC_APL0127_P7A, v -> FCDotAPL0127DashP7A.valueOf(v).codePoints()[0]);
writeP7x(writer, FourCornerDotCake.FC_APL0127_P7B, v -> FCDotAPL0127DashP7B.valueOf(v).codePoints()[0]);
writeP7x(writer, FourCornerDotCake.FC_APL0127_P7C, v -> FCDotAPL0127DashP7C.valueOf(v).codePoints()[0]);
@ -84,16 +82,16 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
try (ContentCloseable content = writer.docPageContent()) {
String xSpec = FourCornerDotCake.FC_BYD0127_P7D.nameSpec().replaceAll("P7D", "P7x");
try (ContentCloseable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) {
writeTableBoxHeader(writer, 28, true);
writeTableBoxHeaderNumeric(writer, 28, true);
writeP7x(writer, FourCornerDotCake.FC_BYD0127_P7D, v -> FCDotBYD0127DashP7D.valueOf(v).codePoints()[0]);
writeP7x(writer, FourCornerDotCake.FC_BYD0127_P7E, v -> FCDotBYD0127DashP7E.valueOf(v).codePoints()[0]);
writeP7x(writer, FourCornerDotCake.FC_BYD0127_P7F, v -> FCDotBYD0127DashP7F.valueOf(v).codePoints()[0]);
}
}
try (ContentCloseable content = writer.docPageContent()) {
String xSpec = FourCornerDotCake.FC_PIE9C_01.nameSpec().replaceAll("01", "baklava");
String xSpec = FourCornerDotCake.FC_PIE9C_01.nameSpec().replaceAll("01", "Cake");
try (ContentCloseable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) {
writeTableBoxHeader(writer, 28, true);
writeTableBoxHeaderNumeric(writer, 28, true);
writePIE(writer, FourCornerDotCake.FC_PIE9C_01);
writePIE(writer, FourCornerDotCake.FC_PIE9C_02);
writePIE(writer, FourCornerDotCake.FC_PIE9C_03);
@ -124,9 +122,9 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
}
}
try (ContentCloseable content = writer.docPageContent()) {
String xSpec = FourCornerDotCake.FC_PIE9D_01.nameSpec().replaceAll("01", "baklava");
String xSpec = FourCornerDotCake.FC_PIE9D_01.nameSpec().replaceAll("01", "Cake");
try (ContentCloseable table = writer.docTable(xSpec, null, ApiDocContentCss.overviewSummary)) {
writeTableBoxHeader(writer, 28, true);
writeTableBoxHeaderNumeric(writer, 28, true);
writePIE(writer, FourCornerDotCake.FC_PIE9D_01);
writePIE(writer, FourCornerDotCake.FC_PIE9D_02);
writePIE(writer, FourCornerDotCake.FC_PIE9D_03);
@ -156,52 +154,6 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
writePIE(writer, FourCornerDotCake.FC_PIE9D_27);
}
}
try (ContentCloseable content = writer.docPageContent()) {
try (ContentCloseable table = writer.docTable(FourCornerDotCake.FC_NCR1632_XD.nameSpec().replaceAll("XD", "baklava"), null, ApiDocContentCss.overviewSummary)) {
writeTableBoxHeader(writer, 28);
writePIN(writer);
}
}
}
private void writePIN(ApiDocContentWriter 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, ApiDocContentCss.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, ApiDocContentCss.colLast);
}
if (i > t) {
writer.printTagEnd(Tag.td);
continue;
}
List<Integer> piNum = new ArrayList<>();
//piNum.add(FCDotCDC1604DashP6.__NCR68.ordinal());\
for (int letter : FCDotDEC0127DashPX0.ESC68_NCR.baklavaPoints()) {
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);
}
}
}
}
private void writePIE(ApiDocContentWriter writer, FourCornerDotCake slice) throws IOException {
@ -302,35 +254,4 @@ public class FCDocPageWriterMuffin implements ApiDocPageWriter {
}
}
}
private void writeTableBoxHeader(ApiDocContentWriter writer, int num) throws IOException {
writeTableBoxHeader(writer, num, false);
}
private void writeTableBoxHeader(ApiDocContentWriter writer, int num, boolean colFirst) throws IOException {
writer.printTagStart(Tag.tr);
AttributesImpl atts;
if (colFirst) {
atts = new AttributesImpl();
atts.addAttribute ("", "class", "", "", ApiDocContentCss.colFirst.name());
atts.addAttribute ("", "scope", "", "", "col");
writer.printTagStart(Tag.th, atts);
writer.printTagEnd(Tag.th);
}
atts = new AttributesImpl();
atts.addAttribute ("", "class", "", "", ApiDocContentCss.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", "", "", ApiDocContentCss.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);
}
}

View file

@ -142,6 +142,7 @@ public class FCDocWriter {
//adc4.addChildConcepts(new ApiDocConcept(adc4, CC_RS, Relationship.class));
doc.addDocPage(FCDocPageWriterMuffin.createDocPage());
doc.addDocPage(FCDocPageWriterBaklava.createDocPage());
doc.addDocPage(FCDocPageWriterCakeTower.createDocPage());
doc.addDocPage(DefaultPageWriterTree.createDocPage());
//doc.addDocPage(DefaultPageWriterIndexAll.createDocPage());