Updated GUInand3 to SimpleRectangularSubmodelComponent
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 5 Jun 2019 16:37:31 +0000 (18:37 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 5 Jun 2019 16:37:31 +0000 (18:37 +0200)
net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/SubmodelComponentTestbench.java
net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUInand3.java

index a2c63a1..7563d44 100644 (file)
@@ -5,7 +5,7 @@ import net.mograsim.logic.ui.model.ViewModelModifiable;
 import net.mograsim.logic.ui.model.components.GUIBitDisplay;
 import net.mograsim.logic.ui.model.components.GUIManualSwitch;
 import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent;
-import net.mograsim.logic.ui.model.components.mi.nandbased.GUIdemux2;
+import net.mograsim.logic.ui.model.components.mi.nandbased.GUInand3;
 import net.mograsim.logic.ui.model.wires.GUIWire;
 
 public class SubmodelComponentTestbench
@@ -18,7 +18,7 @@ public class SubmodelComponentTestbench
        @SuppressWarnings("unused") // for GUIWires being created
        public static void createTestbench(ViewModelModifiable model)
        {
-               SimpleRectangularSubmodelComponent comp = new GUIdemux2(model);
+               SimpleRectangularSubmodelComponent comp = new GUInand3(model);
 
                comp.moveTo(100, 0);
                for (int i = 0; i < comp.getInputPins().size(); i++)
index d126dfe..0b0a3b5 100644 (file)
@@ -3,40 +3,30 @@ package net.mograsim.logic.ui.model.components.mi.nandbased;
 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
 import net.mograsim.logic.ui.model.ViewModelModifiable;
 import net.mograsim.logic.ui.model.components.GUINandGate;
-import net.mograsim.logic.ui.model.components.SubmodelComponent;
+import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent;
 import net.mograsim.logic.ui.model.wires.GUIWire;
 import net.mograsim.logic.ui.model.wires.Pin;
 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
 
-public class GUInand3 extends SubmodelComponent
+public class GUInand3 extends SimpleRectangularSubmodelComponent
 {
-       private final Pin pinA;
-       private final Pin pinB;
-       private final Pin pinC;
-       private final Pin pinY;
-
        public GUInand3(ViewModelModifiable model)
        {
-               super(model, "GUInand3");
-               setSize(40, 30);
+               super(model, 1, "GUInand3");
                setSubmodelScale(.4);
-
-               Pin A = addSubmodelInterface(1, 0, 5);
-               Pin B = addSubmodelInterface(1, 0, 15);
-               Pin C = addSubmodelInterface(1, 0, 25);
-               Pin Y = addSubmodelInterface(1, 40, 15);
-
-               this.pinA = getSupermodelPin(A);
-               this.pinB = getSupermodelPin(B);
-               this.pinC = getSupermodelPin(C);
-               this.pinY = getSupermodelPin(Y);
-
-               initSubmodelComponents(A, B, C, Y);
+               setInputCount(3);
+               setOutputCount(1);
+               initSubmodelComponents();
        }
 
        @SuppressWarnings("unused") // for GUIWires being created
-       private void initSubmodelComponents(Pin A, Pin B, Pin C, Pin Y)
+       private void initSubmodelComponents()
        {
+               Pin A = getInputSubmodelPins().get(0);
+               Pin B = getInputSubmodelPins().get(1);
+               Pin C = getInputSubmodelPins().get(2);
+               Pin Y = getOutputSubmodelPins().get(0);
+
                GUINandGate nandAB = new GUINandGate(submodelModifiable, 1);
                GUINandGate andAB = new GUINandGate(submodelModifiable, 1);
                GUINandGate nandABC = new GUINandGate(submodelModifiable, 1);
@@ -44,37 +34,17 @@ public class GUInand3 extends SubmodelComponent
                WireCrossPoint cpNandAB = new WireCrossPoint(submodelModifiable, 1);
 
                nandAB.moveTo(10, 15);
-               andAB.moveTo(40, 15);
-               nandABC.moveTo(70, 27.5);
-               cpNandAB.moveTo(35, 25);
-
-               new GUIWire(submodelModifiable, A, nandAB.getInputPins().get(0), new Point(5, 12.5), new Point(5, 20));
-               new GUIWire(submodelModifiable, B, nandAB.getInputPins().get(1), new Point(5, 37.5), new Point(5, 30));
-               new GUIWire(submodelModifiable, nandAB.getOutputPin(), cpNandAB);
-               new GUIWire(submodelModifiable, cpNandAB, andAB.getInputPins().get(0), new Point(35, 20));
-               new GUIWire(submodelModifiable, cpNandAB, andAB.getInputPins().get(1), new Point(35, 30));
-               new GUIWire(submodelModifiable, andAB.getOutputPin(), nandABC.getInputPins().get(0), new Point(65, 25), new Point(65, 32.5));
-               new GUIWire(submodelModifiable, C, nandABC.getInputPins().get(1), new Point(65, 62.5), new Point(65, 42.5));
-               new GUIWire(submodelModifiable, nandABC.getOutputPin(), Y);
-       }
-
-       public Pin getPinA()
-       {
-               return pinA;
-       }
-
-       public Pin getPinB()
-       {
-               return pinB;
-       }
-
-       public Pin getPinC()
-       {
-               return pinC;
-       }
-
-       public Pin getPinY()
-       {
-               return pinY;
+               andAB.moveTo(35, 15);
+               nandABC.moveTo(62.5, 2.5);
+               cpNandAB.moveTo(32.5, 25);
+
+               new GUIWire(submodelModifiable, A, nandAB.getInputPins().get(0));
+               new GUIWire(submodelModifiable, B, nandAB.getInputPins().get(1));
+               new GUIWire(submodelModifiable, nandAB.getOutputPin(), cpNandAB, new Point[0]);
+               new GUIWire(submodelModifiable, cpNandAB, andAB.getInputPins().get(0), new Point(32.5, 20));
+               new GUIWire(submodelModifiable, cpNandAB, andAB.getInputPins().get(1), new Point(32.5, 30));
+               new GUIWire(submodelModifiable, andAB.getOutputPin(), nandABC.getInputPins().get(0), new Point(57.5, 25), new Point(57.5, 7.5));
+               new GUIWire(submodelModifiable, C, nandABC.getInputPins().get(1), new Point(60, 62.5), new Point(60, 17.5));
+               new GUIWire(submodelModifiable, nandABC.getOutputPin(), Y, new Point[0]);
        }
 }
\ No newline at end of file