Updated GUIand to SimpleRectangularSubmodelComponent
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 5 Jun 2019 15:43:53 +0000 (17:43 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Wed, 5 Jun 2019 15:43:53 +0000 (17:43 +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/GUIand.java

index 19416b7..d29ecb2 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.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.GUI_rsLatch;
+import net.mograsim.logic.ui.model.components.mi.nandbased.GUIand;
 import net.mograsim.logic.ui.model.wires.GUIWire;
 
 public class SubmodelComponentTestbench
 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)
        {
        @SuppressWarnings("unused") // for GUIWires being created
        public static void createTestbench(ViewModelModifiable model)
        {
-               SimpleRectangularSubmodelComponent comp = new GUI_rsLatch(model);
+               SimpleRectangularSubmodelComponent comp = new GUIand(model);
 
                comp.moveTo(100, 0);
                for (int i = 0; i < comp.getInputPins().size(); i++)
 
                comp.moveTo(100, 0);
                for (int i = 0; i < comp.getInputPins().size(); i++)
index eb8b888..35c47b0 100644 (file)
@@ -3,67 +3,43 @@ 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.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;
 
 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 GUIand extends SubmodelComponent
+public class GUIand extends SimpleRectangularSubmodelComponent
 {
 {
-       private final Pin pinA;
-       private final Pin pinB;
-       private final Pin pinY;
-
        public GUIand(ViewModelModifiable model)
        {
        public GUIand(ViewModelModifiable model)
        {
-               super(model, "GUIand");
-               setSize(35, 25);
+               super(model, 1, "GUIand");
                setSubmodelScale(.4);
                setSubmodelScale(.4);
-
-               Pin A = addSubmodelInterface(1, 0, 5);
-               Pin B = addSubmodelInterface(1, 0, 20);
-               Pin Y = addSubmodelInterface(1, 35, 12.5);
-
-               this.pinA = getSupermodelPin(A);
-               this.pinB = getSupermodelPin(B);
-               this.pinY = getSupermodelPin(Y);
-
-               initSubmodelComponents(A, B, Y);
+               setInputCount(2);
+               setOutputCount(1);
+               initSubmodelComponents();
        }
 
        @SuppressWarnings("unused") // for GUIWires being created
        }
 
        @SuppressWarnings("unused") // for GUIWires being created
-       private void initSubmodelComponents(Pin A, Pin B, Pin Y)
+       private void initSubmodelComponents()
        {
        {
+               Pin A = getInputSubmodelPins().get(0);
+               Pin B = getInputSubmodelPins().get(1);
+               Pin Y = getOutputSubmodelPins().get(0);
+
                GUINandGate nand = new GUINandGate(submodelModifiable, 1);
                GUINandGate not = new GUINandGate(submodelModifiable, 1);
 
                WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
 
                GUINandGate nand = new GUINandGate(submodelModifiable, 1);
                GUINandGate not = new GUINandGate(submodelModifiable, 1);
 
                WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
 
-               nand.moveTo(20, 21.25);
-               not.moveTo(50, 21.25);
-               cp1.moveTo(45, 31.25);
+               nand.moveTo(20, 15);
+               not.moveTo(50, 15);
+               cp1.moveTo(45, 25);
 
 
-               new GUIWire(submodelModifiable, A, nand.getInputPins().get(0), new Point(10, 12.5), new Point(10, 26.25));
-               new GUIWire(submodelModifiable, B, nand.getInputPins().get(1), new Point(10, 50), new Point(10, 36.25));
-               new GUIWire(submodelModifiable, nand.getOutputPin(), cp1);
-               new GUIWire(submodelModifiable, cp1, not.getInputPins().get(0), new Point(45, 26.25));
-               new GUIWire(submodelModifiable, cp1, not.getInputPins().get(1), new Point(45, 36.25));
+               new GUIWire(submodelModifiable, A, nand.getInputPins().get(0));
+               new GUIWire(submodelModifiable, B, nand.getInputPins().get(1));
+               new GUIWire(submodelModifiable, nand.getOutputPin(), cp1, new Point[0]);
+               new GUIWire(submodelModifiable, cp1, not.getInputPins().get(0), new Point(45, 20));
+               new GUIWire(submodelModifiable, cp1, not.getInputPins().get(1), new Point(45, 30));
                new GUIWire(submodelModifiable, not.getOutputPin(), Y);
        }
                new GUIWire(submodelModifiable, not.getOutputPin(), Y);
        }
-
-       public Pin getPinA()
-       {
-               return pinA;
-       }
-
-       public Pin getPinB()
-       {
-               return pinB;
-       }
-
-       public Pin getPinY()
-       {
-               return pinY;
-       }
-
 }
\ No newline at end of file
 }
\ No newline at end of file