Added glocal china unit test and added T07PartPlanIt
This commit is contained in:
parent
daad0690fc
commit
9793e70937
|
@ -8,7 +8,9 @@ import imgui.ImGui;
|
|||
import imgui.ImGuiIO;
|
||||
import imgui.gl3.ImGuiImplGl3;
|
||||
import imgui.glfw.ImGuiImplGlfw;
|
||||
import love.distributedrebirth.numberxd.base2t.T60Sexagesimal;
|
||||
import love.distributedrebirth.numberxd.base2t.BasePartFactory;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePart;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1;
|
||||
|
||||
/**
|
||||
* Create and shutdown of ImGui and font activations.
|
||||
|
@ -22,7 +24,6 @@ public class ImGuiSetup {
|
|||
private static final short[] glyphRangesArabic = new short[]{0x0600, 0x06FF};
|
||||
private static final short[] glyphRangesSubSuper0 = new short[]{0x00B2, 0x00B9};
|
||||
private static final short[] glyphRangesSubSuper1 = new short[]{0x2070, 0x209F};
|
||||
private static final short[] glyphRangesToneLetters0 = new short[]{0x02E5, 0x02E9};
|
||||
|
||||
public static void init() {
|
||||
long windowHandle = -1;
|
||||
|
@ -53,13 +54,18 @@ public class ImGuiSetup {
|
|||
rangesBuilder.addRanges(glyphRangesArabic);
|
||||
rangesBuilder.addRanges(glyphRangesSubSuper0);
|
||||
rangesBuilder.addRanges(glyphRangesSubSuper1);
|
||||
rangesBuilder.addRanges(glyphRangesToneLetters0);
|
||||
rangesBuilder.addText("@Ω\u4ed9⁴ ˧꜏⋇꜊꜔ ⁴ﷲΩ@");
|
||||
rangesBuilder.addText("©Δ∞ \u4ed9\u4e0a\u4e3b\u5929");
|
||||
|
||||
for (T60Sexagesimal value:T60Sexagesimal.values()) {
|
||||
rangesBuilder.addText(value.getIdentifierLetter());
|
||||
rangesBuilder.addText(value.getChinaKey());
|
||||
for (int base:BasePartFactory.getSupportedBases()) {
|
||||
for (BasePart part:BasePartFactory.buildBasePartsByBase(base)) {
|
||||
rangesBuilder.addText(part.getIdentifierTone());
|
||||
rangesBuilder.addText(part.getIdentifierLetter());
|
||||
rangesBuilder.addText(part.getChinaKey());
|
||||
if (part instanceof BasePartAlt1) {
|
||||
rangesBuilder.addText(BasePartAlt1.class.cast(part).getAlt1Value());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final ImFontConfig fontConfig = new ImFontConfig();
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
package love.distributedrebirth.demo4d.screen;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import imgui.ImGui;
|
||||
import imgui.flag.ImGuiCond;
|
||||
import imgui.flag.ImGuiTableFlags;
|
||||
import imgui.type.ImBoolean;
|
||||
import imgui.type.ImInt;
|
||||
import love.distributedrebirth.demo4d.Demo4DMain;
|
||||
import love.distributedrebirth.demo4d.ImGuiRendererMain;
|
||||
import love.distributedrebirth.numberxd.base2t.T60Sexagesimal;
|
||||
import love.distributedrebirth.numberxd.base2t.BasePartFactory;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePart;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt2;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt3;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt4;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -19,6 +24,8 @@ import love.distributedrebirth.numberxd.base2t.facet.BasePart;
|
|||
*/
|
||||
public class BasePartRenderer extends ImGuiRendererMain {
|
||||
|
||||
private ImInt selectedBasePart = new ImInt();
|
||||
|
||||
public BasePartRenderer(Demo4DMain main) {
|
||||
super(main);
|
||||
}
|
||||
|
@ -29,21 +36,34 @@ public class BasePartRenderer extends ImGuiRendererMain {
|
|||
ImGui.setNextWindowSize(640, 480, ImGuiCond.FirstUseEver);
|
||||
ImGui.begin("Base part", widgetOpen);
|
||||
|
||||
ImGui.text("Current part type:");
|
||||
ImGui.text("Current Part");
|
||||
ImGui.sameLine();
|
||||
ImGui.text("T60Sexagesimal");
|
||||
|
||||
List<String> bases = new ArrayList<>();
|
||||
for (int base:BasePartFactory.getSupportedBases()) {
|
||||
bases.add(Integer.toString(base));
|
||||
}
|
||||
String[] items = new String[bases.size()];
|
||||
|
||||
ImGui.combo("Type", selectedBasePart, bases.toArray(items));
|
||||
String selectedItem = items[selectedBasePart.get()];
|
||||
Integer baseNumber = Integer.valueOf(selectedItem);
|
||||
BasePart[] baseParts = BasePartFactory.buildBasePartsByBase(baseNumber);
|
||||
|
||||
int flags = ImGuiTableFlags.ScrollX | ImGuiTableFlags.RowBg | ImGuiTableFlags.BordersOuter | ImGuiTableFlags.BordersV;
|
||||
ImGui.beginTable("base-part", 5, flags);
|
||||
ImGui.tableSetupColumn("ordinal");
|
||||
ImGui.tableSetupColumn("idTone");
|
||||
ImGui.tableSetupColumn("idLetter");
|
||||
ImGui.tableSetupColumn("ChinaKey");
|
||||
ImGui.tableSetupColumn("ChinaValue");
|
||||
ImGui.beginTable("base-part", 9, flags);
|
||||
ImGui.tableSetupColumn("Ordinal");
|
||||
ImGui.tableSetupColumn("Tone");
|
||||
ImGui.tableSetupColumn("Letter");
|
||||
ImGui.tableSetupColumn("ChinaK");
|
||||
ImGui.tableSetupColumn("ChinaV");
|
||||
ImGui.tableSetupColumn("Alt1");
|
||||
ImGui.tableSetupColumn("Alt2");
|
||||
ImGui.tableSetupColumn("Alt3");
|
||||
ImGui.tableSetupColumn("Alt4");
|
||||
ImGui.tableHeadersRow();
|
||||
|
||||
List<BasePart> parts = Arrays.asList(T60Sexagesimal.values());
|
||||
|
||||
for (BasePart part:parts) {
|
||||
for (BasePart part:baseParts) {
|
||||
ImGui.tableNextRow();
|
||||
ImGui.tableNextColumn();
|
||||
ImGui.text(Integer.toString(part.ordinal()));
|
||||
|
@ -55,7 +75,33 @@ public class BasePartRenderer extends ImGuiRendererMain {
|
|||
ImGui.text(part.getChinaKey());
|
||||
ImGui.tableNextColumn();
|
||||
ImGui.text(part.getChinaValue());
|
||||
|
||||
ImGui.tableNextColumn();
|
||||
if (part instanceof BasePartAlt1) {
|
||||
ImGui.text(BasePartAlt1.class.cast(part).getAlt1Value());
|
||||
} else {
|
||||
ImGui.text("");
|
||||
}
|
||||
ImGui.tableNextColumn();
|
||||
if (part instanceof BasePartAlt2) {
|
||||
ImGui.text(BasePartAlt2.class.cast(part).getAlt1Value());
|
||||
} else {
|
||||
ImGui.text("");
|
||||
}
|
||||
ImGui.tableNextColumn();
|
||||
if (part instanceof BasePartAlt3) {
|
||||
ImGui.text(BasePartAlt3.class.cast(part).getAlt1Value());
|
||||
} else {
|
||||
ImGui.text("");
|
||||
}
|
||||
ImGui.tableNextColumn();
|
||||
if (part instanceof BasePartAlt4) {
|
||||
ImGui.text(BasePartAlt4.class.cast(part).getAlt1Value());
|
||||
} else {
|
||||
ImGui.text("");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.endTable();
|
||||
|
||||
ImGui.end();
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
package love.distributedrebirth.numberxd.base2t;
|
||||
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePart;
|
||||
|
||||
public final class BasePartFactory {
|
||||
|
||||
private static final int[] SUPPORTED_BASES = {2,3,4,5,6,7,8,12,16,20,60};
|
||||
|
||||
public static int[] getSupportedBases() {
|
||||
return SUPPORTED_BASES;
|
||||
}
|
||||
|
||||
public static BasePart[] buildBasePartsByBase(int base) {
|
||||
switch (base) {
|
||||
case 2:
|
||||
return T02PartBinary.values();
|
||||
case 3:
|
||||
return T03PartTrit.values();
|
||||
case 4:
|
||||
return T04PartQuad.values();
|
||||
case 5:
|
||||
return T05PartPental.values();
|
||||
case 6:
|
||||
return T06PartSeximal.values();
|
||||
case 7:
|
||||
return T07PartPlanIt.values();
|
||||
case 8:
|
||||
return T08PartOctal.values();
|
||||
case 9:
|
||||
throw new IllegalArgumentException("Unsupported base: "+base);
|
||||
case 10:
|
||||
throw new IllegalArgumentException("Unsupported base: "+base);
|
||||
case 11:
|
||||
throw new IllegalArgumentException("Unsupported base: "+base);
|
||||
case 12:
|
||||
return T12PartUncial.values();
|
||||
case 16:
|
||||
return T16PartHex.values();
|
||||
case 20:
|
||||
return T20PartScore.values();
|
||||
case 60:
|
||||
return T60Sexagesimal.values();
|
||||
default:
|
||||
throw new IllegalArgumentException("Unsupported base: "+base);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package love.distributedrebirth.numberxd.base2t;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePart;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BaseFacetKey;
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePartAlt1;
|
||||
|
||||
/**
|
||||
* The distribution by 7.
|
||||
*
|
||||
* @author willemtsade ©Δ∞ 仙上主天
|
||||
*/
|
||||
public enum T07PartPlanIt implements BasePart,BasePartAlt1 {
|
||||
|
||||
PART_1("˥","0","♎︎","libra","天秤座"),
|
||||
PART_2("꜉","1","♏︎","scorpio","天蠍座"),
|
||||
PART_3("꜋","2","♓︎","pisces","雙魚座"),
|
||||
PART_4("꜔","3","♍︎","virgo","處女座"),
|
||||
PART_5("꜎","4","♋︎","cancer","癌症"),
|
||||
PART_6("꜐","5","♑︎","capricorn","摩羯座"),
|
||||
PART_7("˩","7","♈︎","aries","白羊座"),
|
||||
;
|
||||
|
||||
public static int LENGTH = 6;
|
||||
private final Map<BaseFacetKey, Object> facetStore = new HashMap<>();
|
||||
private static final String ALT_1_NAME = "Fallen sign";
|
||||
private static final String ALT_1_WIKI = "https://en.wikipedia.org/wiki/Classical_planet#Western_astrology";
|
||||
private static final Map<String, T07PartPlanIt> TONE_MAP = Collections.unmodifiableMap(
|
||||
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getIdentifierTone(), v -> v)));
|
||||
private static final Map<String, T07PartPlanIt> CHINA_MAP = Collections.unmodifiableMap(
|
||||
Arrays.asList(values()).stream().collect(Collectors.toMap(v -> v.getChinaKey(), v -> v)));
|
||||
|
||||
private T07PartPlanIt(String idTone, String idLetter, String chinaKey, String chinaValue, String alt1Value) {
|
||||
this.getFacetStore().put(BaseFacetKey.ID_TONE, idTone);
|
||||
this.getFacetStore().put(BaseFacetKey.ID_LETTER, idLetter);
|
||||
this.getFacetStore().put(BaseFacetKey.CHINA_KEY, chinaKey);
|
||||
this.getFacetStore().put(BaseFacetKey.CHINA_VALUE, chinaValue);
|
||||
this.getFacetStore().put(BaseFacetKey.ALT_1_VALUE, alt1Value);
|
||||
this.getFacetStore().put(BaseFacetKey.ALT_1_NAME, ALT_1_NAME);
|
||||
this.getFacetStore().put(BaseFacetKey.ALT_1_WIKI, ALT_1_WIKI);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<BaseFacetKey, Object> getFacetStore() {
|
||||
return facetStore;
|
||||
}
|
||||
|
||||
public static void forEach(Consumer<T07PartPlanIt> consumer) {
|
||||
for (T07PartPlanIt value:values()) {
|
||||
consumer.accept(value);
|
||||
}
|
||||
}
|
||||
|
||||
public static T07PartPlanIt valueOfTone(String identifierTone) {
|
||||
return TONE_MAP.get(identifierTone);
|
||||
}
|
||||
|
||||
public static T07PartPlanIt valueOfChina(String chinaKey) {
|
||||
return CHINA_MAP.get(chinaKey);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
package love.distributedrebirth.numberxd.base2t;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import love.distributedrebirth.numberxd.base2t.facet.BasePart;
|
||||
|
||||
public class BasePartFactoryTest {
|
||||
|
||||
@Test
|
||||
public void testSupportedBases() {
|
||||
int[] bases = BasePartFactory.getSupportedBases();
|
||||
Assertions.assertNotNull(bases);
|
||||
Assertions.assertTrue(bases.length > 1);
|
||||
Assertions.assertTrue(bases.length < 100);
|
||||
for (int base:bases) {
|
||||
Assertions.assertNotNull(base);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGlobalChinaMap() {
|
||||
Map<String,String> global = new HashMap<>();
|
||||
for (int base:BasePartFactory.getSupportedBases()) {
|
||||
for (BasePart part:BasePartFactory.buildBasePartsByBase(base)) {
|
||||
Assertions.assertFalse(global.containsKey(part.getChinaKey()));
|
||||
global.put(part.getChinaKey(), part.getChinaValue());
|
||||
}
|
||||
}
|
||||
Assertions.assertTrue(global.size() > 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGlobalToneMap() {
|
||||
boolean duplicate = false;
|
||||
Map<String,String> global = new HashMap<>();
|
||||
for (int base:BasePartFactory.getSupportedBases()) {
|
||||
for (BasePart part:BasePartFactory.buildBasePartsByBase(base)) {
|
||||
if (global.containsKey(part.getIdentifierTone())) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
global.put(part.getIdentifierTone(), part.getChinaValue());
|
||||
}
|
||||
}
|
||||
Assertions.assertTrue(global.size() > 1);
|
||||
Assertions.assertTrue(duplicate);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGlobalLetterMap() {
|
||||
boolean duplicate = false;
|
||||
Map<String,String> global = new HashMap<>();
|
||||
for (int base:BasePartFactory.getSupportedBases()) {
|
||||
for (BasePart part:BasePartFactory.buildBasePartsByBase(base)) {
|
||||
if (global.containsKey(part.getIdentifierLetter())) {
|
||||
duplicate = true;
|
||||
break;
|
||||
}
|
||||
global.put(part.getIdentifierLetter(), part.getChinaValue());
|
||||
}
|
||||
}
|
||||
Assertions.assertTrue(global.size() > 1);
|
||||
Assertions.assertTrue(duplicate);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package love.distributedrebirth.numberxd.base2t;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author willemtsade ©Δ∞ 仙上主天
|
||||
*/
|
||||
public class T07PartPlanItTest {
|
||||
|
||||
@Test
|
||||
public void testBasePart() {
|
||||
for (T07PartPlanIt value:T07PartPlanIt.values()) {
|
||||
Assertions.assertNotNull(value.getIdentifierTone());
|
||||
Assertions.assertNotNull(value.getIdentifierLetter());
|
||||
Assertions.assertNotNull(value.getChinaKey());
|
||||
Assertions.assertNotNull(value.getChinaValue());
|
||||
Assertions.assertNotNull(value.getAlt1Value());
|
||||
Assertions.assertNotNull(value.getAlt1Name());
|
||||
Assertions.assertNotNull(value.getAlt1Wiki());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToneMap() {
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_1, T07PartPlanIt.valueOfTone("˥"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_2, T07PartPlanIt.valueOfTone("꜉"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_6, T07PartPlanIt.valueOfTone("꜐"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_7, T07PartPlanIt.valueOfTone("˩"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChinaMap() {
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_1, T07PartPlanIt.valueOfChina("♎︎"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_2, T07PartPlanIt.valueOfChina("♏︎"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_6, T07PartPlanIt.valueOfChina("♑︎"));
|
||||
Assertions.assertEquals(T07PartPlanIt.PART_7, T07PartPlanIt.valueOfChina("♈︎"));
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue