FC18: Removed some unneeded List wrapping in building text output
This commit is contained in:
parent
d0e68f4d7b
commit
e2f54ec3ea
2 changed files with 62 additions and 37 deletions
|
|
@ -31,7 +31,6 @@ import java.util.PrimitiveIterator;
|
|||
import org.x4o.fc18.cake2.FourCornerDotCake;
|
||||
import org.x4o.fc18.cake2.FourCornerX00PetitVide;
|
||||
import org.x4o.fc18.cake2.FourCornerX06BaklavaPointSequence;
|
||||
import org.x4o.fc18.cake2.FourCornerX18CakePointDotIndex;
|
||||
import org.x4o.fc18.cake2.FourCornerX18CakePointSequence;
|
||||
import org.x4o.fc18.cake2.pie9c.FCDotPIE9CDash10;
|
||||
import org.x4o.fc18.cake2.pie9c.FCDotPIE9CDash11;
|
||||
|
|
@ -45,6 +44,9 @@ import org.x4o.fc18.cake2.zero33.dec1.FCDotDEC2701DashPX0;
|
|||
/// @version 1.0 Jan 09, 2025
|
||||
final public class FourCornerRecipe {
|
||||
|
||||
static final private BigInteger NCR1632_MASK_PAGE = BigInteger.valueOf(0x1FF);
|
||||
static final private BigInteger NCR1632_VALUE_MAX = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16);
|
||||
|
||||
private FourCornerRecipe() {
|
||||
}
|
||||
|
||||
|
|
@ -125,18 +127,15 @@ final public class FourCornerRecipe {
|
|||
return embedNCR1632Value(new ArrayList<>(), value, FourCornerDotCake.FC_NCR1632_XN.getStart());
|
||||
}
|
||||
|
||||
static public void embedNCR1632Denominator(List<Integer> result, BigInteger value) {
|
||||
embedNCR1632Value(result, value, FourCornerDotCake.FC_NCR1632_XD.getStart());
|
||||
static public void embedNCR1632Denominator(List<Integer> out, BigInteger value) {
|
||||
embedNCR1632Value(out, value, FourCornerDotCake.FC_NCR1632_XD.getStart());
|
||||
}
|
||||
|
||||
static public void embedNCR1632Numerator(List<Integer> result, BigInteger value) {
|
||||
embedNCR1632Value(result, value, FourCornerDotCake.FC_NCR1632_XN.getStart());
|
||||
static public void embedNCR1632Numerator(List<Integer> out, BigInteger value) {
|
||||
embedNCR1632Value(out, value, FourCornerDotCake.FC_NCR1632_XN.getStart());
|
||||
}
|
||||
|
||||
static final private BigInteger NCR1632_MASK_PAGE = BigInteger.valueOf(0x1FF);
|
||||
static final private BigInteger NCR1632_VALUE_MAX = new BigInteger("FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF"+"FFFFFFFFFFFFFFFFFF", 16);
|
||||
|
||||
static private List<Integer> embedNCR1632Value(List<Integer> result, BigInteger value, int bankStart) {
|
||||
static private List<Integer> embedNCR1632Value(List<Integer> out, BigInteger value, int bankStart) {
|
||||
if (value.equals(BigInteger.ZERO)) {
|
||||
throw new IllegalArgumentException("The value ZERO is not allowed.");
|
||||
}
|
||||
|
|
@ -148,8 +147,8 @@ final public class FourCornerRecipe {
|
|||
}
|
||||
BigInteger valueZero = value.subtract(BigInteger.ONE);
|
||||
if (valueZero.equals(BigInteger.ZERO)) {
|
||||
result.add(bankStart);
|
||||
return result;
|
||||
out.add(bankStart);
|
||||
return out;
|
||||
}
|
||||
for (int i = 63; i >= 0; i--) {
|
||||
int bankValue = valueZero.shiftRight(i * 9).and(NCR1632_MASK_PAGE).intValue();
|
||||
|
|
@ -157,68 +156,94 @@ final public class FourCornerRecipe {
|
|||
continue;
|
||||
}
|
||||
int cakePoint = bankStart + bankValue + (i * 512);
|
||||
result.add(cakePoint);
|
||||
out.add(cakePoint);
|
||||
}
|
||||
return result;
|
||||
return out;
|
||||
}
|
||||
|
||||
static public List<FourCornerX18CakePointDotIndex> toScriptSuper(int value) {
|
||||
return toScript(Integer.toString(value), 0);
|
||||
static public List<Integer> toScriptSuper(int value) {
|
||||
return toScript(new ArrayList<>(), Integer.toString(value), 0);
|
||||
}
|
||||
|
||||
static public List<FourCornerX18CakePointDotIndex> toScriptSub(int value) {
|
||||
return toScript(Integer.toString(value), 10);
|
||||
static public List<Integer> toScriptSub(int value) {
|
||||
return toScript(new ArrayList<>(), Integer.toString(value), 10);
|
||||
}
|
||||
|
||||
static public List<FourCornerX18CakePointDotIndex> toScriptSuper(BigInteger value) {
|
||||
return toScript(value.toString(10), 0);
|
||||
static public List<Integer> toScriptSuper(BigInteger value) {
|
||||
return toScript(new ArrayList<>(), value.toString(10), 0);
|
||||
}
|
||||
|
||||
static public List<FourCornerX18CakePointDotIndex> toScriptSub(BigInteger value) {
|
||||
return toScript(value.toString(10), 10);
|
||||
static public List<Integer> toScriptSub(BigInteger value) {
|
||||
return toScript(new ArrayList<>(), value.toString(10), 10);
|
||||
}
|
||||
|
||||
static private List<FourCornerX18CakePointDotIndex> toScript(String value, int off) {
|
||||
List<FourCornerX18CakePointDotIndex> result = new ArrayList<>();
|
||||
static public void toScriptSuper(List<Integer> out, int value) {
|
||||
toScript(out, Integer.toString(value), 0);
|
||||
}
|
||||
|
||||
static public void toScriptSub(List<Integer> out, int value) {
|
||||
toScript(out, Integer.toString(value), 10);
|
||||
}
|
||||
|
||||
static public void toScriptSuper(List<Integer> out, BigInteger value) {
|
||||
toScript(out, value.toString(10), 0);
|
||||
}
|
||||
|
||||
static public void toScriptSub(List<Integer> out, BigInteger value) {
|
||||
toScript(out, value.toString(10), 10);
|
||||
}
|
||||
|
||||
static private List<Integer> toScript(List<Integer> out, String value, int off) {
|
||||
PrimitiveIterator.OfInt i = value.codePoints().iterator();
|
||||
while (i.hasNext()) {
|
||||
int chr = i.nextInt();
|
||||
if (chr == '-') {
|
||||
if (off == 0) {
|
||||
result.add(FCDotPIE9CDash11.NXX_03);
|
||||
out.add(FCDotPIE9CDash11.NXX_03.cakePointDotIndex());
|
||||
} else {
|
||||
result.add(FCDotPIE9CDash11.NXX_08);
|
||||
out.add(FCDotPIE9CDash11.NXX_08.cakePointDotIndex());
|
||||
}
|
||||
continue;
|
||||
}
|
||||
int num = chr - '0';
|
||||
result.add(FCDotPIE9CDash20.valueOf(num + off));
|
||||
out.add(FCDotPIE9CDash20.valueOf(num + off).cakePointDotIndex());
|
||||
}
|
||||
return result;
|
||||
return out;
|
||||
}
|
||||
|
||||
// todo: remove X06 output here ??
|
||||
|
||||
static public List<FourCornerX06BaklavaPointSequence> toDecimalsX06(int value) {
|
||||
return toDecimalsX00(value);
|
||||
return toDecimalsX00(new ArrayList<>(), value);
|
||||
}
|
||||
|
||||
static public List<FourCornerX18CakePointSequence> toDecimalsX18(int value) {
|
||||
return toDecimalsX00(value);
|
||||
return toDecimalsX00(new ArrayList<>(), value);
|
||||
}
|
||||
|
||||
static public void toDecimalsX06(List<FourCornerX06BaklavaPointSequence> out, int value) {
|
||||
toDecimalsX00(out, value);
|
||||
}
|
||||
|
||||
static public void toDecimalsX18(List<FourCornerX06BaklavaPointSequence> out, int value) {
|
||||
toDecimalsX00(out, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
static private <T extends FourCornerX00PetitVide> List<T> toDecimalsX00(int value) {
|
||||
List<T> result = new ArrayList<>();
|
||||
static private <T extends FourCornerX00PetitVide> List<T> toDecimalsX00(List<T> out, int value) {
|
||||
String valueStr = Integer.toString(value);
|
||||
PrimitiveIterator.OfInt i = valueStr.codePoints().iterator();
|
||||
boolean first = true;
|
||||
while (i.hasNext()) {
|
||||
int chr = i.nextInt();
|
||||
int num = chr - '0';
|
||||
if (result.isEmpty()) {
|
||||
result.add((T) FCDotPIE9CDash10.valueOf(num)); // Add escaping only once
|
||||
if (first) {
|
||||
first = false; // Add escaping only once
|
||||
out.add((T) FCDotPIE9CDash10.valueOf(num));
|
||||
} else {
|
||||
result.add((T) FCDotCDC1604DashP6.valueOf(FCDotCDC1604DashP6.NX01_A.ordinal() + num));
|
||||
out.add((T) FCDotCDC1604DashP6.valueOf(FCDotCDC1604DashP6.NX01_A.ordinal() + num));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,9 +226,9 @@ public class FourCornerUnicodeDisplay {
|
|||
@Override
|
||||
public void strobeNCR1632(BigInteger denominator, BigInteger numerator) {
|
||||
List<Integer> math = new ArrayList<>();
|
||||
FourCornerRecipe.toScriptSuper(numerator).forEach(v -> math.add(v.cakePointDotIndex()));
|
||||
FourCornerRecipe.toScriptSuper(math, numerator);
|
||||
math.add(FCDotCDC1604DashP6.NY02_BAR_V_RIGHT.ordinal());
|
||||
FourCornerRecipe.toScriptSub(denominator).forEach(v -> math.add(v.cakePointDotIndex()));
|
||||
FourCornerRecipe.toScriptSub(math, denominator);
|
||||
renderFromInt18(math, output);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue