Added DeserializedSubmodelComponent Editor project
[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                 super(model, 1, "GUImux1");
17                 setSubmodelScale(.4);
18                 setInputPins("S0", "I0", "I1");
19                 setOutputPins("Y");
20                 initSubmodelComponents();
21         }
22
23         @SuppressWarnings("unused")
24         private void initSubmodelComponents()
25         {
26                 Pin S0 = getSubmodelPin("S0");
27                 Pin I0 = getSubmodelPin("I0");
28                 Pin I1 = getSubmodelPin("I1");
29                 Pin Y = getSubmodelPin("Y");
30
31                 GUINandGate nandS0 = new GUINandGate(submodelModifiable, 1);
32                 GUINandGate nandI0 = new GUINandGate(submodelModifiable, 1);
33                 GUINandGate nandI1 = new GUINandGate(submodelModifiable, 1);
34                 GUINandGate nandY = new GUINandGate(submodelModifiable, 1);
35
36                 WireCrossPoint cp0 = new WireCrossPoint(submodelModifiable, 1);
37                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
38
39                 nandS0.moveTo(10, 7.5);
40                 nandI0.moveTo(35, 22.5);
41                 nandI1.moveTo(35, 47.5);
42                 nandY.moveTo(60, 30);
43                 cp0.moveCenterTo(5, 12.5);
44                 cp1.moveCenterTo(5, 22.5);
45
46                 new GUIWire(submodelModifiable, S0, cp0, new Point[0]);
47                 new GUIWire(submodelModifiable, cp0, nandS0.getPin("A"), new Point[0]);
48                 new GUIWire(submodelModifiable, cp0, cp1, new Point[0]);
49                 new GUIWire(submodelModifiable, cp1, nandS0.getPin("B"), new Point[0]);
50                 new GUIWire(submodelModifiable, nandS0.getPin("Y"), nandI0.getPin("A"));
51                 new GUIWire(submodelModifiable, I0, nandI0.getPin("B"), new Point[0]);
52                 new GUIWire(submodelModifiable, cp1, nandI1.getPin("A"), new Point(5, 52.5));
53                 new GUIWire(submodelModifiable, I1, nandI1.getPin("B"), new Point[0]);
54                 new GUIWire(submodelModifiable, nandI0.getPin("Y"), nandY.getPin("A"));
55                 new GUIWire(submodelModifiable, nandI1.getPin("Y"), nandY.getPin("B"));
56                 new GUIWire(submodelModifiable, nandY.getPin("Y"), Y);
57         }
58
59         static
60         {
61                 IndirectGUIComponentCreator.setComponentProvider(GUImux1.class.getCanonicalName(), (m, p) -> new GUImux1(m));
62         }
63 }