X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fcomponents%2Fmi%2Fnandbased%2FGUIfulladder.java;h=1f424a9d0d3065e0e258feab748523b5ce30acae;hb=ae74a6a022756a4cc7ee5b453ad7a68e13832788;hp=0e3a8fd9e661dfc87fdfdf2f1bfbfd1a9082cd5b;hpb=63a0289cdf12e2f349267b6be9897350171d9741;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIfulladder.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIfulladder.java index 0e3a8fd9..1f424a9d 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIfulladder.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIfulladder.java @@ -1,83 +1,48 @@ 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; -public class GUIfulladder extends SubmodelComponent +public class GUIfulladder extends SimpleRectangularSubmodelComponent { - private final Pin pinA; - private final Pin pinB; - private final Pin pinC; - private final Pin pinY; - private final Pin pinZ; - public GUIfulladder(ViewModelModifiable model) { - super(model, "GUIfulladder"); - setSize(50, 40); + super(model, 1, "GUIfulladder"); setSubmodelScale(.4); - - Pin A = addSubmodelInterface(1, 0, 5); - Pin B = addSubmodelInterface(1, 0, 20); - Pin C = addSubmodelInterface(1, 0, 35); - Pin Y = addSubmodelInterface(1, 50, 5); - Pin Z = addSubmodelInterface(1, 50, 20); - - this.pinA = getSupermodelPin(A); - this.pinB = getSupermodelPin(B); - this.pinC = getSupermodelPin(C); - this.pinY = getSupermodelPin(Y); - this.pinZ = getSupermodelPin(Z); - - initSubmodelComponents(A, B, C, Y, Z); + setInputPins("A", "B", "C"); + setOutputPins("Y", "Z"); + initSubmodelComponents(); } @SuppressWarnings("unused") // for GUIWires being created - private void initSubmodelComponents(Pin A, Pin B, Pin C, Pin Y, Pin Z) + private void initSubmodelComponents() { + Pin A = getInputSubmodelPins().get(0); + Pin B = getInputSubmodelPins().get(1); + Pin C = getInputSubmodelPins().get(2); + Pin Y = getOutputSubmodelPins().get(0); + Pin Z = getOutputSubmodelPins().get(1); + GUIhalfadder halfBC = new GUIhalfadder(submodelModifiable); GUIhalfadder halfAY = new GUIhalfadder(submodelModifiable); GUINandGate nandZ = new GUINandGate(submodelModifiable, 1); - halfAY.moveTo(55, 7.5); - halfBC.moveTo(10, 40); - nandZ.moveTo(100, 25); - - new GUIWire(submodelModifiable, A, halfAY.getPinA()); - new GUIWire(submodelModifiable, B, halfBC.getPinA());// , new Point(5, 50), new Point(5, 45)); - new GUIWire(submodelModifiable, C, halfBC.getPinB());// , new Point(5, 87.5), new Point(5, 60)); - new GUIWire(submodelModifiable, halfBC.getPinY(), halfAY.getPinB());// , new Point(50, 45), new Point(50, 27.5)); - new GUIWire(submodelModifiable, halfBC.getPin_Z(), nandZ.getInputPins().get(1)); - new GUIWire(submodelModifiable, halfAY.getPinY(), Y); - new GUIWire(submodelModifiable, halfAY.getPin_Z(), nandZ.getInputPins().get(0)); + halfAY.moveTo(45, 7.5); + halfBC.moveTo(5, 40); + nandZ.moveTo(57.5, 40); + + new GUIWire(submodelModifiable, A, halfAY.getInputPins().get(0), new Point[0]); + new GUIWire(submodelModifiable, B, halfBC.getInputPins().get(0)); + new GUIWire(submodelModifiable, C, halfBC.getInputPins().get(1)); + new GUIWire(submodelModifiable, halfBC.getOutputPins().get(0), halfAY.getInputPins().get(1)); + new GUIWire(submodelModifiable, halfBC.getOutputPins().get(1), nandZ.getInputPins().get(1), new Point[0]); + new GUIWire(submodelModifiable, halfAY.getOutputPins().get(0), Y, new Point[0]); + new GUIWire(submodelModifiable, halfAY.getOutputPins().get(1), nandZ.getInputPins().get(0), new Point(82.5, 22.5), + new Point(82.5, 35), new Point(52.5, 35), new Point(52.5, 45)); new GUIWire(submodelModifiable, nandZ.getOutputPin(), Z); } - - public Pin getPinA() - { - return pinA; - } - - public Pin getPinB() - { - return pinB; - } - - public Pin getPinC() - { - return pinC; - } - - public Pin getPinY() - { - return pinY; - } - - public Pin getPinZ() - { - return pinZ; - } } \ No newline at end of file