Updated to new SWTHelper version
[Mograsim.git] / net.mograsim.logic.ui.am2900 / src / net / mograsim / logic / ui / model / components / mi / nandbased / am2901 / GUIAm2901SourceDecode.java
1 package net.mograsim.logic.ui.model.components.mi.nandbased.am2901;
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.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.model.wires.WireCrossPoint;
10 import net.mograsim.logic.ui.serializing.IndirectGUIComponentCreator;
11
12 public class GUIAm2901SourceDecode extends SimpleRectangularSubmodelComponent
13 {
14         public GUIAm2901SourceDecode(ViewModelModifiable model)
15         {
16                 this(model, null);
17         }
18
19         public GUIAm2901SourceDecode(ViewModelModifiable model, String name)
20         {
21                 super(model, 1, "Am2901SourceDecode", name);
22                 setSubmodelScale(.25);
23                 setInputPins("I2", "I1", "I0");
24                 setOutputPins("SQ", "RA", "SB", "SA", "RD");
25                 initSubmodelComponents();
26         }
27
28         @SuppressWarnings("unused") // for GUIWires being created
29         private void initSubmodelComponents()
30         {
31                 Pin I2 = getSubmodelPin("I2");
32                 Pin I1 = getSubmodelPin("I1");
33                 Pin I0 = getSubmodelPin("I0");
34                 Pin SQ = getSubmodelPin("SQ");
35                 Pin RA = getSubmodelPin("RA");
36                 Pin SB = getSubmodelPin("SB");
37                 Pin SA = getSubmodelPin("SA");
38                 Pin RD = getSubmodelPin("RD");
39
40                 GUINandGate notI2 = new GUINandGate(submodelModifiable, 1);
41                 GUINandGate notI1 = new GUINandGate(submodelModifiable, 1);
42                 GUINandGate notI0 = new GUINandGate(submodelModifiable, 1);
43                 GUINandGate nand21 = new GUINandGate(submodelModifiable, 1);
44                 GUINandGate nand22 = new GUINandGate(submodelModifiable, 1);
45                 GUINandGate nand23 = new GUINandGate(submodelModifiable, 1);
46                 GUINandGate nand24 = new GUINandGate(submodelModifiable, 1);
47                 GUINandGate nand25 = new GUINandGate(submodelModifiable, 1);
48                 GUINandGate nand31 = new GUINandGate(submodelModifiable, 1);
49                 GUINandGate nand32 = new GUINandGate(submodelModifiable, 1);
50                 GUINandGate nand33 = new GUINandGate(submodelModifiable, 1);
51                 GUINandGate nand34 = new GUINandGate(submodelModifiable, 1);
52                 GUINandGate nand35 = new GUINandGate(submodelModifiable, 1);
53                 GUINandGate nand41 = new GUINandGate(submodelModifiable, 1);
54                 GUINandGate nand42 = new GUINandGate(submodelModifiable, 1);
55
56                 WireCrossPoint cpI21 = new WireCrossPoint(submodelModifiable, 1);
57                 WireCrossPoint cpI22 = new WireCrossPoint(submodelModifiable, 1);
58                 WireCrossPoint cpI23 = new WireCrossPoint(submodelModifiable, 1);
59                 WireCrossPoint cpI1 = new WireCrossPoint(submodelModifiable, 1);
60                 WireCrossPoint cpI01 = new WireCrossPoint(submodelModifiable, 1);
61                 WireCrossPoint cpI02 = new WireCrossPoint(submodelModifiable, 1);
62                 WireCrossPoint cpNotI2 = new WireCrossPoint(submodelModifiable, 1);
63                 WireCrossPoint cpNotI11 = new WireCrossPoint(submodelModifiable, 1);
64                 WireCrossPoint cpNotI12 = new WireCrossPoint(submodelModifiable, 1);
65                 WireCrossPoint cpNotI13 = new WireCrossPoint(submodelModifiable, 1);
66                 WireCrossPoint cpNotI0 = new WireCrossPoint(submodelModifiable, 1);
67                 WireCrossPoint cpNand22 = new WireCrossPoint(submodelModifiable, 1);
68                 WireCrossPoint cpNand23 = new WireCrossPoint(submodelModifiable, 1);
69                 WireCrossPoint cpNand24 = new WireCrossPoint(submodelModifiable, 1);
70                 WireCrossPoint cpNand31 = new WireCrossPoint(submodelModifiable, 1);
71                 WireCrossPoint cpNand35 = new WireCrossPoint(submodelModifiable, 1);
72
73                 notI2.moveTo(10, 10);
74                 notI1.moveTo(10, 50);
75                 notI0.moveTo(10, 90);
76                 nand21.moveTo(40, 10);
77                 nand22.moveTo(40, 50);
78                 nand23.moveTo(40, 90);
79                 nand24.moveTo(40, 130);
80                 nand25.moveTo(40, 170);
81                 nand31.moveTo(70, 10);
82                 nand32.moveTo(70, 50);
83                 nand33.moveTo(70, 90);
84                 nand34.moveTo(70, 130);
85                 nand35.moveTo(70, 170);
86                 nand41.moveTo(100, 10);
87                 nand42.moveTo(100, 170);
88                 cpI21.moveCenterTo(5, 20);
89                 cpI22.moveCenterTo(7.5, 20);
90                 cpI23.moveCenterTo(5, 145);
91                 cpI1.moveCenterTo(7.5, 60);
92                 cpI01.moveCenterTo(7.5, 100);
93                 cpI02.moveCenterTo(7.5, 105);
94                 cpNotI2.moveCenterTo(32.5, 55);
95                 cpNotI11.moveCenterTo(35, 60);
96                 cpNotI12.moveCenterTo(35, 65);
97                 cpNotI13.moveCenterTo(35, 135);
98                 cpNotI0.moveCenterTo(37.5, 100);
99                 cpNand22.moveCenterTo(65, 60);
100                 cpNand23.moveCenterTo(65, 100);
101                 cpNand24.moveCenterTo(65, 140);
102                 cpNand31.moveCenterTo(95, 20);
103                 cpNand35.moveCenterTo(95, 180);
104
105                 new GUIWire(submodelModifiable, I2, cpI21, new Point[0]);
106                 new GUIWire(submodelModifiable, cpI21, nand21.getPin("A"), new Point(5, 5), new Point(35, 5), new Point(35, 15));
107                 new GUIWire(submodelModifiable, cpI21, cpI22, new Point[0]);
108                 new GUIWire(submodelModifiable, cpI22, notI2.getPin("A"), new Point(7.5, 15));
109                 new GUIWire(submodelModifiable, cpI22, notI2.getPin("B"), new Point(7.5, 25));
110                 new GUIWire(submodelModifiable, cpI21, cpI23, new Point[0]);
111                 new GUIWire(submodelModifiable, cpI23, nand24.getPin("B"), new Point[0]);
112                 new GUIWire(submodelModifiable, cpI23, nand35.getPin("B"), new Point(5, 195), new Point(65, 195), new Point(65, 185));
113                 new GUIWire(submodelModifiable, I1, cpI1, new Point[0]);
114                 new GUIWire(submodelModifiable, cpI1, notI1.getPin("A"), new Point(7.5, 55));
115                 new GUIWire(submodelModifiable, cpI1, notI1.getPin("B"), new Point(7.5, 65));
116                 new GUIWire(submodelModifiable, I0, cpI01, new Point[0]);
117                 new GUIWire(submodelModifiable, cpI01, notI0.getPin("A"), new Point(7.5, 95));
118                 new GUIWire(submodelModifiable, cpI01, cpI02, new Point[0]);
119                 new GUIWire(submodelModifiable, cpI02, notI0.getPin("B"), new Point[0]);
120                 new GUIWire(submodelModifiable, cpI02, nand23.getPin("B"), new Point(7.5, 112.5), new Point(32.5, 112.5), new Point(32.5, 105));
121                 new GUIWire(submodelModifiable, notI2.getPin("Y"), cpNotI2, new Point(32.5, 20));
122                 new GUIWire(submodelModifiable, cpNotI2, nand22.getPin("A"), new Point[0]);
123                 new GUIWire(submodelModifiable, cpNotI2, nand23.getPin("A"), new Point(32.5, 95));
124                 new GUIWire(submodelModifiable, notI1.getPin("Y"), cpNotI11, new Point[0]);
125                 new GUIWire(submodelModifiable, cpNotI11, nand21.getPin("B"), new Point(35, 25));
126                 new GUIWire(submodelModifiable, cpNotI11, cpNotI12, new Point[0]);
127                 new GUIWire(submodelModifiable, cpNotI12, nand22.getPin("B"), new Point[0]);
128                 new GUIWire(submodelModifiable, cpNotI12, cpNotI13, new Point[0]);
129                 new GUIWire(submodelModifiable, cpNotI13, nand24.getPin("A"), new Point[0]);
130                 new GUIWire(submodelModifiable, cpNotI13, nand25.getPin("A"), new Point(35, 175));
131                 new GUIWire(submodelModifiable, notI0.getPin("Y"), cpNotI0, new Point[0]);
132                 new GUIWire(submodelModifiable, cpNotI0, nand31.getPin("B"), new Point(37.5, 35), new Point(65, 35), new Point(65, 25));
133                 new GUIWire(submodelModifiable, cpNotI0, nand25.getPin("B"), new Point(37.5, 185));
134                 new GUIWire(submodelModifiable, nand21.getPin("Y"), nand31.getPin("A"));
135                 new GUIWire(submodelModifiable, nand22.getPin("Y"), cpNand22, new Point[0]);
136                 new GUIWire(submodelModifiable, cpNand22, nand32.getPin("A"), new Point(65, 55));
137                 new GUIWire(submodelModifiable, cpNand22, nand32.getPin("B"), new Point(65, 65));
138                 new GUIWire(submodelModifiable, nand23.getPin("Y"), cpNand23, new Point[0]);
139                 new GUIWire(submodelModifiable, cpNand23, nand33.getPin("A"), new Point(65, 95));
140                 new GUIWire(submodelModifiable, cpNand23, nand33.getPin("B"), new Point(65, 105));
141                 new GUIWire(submodelModifiable, nand24.getPin("Y"), cpNand24, new Point[0]);
142                 new GUIWire(submodelModifiable, cpNand24, nand34.getPin("A"), new Point(65, 135));
143                 new GUIWire(submodelModifiable, cpNand24, nand34.getPin("B"), new Point(65, 145));
144                 new GUIWire(submodelModifiable, nand25.getPin("Y"), nand35.getPin("A"));
145                 new GUIWire(submodelModifiable, nand31.getPin("Y"), cpNand31, new Point[0]);
146                 new GUIWire(submodelModifiable, cpNand31, nand41.getPin("A"), new Point(95, 15));
147                 new GUIWire(submodelModifiable, cpNand31, nand41.getPin("B"), new Point(95, 25));
148                 new GUIWire(submodelModifiable, nand32.getPin("Y"), RA, new Point[0]);
149                 new GUIWire(submodelModifiable, nand33.getPin("Y"), SB, new Point[0]);
150                 new GUIWire(submodelModifiable, nand34.getPin("Y"), SA, new Point[0]);
151                 new GUIWire(submodelModifiable, nand35.getPin("Y"), cpNand35, new Point[0]);
152                 new GUIWire(submodelModifiable, cpNand35, nand42.getPin("A"), new Point(95, 175));
153                 new GUIWire(submodelModifiable, cpNand35, nand42.getPin("B"), new Point(95, 185));
154                 new GUIWire(submodelModifiable, nand41.getPin("Y"), SQ, new Point[0]);
155                 new GUIWire(submodelModifiable, nand42.getPin("Y"), RD, new Point[0]);
156         }
157
158         static
159         {
160                 IndirectGUIComponentCreator.setComponentSupplier(GUIAm2901SourceDecode.class.getCanonicalName(),
161                                 (m, p, n) -> new GUIAm2901SourceDecode(m, n));
162         }
163 }