X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fexamples%2FJsonExample.java;h=793f0f7f45bd28da1d54404271f8468189880e97;hb=ae74a6a022756a4cc7ee5b453ad7a68e13832788;hp=c6a2e7beb8b035d716ca5ea7876b1a7444547762;hpb=b2f3d0b16783289fab229c667c18d61f84119bbd;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/JsonExample.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/JsonExample.java index c6a2e7be..793f0f7f 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/JsonExample.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/JsonExample.java @@ -5,26 +5,20 @@ import java.io.IOException; import net.mograsim.logic.ui.SimpleLogicUIStandalone; import net.mograsim.logic.ui.model.ViewModelModifiable; import net.mograsim.logic.ui.model.components.GUIBitDisplay; -import net.mograsim.logic.ui.model.components.GUIComponent; import net.mograsim.logic.ui.model.components.GUICustomComponentCreator; import net.mograsim.logic.ui.model.components.GUIManualSwitch; import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent; import net.mograsim.logic.ui.model.components.SubmodelComponent; -import net.mograsim.logic.ui.model.components.mi.nandbased.GUIand; +import net.mograsim.logic.ui.model.components.SubmodelComponentParams; import net.mograsim.logic.ui.model.components.mi.nandbased.GUIfulladder; import net.mograsim.logic.ui.model.components.mi.nandbased.GUIhalfadder; -import net.mograsim.logic.ui.model.components.mi.nandbased.GUImux1; -import net.mograsim.logic.ui.model.components.mi.nandbased.GUImux1_4; -import net.mograsim.logic.ui.model.components.mi.nandbased.GUIsel2_4; -import net.mograsim.logic.ui.model.components.params.RectComponentParams; -import net.mograsim.logic.ui.model.components.params.SubComponentParams; import net.mograsim.logic.ui.model.wires.GUIWire; public class JsonExample { public static void main(String[] args) { - SimpleLogicUIStandalone.executeVisualisation(JsonExample::createFromJsonExample); + SimpleLogicUIStandalone.executeVisualisation(JsonExample::refJsonFromJsonTest); } private static class TestComponent extends SimpleRectangularSubmodelComponent @@ -32,18 +26,18 @@ public class JsonExample protected TestComponent(ViewModelModifiable model) { super(model, 1, "Test"); - setInputCount(1); setSubmodelScale(.4); - GUICustomComponentCreator.create(submodelModifiable, "HalfAdder.rc"); + setInputPins("Test input pin"); + GUICustomComponentCreator.create(submodelModifiable, "HalfAdder.json"); } } - // Execute only after HalfAdder.rc has been created + // Execute only after HalfAdder.json has been created public static void refJsonFromJsonTest(ViewModelModifiable model) { TestComponent t = new TestComponent(model); - t.calculateParams().writeJson("Test.sc"); - SubmodelComponent c = GUICustomComponentCreator.create(model, "Test.sc"); + t.calculateParams().writeJson("Test.json"); + SubmodelComponent c = GUICustomComponentCreator.create(model, "Test.json"); c.moveTo(0, 50); } @@ -52,54 +46,38 @@ public class JsonExample { GUIhalfadder tmp = new GUIhalfadder(model); tmp.moveTo(1000, 50); - RectComponentParams p = tmp.calculateRectParams(); - SubComponentParams pC = tmp.calculateParams(); + SubmodelComponentParams p = tmp.calculateParams(); try { - p.writeJson("HalfAdder.rc"); - pC.writeJson("HalfAdder.sc"); - p = RectComponentParams.readJson("HalfAdder.rc"); - pC = SubComponentParams.readJson("HalfAdder.sc"); + p.writeJson("HalfAdder.json"); + p = SubmodelComponentParams.readJson("HalfAdder.json"); } catch (IOException e) { e.printStackTrace(); } - SubmodelComponent adder = GUICustomComponentCreator.create(model, p, ""); - adder = GUICustomComponentCreator.create(model, pC, ""); - adder.moveTo(0, 200); + GUICustomComponentCreator.create(model, p, ""); } @SuppressWarnings("unused") // for GUIWires being created public static void createFromJsonExample(ViewModelModifiable model) { - SimpleRectangularSubmodelComponent tmp = new GUIhalfadder(model); - tmp.moveTo(1000, 50); - RectComponentParams p = tmp.calculateRectParams(); - try - { - p.writeJson("HalfAdder.rc"); - p = RectComponentParams.readJson("HalfAdder.rc"); - } - catch (IOException e) - { - e.printStackTrace(); - } - tmp = new GUIfulladder(model); - SubComponentParams pC = tmp.calculateParams(); + SimpleRectangularSubmodelComponent tmp = new GUIfulladder(model); + SubmodelComponentParams pC = tmp.calculateParams(); tmp.moveTo(1000, 100); try { - pC.writeJson("FullAdder.sc"); - pC = SubComponentParams.readJson("FullAdder.sc"); + pC.writeJson("FullAdder.json"); + pC = SubmodelComponentParams.readJson("FullAdder.json"); } catch (IOException e) { e.printStackTrace(); } - SimpleRectangularSubmodelComponent adder = new GUIfulladder(model); + SimpleRectangularSubmodelComponent adder = (SimpleRectangularSubmodelComponent) GUICustomComponentCreator.create(model, + "FullAdder.json"); GUIManualSwitch swA = new GUIManualSwitch(model); swA.moveTo(0, 0);