GUIComponents now have names
[Mograsim.git] / net.mograsim.logic.ui.am2900 / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIsel2_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.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 GUIsel2_4 extends SimpleRectangularSubmodelComponent
13 {
14         public GUIsel2_4(ViewModelModifiable model)
15         {
16                 this(model, null);
17         }
18
19         public GUIsel2_4(ViewModelModifiable model, String name)
20         {
21                 super(model, 1, "GUIsel2_4", name);
22                 setSubmodelScale(.4);
23                 setInputPins("SA", "SB", "A1", "A2", "A3", "A4", "B1", "B2", "B3", "B4");
24                 setOutputPins("Y1", "Y2", "Y3", "Y4");
25                 initSubmodelComponents();
26         }
27
28         @SuppressWarnings("unused") // for GUIWires being created
29         private void initSubmodelComponents()
30         {
31                 Pin SA = getSubmodelPin("SA");
32                 Pin SB = getSubmodelPin("SB");
33                 Pin A1 = getSubmodelPin("A1");
34                 Pin A2 = getSubmodelPin("A2");
35                 Pin A3 = getSubmodelPin("A3");
36                 Pin A4 = getSubmodelPin("A4");
37                 Pin B1 = getSubmodelPin("B1");
38                 Pin B2 = getSubmodelPin("B2");
39                 Pin B3 = getSubmodelPin("B3");
40                 Pin B4 = getSubmodelPin("B4");
41                 Pin Y1 = getSubmodelPin("Y1");
42                 Pin Y2 = getSubmodelPin("Y2");
43                 Pin Y3 = getSubmodelPin("Y3");
44                 Pin Y4 = getSubmodelPin("Y4");
45
46                 GUINandGate nandA1 = new GUINandGate(submodelModifiable, 1);
47                 GUINandGate nandA2 = new GUINandGate(submodelModifiable, 1);
48                 GUINandGate nandA3 = new GUINandGate(submodelModifiable, 1);
49                 GUINandGate nandA4 = new GUINandGate(submodelModifiable, 1);
50                 GUINandGate nandB1 = new GUINandGate(submodelModifiable, 1);
51                 GUINandGate nandB2 = new GUINandGate(submodelModifiable, 1);
52                 GUINandGate nandB3 = new GUINandGate(submodelModifiable, 1);
53                 GUINandGate nandB4 = new GUINandGate(submodelModifiable, 1);
54                 GUINandGate nandY1 = new GUINandGate(submodelModifiable, 1);
55                 GUINandGate nandY2 = new GUINandGate(submodelModifiable, 1);
56                 GUINandGate nandY3 = new GUINandGate(submodelModifiable, 1);
57                 GUINandGate nandY4 = new GUINandGate(submodelModifiable, 1);
58
59                 WireCrossPoint cpA1 = new WireCrossPoint(submodelModifiable, 1);
60                 WireCrossPoint cpA2 = new WireCrossPoint(submodelModifiable, 1);
61                 WireCrossPoint cpA3 = new WireCrossPoint(submodelModifiable, 1);
62                 WireCrossPoint cpB1 = new WireCrossPoint(submodelModifiable, 1);
63                 WireCrossPoint cpB2 = new WireCrossPoint(submodelModifiable, 1);
64                 WireCrossPoint cpB3 = new WireCrossPoint(submodelModifiable, 1);
65
66                 nandA1.moveTo(20, 2.5);
67                 nandB1.moveTo(20, 27.5);
68                 nandA2.moveTo(20, 52.5);
69                 nandB2.moveTo(20, 77.5);
70                 nandA3.moveTo(20, 102.5);
71                 nandB3.moveTo(20, 127.5);
72                 nandA4.moveTo(20, 152.5);
73                 nandB4.moveTo(20, 177.5);
74                 nandY1.moveTo(65, 2.5);
75                 nandY2.moveTo(65, 27.5);
76                 nandY3.moveTo(65, 52.5);
77                 nandY4.moveTo(65, 77.5);
78                 cpA1.moveCenterTo(7.5, 17.5);
79                 cpB1.moveCenterTo(5, 42.5);
80                 cpA2.moveCenterTo(7.5, 67.5);
81                 cpB2.moveCenterTo(5, 92.5);
82                 cpA3.moveCenterTo(7.5, 117.5);
83                 cpB3.moveCenterTo(5, 142.5);
84
85                 new GUIWire(submodelModifiable, A1, nandA1.getPin("A"), new Point(15, 62.5), new Point(15, 7.5));
86                 new GUIWire(submodelModifiable, A2, nandA2.getPin("A"), new Point(17.5, 87.5), new Point(17.5, 57.5));
87                 new GUIWire(submodelModifiable, A3, nandA3.getPin("A"), new Point(17.5, 112.5), new Point(17.5, 107.5));
88                 new GUIWire(submodelModifiable, A4, nandA4.getPin("A"), new Point(17.5, 137.5), new Point(17.5, 157.5));
89                 new GUIWire(submodelModifiable, B1, nandB1.getPin("A"), new Point(10, 162.5), new Point(10, 32.5));
90                 new GUIWire(submodelModifiable, B2, nandB2.getPin("A"), new Point(12.5, 187.5), new Point(12.5, 82.5));
91                 new GUIWire(submodelModifiable, B3, nandB3.getPin("A"), new Point(15, 212.5), new Point(15, 132.5));
92                 new GUIWire(submodelModifiable, B4, nandB4.getPin("A"), new Point(10, 237.5), new Point(10, 182.5));
93                 new GUIWire(submodelModifiable, SA, cpA1);
94                 new GUIWire(submodelModifiable, SB, cpB1);
95                 new GUIWire(submodelModifiable, cpA1, cpA2);
96                 new GUIWire(submodelModifiable, cpA1, nandA1.getPin("B"));
97                 new GUIWire(submodelModifiable, cpA2, cpA3);
98                 new GUIWire(submodelModifiable, cpA2, nandA2.getPin("B"));
99                 new GUIWire(submodelModifiable, cpA3, nandA3.getPin("B"));
100                 new GUIWire(submodelModifiable, cpA3, nandA4.getPin("B"), new Point(7.5, 167.5));
101                 new GUIWire(submodelModifiable, cpB1, cpB2);
102                 new GUIWire(submodelModifiable, cpB1, nandB1.getPin("B"));
103                 new GUIWire(submodelModifiable, cpB2, cpB3);
104                 new GUIWire(submodelModifiable, cpB2, nandB2.getPin("B"));
105                 new GUIWire(submodelModifiable, cpB3, nandB3.getPin("B"));
106                 new GUIWire(submodelModifiable, cpB3, nandB4.getPin("B"), new Point(5, 192.5));
107                 new GUIWire(submodelModifiable, nandA1.getPin("Y"), nandY1.getPin("A"), new Point(42.5, 12.5), new Point(42.5, 7.5));
108                 new GUIWire(submodelModifiable, nandB1.getPin("Y"), nandY1.getPin("B"), new Point(45, 37.5), new Point(45, 17.5));
109                 new GUIWire(submodelModifiable, nandA2.getPin("Y"), nandY2.getPin("A"), new Point(47.5, 62.5), new Point(47.5, 32.5));
110                 new GUIWire(submodelModifiable, nandB2.getPin("Y"), nandY2.getPin("B"), new Point(50, 87.5), new Point(50, 42.5));
111                 new GUIWire(submodelModifiable, nandA3.getPin("Y"), nandY3.getPin("A"), new Point(52.5, 112.5), new Point(52.5, 57.5));
112                 new GUIWire(submodelModifiable, nandB3.getPin("Y"), nandY3.getPin("B"), new Point(55, 137.5), new Point(55, 67.5));
113                 new GUIWire(submodelModifiable, nandA4.getPin("Y"), nandY4.getPin("A"), new Point(57.5, 162.5), new Point(57.5, 82.5));
114                 new GUIWire(submodelModifiable, nandB4.getPin("Y"), nandY4.getPin("B"), new Point(60, 187.5), new Point(60, 92.5));
115                 new GUIWire(submodelModifiable, nandY1.getPin("Y"), Y1, new Point[0]);
116                 new GUIWire(submodelModifiable, nandY2.getPin("Y"), Y2, new Point[0]);
117                 new GUIWire(submodelModifiable, nandY3.getPin("Y"), Y3, new Point[0]);
118                 new GUIWire(submodelModifiable, nandY4.getPin("Y"), Y4, new Point[0]);
119         }
120
121         static
122         {
123                 IndirectGUIComponentCreator.setComponentSupplier(GUIsel2_4.class.getCanonicalName(), (m, p, n) -> new GUIsel2_4(m, n));
124         }
125 }