Implemented GUIor_4
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIor_4.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.SubmodelComponent;
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
11 public class GUIor_4 extends SubmodelComponent
12 {
13         private final Pin pinA1;
14         private final Pin pinA2;
15         private final Pin pinA3;
16         private final Pin pinA4;
17         private final Pin pinB1;
18         private final Pin pinB2;
19         private final Pin pinB3;
20         private final Pin pinB4;
21         private final Pin pinY1;
22         private final Pin pinY2;
23         private final Pin pinY3;
24         private final Pin pinY4;
25
26         public GUIor_4(ViewModelModifiable model)
27         {
28                 super(model, "GUIor_4");
29                 setSize(40, 80);
30                 setSubmodelScale(.4);
31
32                 Pin A1 = addSubmodelInterface(1, 0, 5);
33                 Pin A2 = addSubmodelInterface(1, 0, 15);
34                 Pin A3 = addSubmodelInterface(1, 0, 25);
35                 Pin A4 = addSubmodelInterface(1, 0, 35);
36                 Pin B1 = addSubmodelInterface(1, 0, 45);
37                 Pin B2 = addSubmodelInterface(1, 0, 55);
38                 Pin B3 = addSubmodelInterface(1, 0, 65);
39                 Pin B4 = addSubmodelInterface(1, 0, 75);
40                 Pin Y1 = addSubmodelInterface(1, 40, 5);
41                 Pin Y2 = addSubmodelInterface(1, 40, 15);
42                 Pin Y3 = addSubmodelInterface(1, 40, 25);
43                 Pin Y4 = addSubmodelInterface(1, 40, 35);
44
45                 this.pinA1 = getSupermodelPin(A1);
46                 this.pinA2 = getSupermodelPin(A2);
47                 this.pinA3 = getSupermodelPin(A3);
48                 this.pinA4 = getSupermodelPin(A4);
49                 this.pinB1 = getSupermodelPin(B1);
50                 this.pinB2 = getSupermodelPin(B2);
51                 this.pinB3 = getSupermodelPin(B3);
52                 this.pinB4 = getSupermodelPin(B4);
53                 this.pinY1 = getSupermodelPin(Y1);
54                 this.pinY2 = getSupermodelPin(Y2);
55                 this.pinY3 = getSupermodelPin(Y3);
56                 this.pinY4 = getSupermodelPin(Y4);
57
58                 initSubmodelComponents(A1, A2, A3, A4, B1, B2, B3, B4, Y1, Y2, Y3, Y4);
59         }
60
61         @SuppressWarnings("unused") // for GUIWires being created
62         private void initSubmodelComponents(Pin A1, Pin A2, Pin A3, Pin A4, Pin B1, Pin B2, Pin B3, Pin B4, Pin Y1, Pin Y2, Pin Y3, Pin Y4)
63         {
64                 GUINandGate notA1 = new GUINandGate(submodelModifiable, 1);
65                 GUINandGate notA2 = new GUINandGate(submodelModifiable, 1);
66                 GUINandGate notA3 = new GUINandGate(submodelModifiable, 1);
67                 GUINandGate notA4 = new GUINandGate(submodelModifiable, 1);
68                 GUINandGate notB1 = new GUINandGate(submodelModifiable, 1);
69                 GUINandGate notB2 = new GUINandGate(submodelModifiable, 1);
70                 GUINandGate notB3 = new GUINandGate(submodelModifiable, 1);
71                 GUINandGate notB4 = new GUINandGate(submodelModifiable, 1);
72                 GUINandGate nandY1 = new GUINandGate(submodelModifiable, 1);
73                 GUINandGate nandY2 = new GUINandGate(submodelModifiable, 1);
74                 GUINandGate nandY3 = new GUINandGate(submodelModifiable, 1);
75                 GUINandGate nandY4 = new GUINandGate(submodelModifiable, 1);
76
77                 WireCrossPoint cpA1 = new WireCrossPoint(submodelModifiable, 1);
78                 WireCrossPoint cpA2 = new WireCrossPoint(submodelModifiable, 1);
79                 WireCrossPoint cpA3 = new WireCrossPoint(submodelModifiable, 1);
80                 WireCrossPoint cpA4 = new WireCrossPoint(submodelModifiable, 1);
81                 WireCrossPoint cpB1 = new WireCrossPoint(submodelModifiable, 1);
82                 WireCrossPoint cpB2 = new WireCrossPoint(submodelModifiable, 1);
83                 WireCrossPoint cpB3 = new WireCrossPoint(submodelModifiable, 1);
84                 WireCrossPoint cpB4 = new WireCrossPoint(submodelModifiable, 1);
85
86                 notA1.moveTo(15, 2.5);
87                 notA2.moveTo(15, 27.5);
88                 notA3.moveTo(15, 52.5);
89                 notA4.moveTo(15, 77.5);
90                 notB1.moveTo(15, 102.5);
91                 notB2.moveTo(15, 127.5);
92                 notB3.moveTo(15, 152.5);
93                 notB4.moveTo(15, 177.5);
94                 nandY1.moveTo(70, 2.5);
95                 nandY2.moveTo(70, 27.5);
96                 nandY3.moveTo(70, 52.5);
97                 nandY4.moveTo(70, 77.5);
98                 cpA1.moveTo(7.5, 12.5);
99                 cpA2.moveTo(7.5, 37.5);
100                 cpA3.moveTo(7.5, 62.5);
101                 cpA4.moveTo(7.5, 87.5);
102                 cpB1.moveTo(7.5, 112.5);
103                 cpB2.moveTo(7.5, 137.5);
104                 cpB3.moveTo(7.5, 162.5);
105                 cpB4.moveTo(7.5, 187.5);
106
107                 new GUIWire(submodelModifiable, A1, cpA1.getPin());
108                 new GUIWire(submodelModifiable, A2, cpA2.getPin());
109                 new GUIWire(submodelModifiable, A3, cpA3.getPin());
110                 new GUIWire(submodelModifiable, A4, cpA4.getPin());
111                 new GUIWire(submodelModifiable, B1, cpB1.getPin());
112                 new GUIWire(submodelModifiable, B2, cpB2.getPin());
113                 new GUIWire(submodelModifiable, B3, cpB3.getPin());
114                 new GUIWire(submodelModifiable, B4, cpB4.getPin());
115                 new GUIWire(submodelModifiable, cpA1.getPin(), notA1.getInputPins().get(0), new Point(7.5, 7.5));
116                 new GUIWire(submodelModifiable, cpA1.getPin(), notA1.getInputPins().get(1), new Point(7.5, 17.5));
117                 new GUIWire(submodelModifiable, cpA2.getPin(), notA2.getInputPins().get(0), new Point(7.5, 32.5));
118                 new GUIWire(submodelModifiable, cpA2.getPin(), notA2.getInputPins().get(1), new Point(7.5, 42.5));
119                 new GUIWire(submodelModifiable, cpA3.getPin(), notA3.getInputPins().get(0), new Point(7.5, 57.5));
120                 new GUIWire(submodelModifiable, cpA3.getPin(), notA3.getInputPins().get(1), new Point(7.5, 67.5));
121                 new GUIWire(submodelModifiable, cpA4.getPin(), notA4.getInputPins().get(0), new Point(7.5, 82.5));
122                 new GUIWire(submodelModifiable, cpA4.getPin(), notA4.getInputPins().get(1), new Point(7.5, 92.5));
123                 new GUIWire(submodelModifiable, cpB1.getPin(), notB1.getInputPins().get(0), new Point(7.5, 107.5));
124                 new GUIWire(submodelModifiable, cpB1.getPin(), notB1.getInputPins().get(1), new Point(7.5, 117.5));
125                 new GUIWire(submodelModifiable, cpB2.getPin(), notB2.getInputPins().get(0), new Point(7.5, 132.5));
126                 new GUIWire(submodelModifiable, cpB2.getPin(), notB2.getInputPins().get(1), new Point(7.5, 142.5));
127                 new GUIWire(submodelModifiable, cpB3.getPin(), notB3.getInputPins().get(0), new Point(7.5, 157.5));
128                 new GUIWire(submodelModifiable, cpB3.getPin(), notB3.getInputPins().get(1), new Point(7.5, 167.5));
129                 new GUIWire(submodelModifiable, cpB4.getPin(), notB4.getInputPins().get(0), new Point(7.5, 182.5));
130                 new GUIWire(submodelModifiable, cpB4.getPin(), notB4.getInputPins().get(1), new Point(7.5, 192.5));
131                 new GUIWire(submodelModifiable, notA1.getOutputPin(), nandY1.getInputPins().get(0), new Point(40, 12.5), new Point(40, 7.5));
132                 new GUIWire(submodelModifiable, notB1.getOutputPin(), nandY1.getInputPins().get(1), new Point(50, 112.5), new Point(50, 17.5));
133                 new GUIWire(submodelModifiable, notA2.getOutputPin(), nandY2.getInputPins().get(0), new Point(40, 37.5), new Point(40, 32.5));
134                 new GUIWire(submodelModifiable, notB2.getOutputPin(), nandY2.getInputPins().get(1), new Point(55, 137.5), new Point(55, 42.5));
135                 new GUIWire(submodelModifiable, notA3.getOutputPin(), nandY3.getInputPins().get(0), new Point(40, 62.5), new Point(40, 57.5));
136                 new GUIWire(submodelModifiable, notB3.getOutputPin(), nandY3.getInputPins().get(1), new Point(60, 162.5), new Point(60, 67.5));
137                 new GUIWire(submodelModifiable, notA4.getOutputPin(), nandY4.getInputPins().get(0), new Point(40, 87.5), new Point(40, 82.5));
138                 new GUIWire(submodelModifiable, notB4.getOutputPin(), nandY4.getInputPins().get(1), new Point(65, 187.5), new Point(65, 92.5));
139                 new GUIWire(submodelModifiable, nandY1.getOutputPin(), Y1);
140                 new GUIWire(submodelModifiable, nandY2.getOutputPin(), Y2);
141                 new GUIWire(submodelModifiable, nandY3.getOutputPin(), Y3);
142                 new GUIWire(submodelModifiable, nandY4.getOutputPin(), Y4);
143         }
144
145         public Pin getPinA1()
146         {
147                 return pinA1;
148         }
149
150         public Pin getPinA2()
151         {
152                 return pinA2;
153         }
154
155         public Pin getPinA3()
156         {
157                 return pinA3;
158         }
159
160         public Pin getPinA4()
161         {
162                 return pinA4;
163         }
164
165         public Pin getPinB1()
166         {
167                 return pinB1;
168         }
169
170         public Pin getPinB2()
171         {
172                 return pinB2;
173         }
174
175         public Pin getPinB3()
176         {
177                 return pinB3;
178         }
179
180         public Pin getPinB4()
181         {
182                 return pinB4;
183         }
184
185         public Pin getPinY1()
186         {
187                 return pinY1;
188         }
189
190         public Pin getPinY2()
191         {
192                 return pinY2;
193         }
194
195         public Pin getPinY3()
196         {
197                 return pinY3;
198         }
199
200         public Pin getPinY4()
201         {
202                 return pinY4;
203         }
204 }