1 package net.mograsim.logic.ui.model.components.mi.nandbased;
3 import net.mograsim.logic.ui.model.ViewModelModifiable;
4 import net.mograsim.logic.ui.model.components.GUINandGate;
5 import net.mograsim.logic.ui.model.components.SubmodelComponent;
6 import net.mograsim.logic.ui.model.wires.GUIWire;
7 import net.mograsim.logic.ui.model.wires.Pin;
9 public class GUIfulladder extends SubmodelComponent
11 private final Pin pinA;
12 private final Pin pinB;
13 private final Pin pinC;
14 private final Pin pinY;
15 private final Pin pinZ;
17 public GUIfulladder(ViewModelModifiable model)
19 super(model, "GUIfulladder");
23 Pin A = addSubmodelInterface(1, 0, 5);
24 Pin B = addSubmodelInterface(1, 0, 20);
25 Pin C = addSubmodelInterface(1, 0, 35);
26 Pin Y = addSubmodelInterface(1, 50, 5);
27 Pin Z = addSubmodelInterface(1, 50, 20);
29 this.pinA = getSupermodelPin(A);
30 this.pinB = getSupermodelPin(B);
31 this.pinC = getSupermodelPin(C);
32 this.pinY = getSupermodelPin(Y);
33 this.pinZ = getSupermodelPin(Z);
35 initSubmodelComponents(A, B, C, Y, Z);
38 @SuppressWarnings("unused") // for GUIWires being created
39 private void initSubmodelComponents(Pin A, Pin B, Pin C, Pin Y, Pin Z)
41 GUIhalfadder halfBC = new GUIhalfadder(submodelModifiable);
42 GUIhalfadder halfAY = new GUIhalfadder(submodelModifiable);
43 GUINandGate nandZ = new GUINandGate(submodelModifiable, 1);
45 halfAY.moveTo(55, 7.5);
46 halfBC.moveTo(10, 40);
47 nandZ.moveTo(100, 25);
49 new GUIWire(submodelModifiable, A, halfAY.getPinA());
50 new GUIWire(submodelModifiable, B, halfBC.getPinA());// , new Point(5, 50), new Point(5, 45));
51 new GUIWire(submodelModifiable, C, halfBC.getPinB());// , new Point(5, 87.5), new Point(5, 60));
52 new GUIWire(submodelModifiable, halfBC.getPinY(), halfAY.getPinB());// , new Point(50, 45), new Point(50, 27.5));
53 new GUIWire(submodelModifiable, halfBC.getPin_Z(), nandZ.getInputPins().get(1));
54 new GUIWire(submodelModifiable, halfAY.getPinY(), Y);
55 new GUIWire(submodelModifiable, halfAY.getPin_Z(), nandZ.getInputPins().get(0));
56 new GUIWire(submodelModifiable, nandZ.getOutputPin(), Z);