1 package net.mograsim.logic.ui.model.components.mi.nandbased;
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.ui.model.ViewModelModifiable;
5 import net.mograsim.logic.ui.model.components.GUINandGate;
6 import net.mograsim.logic.ui.model.components.SubmodelComponent;
7 import net.mograsim.logic.ui.model.wires.GUIWire;
8 import net.mograsim.logic.ui.model.wires.Pin;
9 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
11 public class GUIhalfadder extends SubmodelComponent
13 private final Pin pinA;
14 private final Pin pinB;
15 private final Pin pinY;
16 private final Pin pin_Z;
18 public GUIhalfadder(ViewModelModifiable model)
20 super(model, "GUIhalfadder");
24 Pin A = addSubmodelInterface(1, 0, 5);
25 Pin B = addSubmodelInterface(1, 0, 20);
26 Pin Y = addSubmodelInterface(1, 35, 5);
27 Pin _Z = addSubmodelInterface(1, 35, 20);
29 this.pinA = getSupermodelPin(A);
30 this.pinB = getSupermodelPin(B);
31 this.pinY = getSupermodelPin(Y);
32 this.pin_Z = getSupermodelPin(_Z);
34 initSubmodelComponents(A, B, Y, _Z);
37 @SuppressWarnings("unused") // for GUIWires being created
38 private void initSubmodelComponents(Pin A, Pin B, Pin Y, Pin _Z)
40 GUINandGate nand_Z = new GUINandGate(submodelModifiable, 1);
41 GUINandGate nandYA = new GUINandGate(submodelModifiable, 1);
42 GUINandGate nandYB = new GUINandGate(submodelModifiable, 1);
43 GUINandGate nandY = new GUINandGate(submodelModifiable, 1);
45 WireCrossPoint cpA = new WireCrossPoint(submodelModifiable, 1);
46 WireCrossPoint cpB = new WireCrossPoint(submodelModifiable, 1);
47 WireCrossPoint cp_Z = new WireCrossPoint(submodelModifiable, 1);
49 nand_Z.moveTo(10, 21.25);
50 nandYA.moveTo(40, 2.5);
51 nandYB.moveTo(40, 40);
52 nandY.moveTo(65, 2.5);
55 cp_Z.moveTo(35, 31.25);
57 new GUIWire(submodelModifiable, A, cpA);
58 new GUIWire(submodelModifiable, cpA, nandYA.getInputPins().get(0), new Point(5, 7.5));
59 new GUIWire(submodelModifiable, cpA, nand_Z.getInputPins().get(0), new Point(5, 26.25));
60 new GUIWire(submodelModifiable, B, cpB);
61 new GUIWire(submodelModifiable, cpB, nandYB.getInputPins().get(1), new Point(5, 55));
62 new GUIWire(submodelModifiable, cpB, nand_Z.getInputPins().get(1), new Point(5, 36.25));
63 new GUIWire(submodelModifiable, nand_Z.getOutputPin(), cp_Z);
64 new GUIWire(submodelModifiable, cp_Z, _Z, new Point(80, 31.25), new Point(80, 50));
65 new GUIWire(submodelModifiable, cp_Z, nandYA.getInputPins().get(1), new Point(35, 17.5));
66 new GUIWire(submodelModifiable, cp_Z, nandYB.getInputPins().get(0), new Point(35, 45));
67 new GUIWire(submodelModifiable, nandYA.getOutputPin(), nandY.getInputPins().get(0), new Point(62.5, 12.5), new Point(62.5, 7.5));
68 new GUIWire(submodelModifiable, nandYB.getOutputPin(), nandY.getInputPins().get(1), new Point(62.5, 50), new Point(62.5, 17.5));
69 new GUIWire(submodelModifiable, nandY.getOutputPin(), Y);