Updated GUIfulladder to SimpleRectangularSubmodelComponent
[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                 setSize(50, 40);
16                 setSubmodelScale(.4);
17                 setInputCount(3);
18                 setOutputCount(2);
19                 initSubmodelComponents();
20         }
21
22         @SuppressWarnings("unused") // for GUIWires being created
23         private void initSubmodelComponents()
24         {
25                 Pin A = getInputSubmodelPins().get(0);
26                 Pin B = getInputSubmodelPins().get(1);
27                 Pin C = getInputSubmodelPins().get(2);
28                 Pin Y = getOutputSubmodelPins().get(0);
29                 Pin Z = getOutputSubmodelPins().get(1);
30
31                 GUIhalfadder halfBC = new GUIhalfadder(submodelModifiable);
32                 GUIhalfadder halfAY = new GUIhalfadder(submodelModifiable);
33                 GUINandGate nandZ = new GUINandGate(submodelModifiable, 1);
34
35                 halfAY.moveTo(45, 7.5);
36                 halfBC.moveTo(5, 40);
37                 nandZ.moveTo(57.5, 40);
38
39                 new GUIWire(submodelModifiable, A, halfAY.getInputPins().get(0), new Point[0]);
40                 new GUIWire(submodelModifiable, B, halfBC.getInputPins().get(0));
41                 new GUIWire(submodelModifiable, C, halfBC.getInputPins().get(1));
42                 new GUIWire(submodelModifiable, halfBC.getOutputPins().get(0), halfAY.getInputPins().get(1));
43                 new GUIWire(submodelModifiable, halfBC.getOutputPins().get(1), nandZ.getInputPins().get(1), new Point[0]);
44                 new GUIWire(submodelModifiable, halfAY.getOutputPins().get(0), Y, new Point[0]);
45                 new GUIWire(submodelModifiable, halfAY.getOutputPins().get(1), nandZ.getInputPins().get(0), new Point(82.5, 22.5),
46                                 new Point(82.5, 35), new Point(52.5, 35), new Point(52.5, 45));
47                 new GUIWire(submodelModifiable, nandZ.getOutputPin(), Z);
48         }
49 }