Renamed logic.ui to logic.model
[Mograsim.git] / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / model / components / mi / nandbased / GUIfulladder.java
1 package net.mograsim.logic.model.model.components.mi.nandbased;
2
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.model.model.ViewModelModifiable;
5 import net.mograsim.logic.model.model.components.atomic.GUINandGate;
6 import net.mograsim.logic.model.model.components.submodels.SimpleRectangularSubmodelComponent;
7 import net.mograsim.logic.model.model.wires.GUIWire;
8 import net.mograsim.logic.model.model.wires.Pin;
9 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
10
11 public class GUIfulladder extends SimpleRectangularSubmodelComponent
12 {
13         public GUIfulladder(ViewModelModifiable model)
14         {
15                 this(model, null);
16         }
17
18         public GUIfulladder(ViewModelModifiable model, String name)
19         {
20                 super(model, 1, "GUIfulladder", name);
21                 setSubmodelScale(.4);
22                 setInputPins("A", "B", "C");
23                 setOutputPins("Y", "Z");
24                 initSubmodelComponents();
25         }
26
27         @SuppressWarnings("unused") // for GUIWires being created
28         private void initSubmodelComponents()
29         {
30                 Pin A = getSubmodelPin("A");
31                 Pin B = getSubmodelPin("B");
32                 Pin C = getSubmodelPin("C");
33                 Pin Y = getSubmodelPin("Y");
34                 Pin Z = getSubmodelPin("Z");
35
36                 GUIhalfadder halfBC = new GUIhalfadder(submodelModifiable);
37                 GUIhalfadder halfAY = new GUIhalfadder(submodelModifiable);
38                 GUINandGate nandZ = new GUINandGate(submodelModifiable, 1);
39
40                 halfAY.moveTo(45, 7.5);
41                 halfBC.moveTo(5, 40);
42                 nandZ.moveTo(57.5, 40);
43
44                 new GUIWire(submodelModifiable, A, halfAY.getPin("A"), new Point[0]);
45                 new GUIWire(submodelModifiable, B, halfBC.getPin("A"));
46                 new GUIWire(submodelModifiable, C, halfBC.getPin("B"));
47                 new GUIWire(submodelModifiable, halfBC.getPin("Y"), halfAY.getPin("B"));
48                 new GUIWire(submodelModifiable, halfBC.getPin("_Z"), nandZ.getPin("B"), new Point[0]);
49                 new GUIWire(submodelModifiable, halfAY.getPin("Y"), Y, new Point[0]);
50                 new GUIWire(submodelModifiable, halfAY.getPin("_Z"), nandZ.getPin("A"), new Point(82.5, 22.5), new Point(82.5, 35),
51                                 new Point(52.5, 35), new Point(52.5, 45));
52                 new GUIWire(submodelModifiable, nandZ.getPin("Y"), Z);
53         }
54
55         static
56         {
57                 IndirectGUIComponentCreator.setComponentSupplier(GUIfulladder.class.getCanonicalName(), (m, p, n) -> new GUIfulladder(m, n));
58         }
59 }