Pins are now accessed via name, not index
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / examples / JsonExample.java
index 82b2c8c..9596a69 100644 (file)
@@ -9,9 +9,9 @@ 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.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.params.SubmodelComponentParams;
 import net.mograsim.logic.ui.model.wires.GUIWire;
 
 public class JsonExample
@@ -26,8 +26,8 @@ public class JsonExample
                protected TestComponent(ViewModelModifiable model)
                {
                        super(model, 1, "Test");
-                       setInputCount(1);
                        setSubmodelScale(.4);
+                       setInputPins("Input pin #0");
                        GUICustomComponentCreator.create(submodelModifiable, "HalfAdder.json");
                }
        }
@@ -76,7 +76,8 @@ public class JsonExample
                        e.printStackTrace();
                }
 
-               SimpleRectangularSubmodelComponent adder = new GUIfulladder(model);
+               SimpleRectangularSubmodelComponent adder = (SimpleRectangularSubmodelComponent) GUICustomComponentCreator.create(model,
+                               "FullAdder.json");
 
                GUIManualSwitch swA = new GUIManualSwitch(model);
                swA.moveTo(0, 0);
@@ -91,12 +92,12 @@ public class JsonExample
                GUIBitDisplay bdZ = new GUIBitDisplay(model);
                bdZ.moveTo(90, 30);
 
-               new GUIWire(model, swA.getOutputPin(), adder.getInputPins().get(0));
-               new GUIWire(model, swB.getOutputPin(), adder.getInputPins().get(1));
-               new GUIWire(model, swC.getOutputPin(), adder.getInputPins().get(2));
+               new GUIWire(model, swA.getOutputPin(), adder.getPin("A"));
+               new GUIWire(model, swB.getOutputPin(), adder.getPin("B"));
+               new GUIWire(model, swC.getOutputPin(), adder.getPin("C"));
 
-               new GUIWire(model, adder.getOutputPins().get(0), bdY.getInputPin());
-               new GUIWire(model, adder.getOutputPins().get(1), bdZ.getInputPin());
+               new GUIWire(model, adder.getPin("Y"), bdY.getInputPin());
+               new GUIWire(model, adder.getPin("Z"), bdZ.getInputPin());
 
                SubmodelComponent adder2 = GUICustomComponentCreator.create(model, pC, "");
 
@@ -113,11 +114,11 @@ public class JsonExample
                bdZ = new GUIBitDisplay(model);
                bdZ.moveTo(90, 85);
 
-               new GUIWire(model, swA.getOutputPin(), adder2.getPins().get(0));
-               new GUIWire(model, swB.getOutputPin(), adder2.getPins().get(1));
-               new GUIWire(model, swC.getOutputPin(), adder2.getPins().get(2));
+               new GUIWire(model, swA.getOutputPin(), adder.getPin("A"));
+               new GUIWire(model, swB.getOutputPin(), adder.getPin("B"));
+               new GUIWire(model, swC.getOutputPin(), adder.getPin("C"));
 
-               new GUIWire(model, adder2.getPins().get(3), bdY.getInputPin());
-               new GUIWire(model, adder2.getPins().get(4), bdZ.getInputPin());
+               new GUIWire(model, adder.getPin("Y"), bdY.getInputPin());
+               new GUIWire(model, adder.getPin("Z"), bdZ.getInputPin());
        }
 }
\ No newline at end of file