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.atomic.GUINandGate;
6 import net.mograsim.logic.ui.model.components.submodels.SimpleRectangularSubmodelComponent;
7 import net.mograsim.logic.ui.model.wires.GUIWire;
8 import net.mograsim.logic.ui.model.wires.Pin;
9 import net.mograsim.logic.ui.serializing.IndirectGUIComponentCreator;
11 public class GUIfulladder extends SimpleRectangularSubmodelComponent
13 public GUIfulladder(ViewModelModifiable model)
15 super(model, 1, "GUIfulladder");
17 setInputPins("A", "B", "C");
18 setOutputPins("Y", "Z");
19 initSubmodelComponents();
22 @SuppressWarnings("unused") // for GUIWires being created
23 private void initSubmodelComponents()
25 Pin A = getSubmodelPin("A");
26 Pin B = getSubmodelPin("B");
27 Pin C = getSubmodelPin("C");
28 Pin Y = getSubmodelPin("Y");
29 Pin Z = getSubmodelPin("Z");
31 GUIhalfadder halfBC = new GUIhalfadder(submodelModifiable);
32 GUIhalfadder halfAY = new GUIhalfadder(submodelModifiable);
33 GUINandGate nandZ = new GUINandGate(submodelModifiable, 1);
35 halfAY.moveTo(45, 7.5);
37 nandZ.moveTo(57.5, 40);
39 new GUIWire(submodelModifiable, A, halfAY.getPin("A"), new Point[0]);
40 new GUIWire(submodelModifiable, B, halfBC.getPin("A"));
41 new GUIWire(submodelModifiable, C, halfBC.getPin("B"));
42 new GUIWire(submodelModifiable, halfBC.getPin("Y"), halfAY.getPin("B"));
43 new GUIWire(submodelModifiable, halfBC.getPin("_Z"), nandZ.getPin("B"), new Point[0]);
44 new GUIWire(submodelModifiable, halfAY.getPin("Y"), Y, new Point[0]);
45 new GUIWire(submodelModifiable, halfAY.getPin("_Z"), nandZ.getPin("A"), new Point(82.5, 22.5), new Point(82.5, 35),
46 new Point(52.5, 35), new Point(52.5, 45));
47 new GUIWire(submodelModifiable, nandZ.getPin("Y"), Z);
52 IndirectGUIComponentCreator.setComponentProvider(GUIfulladder.class.getCanonicalName(), (m, p) -> new GUIfulladder(m));