Pins are now accessed via name, not index
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUImux1.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 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
10
11 public class GUImux1 extends SimpleRectangularSubmodelComponent
12 {
13         public GUImux1(ViewModelModifiable model)
14         {
15                 super(model, 1, "GUImux1");
16                 setSubmodelScale(.4);
17                 setInputPins("S0", "I0", "I1");
18                 setOutputPins("Y");
19                 initSubmodelComponents();
20         }
21
22         @SuppressWarnings("unused")
23         private void initSubmodelComponents()
24         {
25                 Pin S0 = getSubmodelPin("S0");
26                 Pin I0 = getSubmodelPin("I0");
27                 Pin I1 = getSubmodelPin("I1");
28                 Pin Y = getSubmodelPin("Y");
29
30                 GUINandGate nandS0 = new GUINandGate(submodelModifiable, 1);
31                 GUINandGate nandI0 = new GUINandGate(submodelModifiable, 1);
32                 GUINandGate nandI1 = new GUINandGate(submodelModifiable, 1);
33                 GUINandGate nandY = new GUINandGate(submodelModifiable, 1);
34
35                 WireCrossPoint cp0 = new WireCrossPoint(submodelModifiable, 1);
36                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
37
38                 nandS0.moveTo(10, 7.5);
39                 nandI0.moveTo(35, 22.5);
40                 nandI1.moveTo(35, 47.5);
41                 nandY.moveTo(60, 30);
42                 cp0.moveCenterTo(5, 12.5);
43                 cp1.moveCenterTo(5, 22.5);
44
45                 new GUIWire(submodelModifiable, S0, cp0, new Point[0]);
46                 new GUIWire(submodelModifiable, cp0, nandS0.getPin("A"), new Point[0]);
47                 new GUIWire(submodelModifiable, cp0, cp1, new Point[0]);
48                 new GUIWire(submodelModifiable, cp1, nandS0.getPin("B"), new Point[0]);
49                 new GUIWire(submodelModifiable, nandS0.getPin("Y"), nandI0.getPin("A"));
50                 new GUIWire(submodelModifiable, I0, nandI0.getPin("B"), new Point[0]);
51                 new GUIWire(submodelModifiable, cp1, nandI1.getPin("A"), new Point(5, 52.5));
52                 new GUIWire(submodelModifiable, I1, nandI1.getPin("B"), new Point[0]);
53                 new GUIWire(submodelModifiable, nandI0.getPin("Y"), nandY.getPin("A"));
54                 new GUIWire(submodelModifiable, nandI1.getPin("Y"), nandY.getPin("B"));
55                 new GUIWire(submodelModifiable, nandY.getPin("Y"), Y);
56         }
57 }