Pins are now accessed via name, not index
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIfulladder.java
1 package net.mograsim.logic.ui.model.components.mi.nandbased;
2
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.SimpleRectangularSubmodelComponent;
7 import net.mograsim.logic.ui.model.wires.GUIWire;
8 import net.mograsim.logic.ui.model.wires.Pin;
9
10 public class GUIfulladder extends SimpleRectangularSubmodelComponent
11 {
12         public GUIfulladder(ViewModelModifiable model)
13         {
14                 super(model, 1, "GUIfulladder");
15                 setSubmodelScale(.4);
16                 setInputPins("A", "B", "C");
17                 setOutputPins("Y", "Z");
18                 initSubmodelComponents();
19         }
20
21         @SuppressWarnings("unused") // for GUIWires being created
22         private void initSubmodelComponents()
23         {
24                 Pin A = getSubmodelPin("A");
25                 Pin B = getSubmodelPin("B");
26                 Pin C = getSubmodelPin("C");
27                 Pin Y = getSubmodelPin("Y");
28                 Pin Z = getSubmodelPin("Z");
29
30                 GUIhalfadder halfBC = new GUIhalfadder(submodelModifiable);
31                 GUIhalfadder halfAY = new GUIhalfadder(submodelModifiable);
32                 GUINandGate nandZ = new GUINandGate(submodelModifiable, 1);
33
34                 halfAY.moveTo(45, 7.5);
35                 halfBC.moveTo(5, 40);
36                 nandZ.moveTo(57.5, 40);
37
38                 new GUIWire(submodelModifiable, A, halfAY.getPin("A"), new Point[0]);
39                 new GUIWire(submodelModifiable, B, halfBC.getPin("A"));
40                 new GUIWire(submodelModifiable, C, halfBC.getPin("B"));
41                 new GUIWire(submodelModifiable, halfBC.getPin("Y"), halfAY.getPin("B"));
42                 new GUIWire(submodelModifiable, halfBC.getPin("_Z"), nandZ.getPin("B"), new Point[0]);
43                 new GUIWire(submodelModifiable, halfAY.getPin("Y"), Y, new Point[0]);
44                 new GUIWire(submodelModifiable, halfAY.getPin("_Z"), nandZ.getPin("A"), new Point(82.5, 22.5), new Point(82.5, 35),
45                                 new Point(52.5, 35), new Point(52.5, 45));
46                 new GUIWire(submodelModifiable, nandZ.getPin("Y"), Z);
47         }
48 }