From 158bb0c6f4d97d6b5a263c98df43d0f4aed50468 Mon Sep 17 00:00:00 2001 From: Willem Date: Mon, 20 Jan 2025 15:59:10 +0100 Subject: [PATCH] Added full cake dot name support to reuse the internal enum naming --- .../x4o/fc18/FourCornerUnicodeDisplay.java | 10 +-- .../x4o/fc18/cake2/FourCornerDotColleCLK.java | 10 +-- .../fc18/cake2/FourCornerX00PetitVide.java | 4 ++ .../cake2/FourCornerX18CakePointDotIndex.java | 2 +- ...ava => FourCornerX18CakePointDotName.java} | 15 +++-- .../fcdoc/FCDocSegmentWriterCakeSlice.java | 6 +- .../fcdoc/FCDocSegmentWriterCakeWord.java | 61 ++++++++++--------- .../x4o/fc18/cake2/fcdoc/TDocCakeWord.java | 4 ++ 8 files changed, 61 insertions(+), 51 deletions(-) rename nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/{FourCornerX18CakeWord.java => FourCornerX18CakePointDotName.java} (79%) diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java index 944fe53..490693a 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/FourCornerUnicodeDisplay.java @@ -33,7 +33,6 @@ import org.x4o.fc18.cake2.FourCornerX00PetitVide; import org.x4o.fc18.cake2.FourCornerX06BaklavaPointSequence; import org.x4o.fc18.cake2.FourCornerX08MuffinPointSequence; import org.x4o.fc18.cake2.FourCornerX18CakePointSequence; -import org.x4o.fc18.cake2.FourCornerX18CakeWord; import org.x4o.fc18.cake2.zero33.FCDotCDC1604DashP6; import org.x4o.fc18.zion7.FourCornerZion7Candlelier; import org.x4o.fc18.zion7.FourCornerZionStenoLexer; @@ -172,14 +171,15 @@ public class FourCornerUnicodeDisplay { output.append(value); } else { FourCornerX00PetitVide videPoint = videPoints[offset]; - if (videPoint instanceof FourCornerX18CakeWord) { - FourCornerX18CakeWord cakeWord = FourCornerX18CakeWord.class.cast(videPoint); - FourCornerX18CakePointSequence[] wordDefault = cakeWord.nameDefault(); - for (FourCornerX18CakePointSequence letter : wordDefault) { + if (videPoint.kaasX18CakeDotName().isPresent()) { + List nameX18 = videPoint.kaasX18CakeDotName().get().nameX18(); + for (FourCornerX18CakePointSequence letter : nameX18) { letter.kaasX21CodeSequence().ifPresent(v -> { v.codePointSequence().forEach(vv -> output.appendCodePoint(vv)); }); } + // should be equal to + //output.append(videPoint.kaasX18CakeDotName().get().name()); } } if (renderSeperator != null && wasExternalWord) { diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerDotColleCLK.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerDotColleCLK.java index 6d3308b..741c316 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerDotColleCLK.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerDotColleCLK.java @@ -25,8 +25,6 @@ package org.x4o.fc18.cake2; import java.util.List; import java.util.Optional; -import org.x4o.fc18.FourCornerUnicodeImport; - /** * Glue for clock speech token support. * @@ -34,9 +32,7 @@ import org.x4o.fc18.FourCornerUnicodeImport; * @author Willem Cazander * @version 1.0 Dec 30, 2024 */ -public interface FourCornerDotColleCLK extends FourCornerX18CakeWord { - - String name(); +public interface FourCornerDotColleCLK extends FourCornerX18CakePointDotIndex { FourCornerDotColleCLKParler[] clockParlers(); @@ -49,10 +45,6 @@ public interface FourCornerDotColleCLK extends FourCornerX18CakeWord { return Optional.empty(); } - default FourCornerX18CakePointSequence[] nameDefault() { - return FourCornerUnicodeImport.strict().convertToX18(name()).toArray(new FourCornerX18CakePointSequence[] {}); - } - @Override default List cakePointSequence() { return List.of(cakePointDotIndex()); diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX00PetitVide.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX00PetitVide.java index fe7276e..8eb1b50 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX00PetitVide.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX00PetitVide.java @@ -46,6 +46,10 @@ public interface FourCornerX00PetitVide { return this instanceof FourCornerX18CakePointDotIndex?Optional.of(FourCornerX18CakePointDotIndex.class.cast(this)):Optional.empty(); } + default Optional kaasX18CakeDotName() { + return this instanceof FourCornerX18CakePointDotName?Optional.of(FourCornerX18CakePointDotName.class.cast(this)):Optional.empty(); + } + default Optional kaasX18CakeSequence() { return this instanceof FourCornerX18CakePointSequence?Optional.of(FourCornerX18CakePointSequence.class.cast(this)):Optional.empty(); } diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX18CakePointDotIndex.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX18CakePointDotIndex.java index 8887322..ae986f6 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX18CakePointDotIndex.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX18CakePointDotIndex.java @@ -26,7 +26,7 @@ package org.x4o.fc18.cake2; /// /// @author Willem Cazander /// @version 1.0 Jan 19, 2025 -public interface FourCornerX18CakePointDotIndex extends FourCornerX18CakePointSequence { +public interface FourCornerX18CakePointDotIndex extends FourCornerX18CakePointSequence, FourCornerX18CakePointDotName { /// One cake piece weights 800 gram int cakePointDotIndex(); diff --git a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX18CakeWord.java b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX18CakePointDotName.java similarity index 79% rename from nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX18CakeWord.java rename to nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX18CakePointDotName.java index 63df29c..3d24c49 100644 --- a/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX18CakeWord.java +++ b/nx01-x4o-fc18/src/main/java/org/x4o/fc18/cake2/FourCornerX18CakePointDotName.java @@ -22,12 +22,19 @@ */ package org.x4o.fc18.cake2; -/// Fall back word provider. +import java.util.List; + +import org.x4o.fc18.FourCornerUnicodeImport; + +/// Access to the internal dot cake point glyph name. /// /// @author Willem Cazander /// @version 1.0 Jan 11, 2025 -public interface FourCornerX18CakeWord extends FourCornerX18CakePointDotIndex { +public interface FourCornerX18CakePointDotName extends FourCornerX00PetitVide { - /// Default word provider - FourCornerX18CakePointSequence[] nameDefault(); + String name(); // copy name from internal enum value + + default List nameX18() { + return FourCornerUnicodeImport.strict().convertToX18(name()); + } } diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeSlice.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeSlice.java index 408f4b8..2cf6430 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeSlice.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeSlice.java @@ -50,7 +50,8 @@ import org.x4o.o2o.tdoc.dom.ApiDocWriteEvent; */ public class FCDocSegmentWriterCakeSlice implements FCDocSegmentWriter { - @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL, targetClasses={TDocCakeSlice.class}, nodeBodyOrders=20) +// NOTE: Table are not allowed in details +// @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL, targetClasses={TDocCakeSlice.class}, nodeBodyOrders=20) public void writeDefaultSummary(ApiDocWriteEvent event) throws IOException { // NOTE: copyed from defaultWriteSummary as that only called with zero summaries + changes name end in; Words ApiDocContentWriter writer = event.getWriter(); @@ -72,7 +73,7 @@ public class FCDocSegmentWriterCakeSlice implements FCDocSegmentWriter { } writer.docTableEnd(); } - + @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY, targetClasses={TDocCakeSlice.class}, nodeBodyOrders=1) public void writeCakeSliceDetails(ApiDocWriteEvent event) throws IOException { ApiDocContentWriter writer = event.getWriter(); @@ -84,6 +85,7 @@ public class FCDocSegmentWriterCakeSlice implements FCDocSegmentWriter { writer.docTableRow("Size", Integer.toString(slice.getLength())); writer.docTableRow("External word", Boolean.toString(slice.isExternWord())); } + writeDefaultSummary(event); // } // // @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.SUMMARY, targetClasses={FourCornerDotCake.class}, nodeBodyOrders=10) diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeWord.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeWord.java index 5da99f3..136857d 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeWord.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/FCDocSegmentWriterCakeWord.java @@ -29,6 +29,7 @@ import java.util.Optional; 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.fc18.cake2.FourCornerX00PetitVide; @@ -54,26 +55,43 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter { TDocCakeWord word = event.getEventObject().toUserData(TDocCakeWord.class); FourCornerX00PetitVide[] videPoints = word.getSlice().getVidePoints(); if (videPoints.length == 0) { + writer.printTagStart(Tag.pre); + writer.printCharacters("None PetitVide for: " + word.toString()); + writer.printTagEnd(Tag.pre); return; } - writer.docTableStart("Points Summary", "Encode point for all systems.",ApiDocContentCss.overviewSummary); - writer.docTableHeader("System", "Point Sequence"); FourCornerX00PetitVide videPoint = videPoints[word.getOffset()]; Optional x21CodeDisplay = videPoint.kaasX21CodeSequence(); Optional x06BaklavaSequence = videPoint.kaasX06BaklavaSequence(); Optional x08MuffinSequence = videPoint.kaasX08MuffinSequence(); Optional x18CakeSequence = videPoint.kaasX18CakeSequence(); - if (x06BaklavaSequence.isPresent()) { - writeSequence(writer, "X06", 2, x06BaklavaSequence.get().baklavaPointSequence()); - } - if (x08MuffinSequence.isPresent()) { - writeSequence(writer, "X08", 2, x08MuffinSequence.get().muffinPointSequence()); - } - if (x18CakeSequence.isPresent()) { - writeSequence(writer, "X18", 6, x18CakeSequence.get().cakePointSequence()); + Optional x18DotName = videPoint.kaasX18CakeDotName(); + + writer.docTableStart("Glyph Summary", "The cake point as unicode glyph.",ApiDocContentCss.overviewSummary); + writer.docTableHeader("Glyph", "Value"); + String name = word.toString(); + String value = name; + if (x18DotName.isPresent()) { + name = x18DotName.get().name(); } if (x21CodeDisplay.isPresent()) { - writeSequence(writer, "X21", 6, x21CodeDisplay.get().codePointSequence()); + 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()); } writer.docTableEnd(); // } @@ -90,7 +108,7 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter { // FourCornerX00PetitVide videPoint = videPoints[word.getOffset()]; Optional x00CoinCarne = videPoint.kaasX00CoinCarne(); writer.docTableStart("Kerning Summary", "Kerning all pattern displays.",ApiDocContentCss.overviewSummary); - writer.docTableHeader("Location", "Corner indents"); + writer.docTableHeader("Location", "Corner dents"); if (x00CoinCarne.isPresent()) { FourCornerX00PetitVideCoinCarne cornerKerning = x00CoinCarne.get(); writer.docTableRow("Top", cornerKerning.coinCarneFrapper().kerningTop().name()); @@ -99,6 +117,7 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter { writer.docTableEnd(); } + private void writeSequence(ApiDocContentWriter writer, String system, int minHex, List sequence) throws IOException { String displayFormat = "0x%0" + minHex + "X"; StringBuilder buf = new StringBuilder(); @@ -112,22 +131,4 @@ public class FCDocSegmentWriterCakeWord implements FCDocSegmentWriter { } writer.docTableRow(system, buf.toString()); } - - @ApiDocNodeWriterMethod(nodeBody=ApiDocNodeBody.DETAIL,targetClasses={TDocCakeWord.class}) - public void writeCakeWordDetail(ApiDocWriteEvent 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 letter = videPoints[word.getOffset()]; - StringBuilder buf = new StringBuilder(); - letter.kaasX21CodeSequence().ifPresent(v -> { - v.codePointSequence().forEach(vv -> buf.appendCodePoint(vv)); - }); - writer.printTagStart(Tag.pre); - writer.printCharacters(buf.toString()); - writer.printTagEnd(Tag.pre); - } } diff --git a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/TDocCakeWord.java b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/TDocCakeWord.java index fc48100..031b9a4 100644 --- a/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/TDocCakeWord.java +++ b/nx01-x4o-fc18/src/test/java/org/x4o/fc18/cake2/fcdoc/TDocCakeWord.java @@ -49,4 +49,8 @@ public class TDocCakeWord { public int getOffset() { return offset; } + + public String toString() { + return String.format("%s.0x%06X", slice.name(), slice.getStart() + offset); + } }