Updated to new SWTHelper version
[Mograsim.git] / net.mograsim.logic.ui.am2900 / 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.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 GUImux1 extends SimpleRectangularSubmodelComponent
13 {
14         public GUImux1(ViewModelModifiable model)
15         {
16                 this(model, null);
17         }
18
19         public GUImux1(ViewModelModifiable model, String name)
20         {
21                 super(model, 1, "GUImux1", name);
22                 setSubmodelScale(.4);
23                 setInputPins("S0", "I0", "I1");
24                 setOutputPins("Y");
25                 initSubmodelComponents();
26         }
27
28         @SuppressWarnings("unused")
29         private void initSubmodelComponents()
30         {
31                 Pin S0 = getSubmodelPin("S0");
32                 Pin I0 = getSubmodelPin("I0");
33                 Pin I1 = getSubmodelPin("I1");
34                 Pin Y = getSubmodelPin("Y");
35
36                 GUINandGate nandS0 = new GUINandGate(submodelModifiable, 1);
37                 GUINandGate nandI0 = new GUINandGate(submodelModifiable, 1);
38                 GUINandGate nandI1 = new GUINandGate(submodelModifiable, 1);
39                 GUINandGate nandY = new GUINandGate(submodelModifiable, 1);
40
41                 WireCrossPoint cp0 = new WireCrossPoint(submodelModifiable, 1);
42                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
43
44                 nandS0.moveTo(10, 7.5);
45                 nandI0.moveTo(35, 22.5);
46                 nandI1.moveTo(35, 47.5);
47                 nandY.moveTo(60, 30);
48                 cp0.moveCenterTo(5, 12.5);
49                 cp1.moveCenterTo(5, 22.5);
50
51                 new GUIWire(submodelModifiable, S0, cp0, new Point[0]);
52                 new GUIWire(submodelModifiable, cp0, nandS0.getPin("A"), new Point[0]);
53                 new GUIWire(submodelModifiable, cp0, cp1, new Point[0]);
54                 new GUIWire(submodelModifiable, cp1, nandS0.getPin("B"), new Point[0]);
55                 new GUIWire(submodelModifiable, nandS0.getPin("Y"), nandI0.getPin("A"));
56                 new GUIWire(submodelModifiable, I0, nandI0.getPin("B"), new Point[0]);
57                 new GUIWire(submodelModifiable, cp1, nandI1.getPin("A"), new Point(5, 52.5));
58                 new GUIWire(submodelModifiable, I1, nandI1.getPin("B"), new Point[0]);
59                 new GUIWire(submodelModifiable, nandI0.getPin("Y"), nandY.getPin("A"));
60                 new GUIWire(submodelModifiable, nandI1.getPin("Y"), nandY.getPin("B"));
61                 new GUIWire(submodelModifiable, nandY.getPin("Y"), Y);
62         }
63
64         static
65         {
66                 IndirectGUIComponentCreator.setComponentSupplier(GUImux1.class.getCanonicalName(), (m, p, n) -> new GUImux1(m, n));
67         }
68 }