Renamed logic.ui to logic.model
[Mograsim.git] / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / model / components / mi / nandbased / GUIdemux2.java
1 package net.mograsim.logic.model.model.components.mi.nandbased;
2
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.model.model.ViewModelModifiable;
5 import net.mograsim.logic.model.model.components.atomic.GUINandGate;
6 import net.mograsim.logic.model.model.components.submodels.SimpleRectangularSubmodelComponent;
7 import net.mograsim.logic.model.model.wires.GUIWire;
8 import net.mograsim.logic.model.model.wires.Pin;
9 import net.mograsim.logic.model.model.wires.WireCrossPoint;
10 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
11
12 public class GUIdemux2 extends SimpleRectangularSubmodelComponent
13 {
14         public GUIdemux2(ViewModelModifiable model)
15         {
16                 this(model, null);
17         }
18
19         public GUIdemux2(ViewModelModifiable model, String name)
20         {
21                 super(model, 1, "GUIdemux2", name);
22                 setSubmodelScale(.4);
23                 setInputPins("S0", "S1");
24                 setOutputPins("Y00", "Y01", "Y10", "Y11");
25                 initSubmodelComponents();
26         }
27
28         @SuppressWarnings("unused") // for GUIWires being created
29         private void initSubmodelComponents()
30         {
31                 Pin S0 = getSubmodelPin("S0");
32                 Pin S1 = getSubmodelPin("S1");
33                 Pin Y00 = getSubmodelPin("Y00");
34                 Pin Y01 = getSubmodelPin("Y01");
35                 Pin Y10 = getSubmodelPin("Y10");
36                 Pin Y11 = getSubmodelPin("Y11");
37
38                 GUINandGate notS0 = new GUINandGate(submodelModifiable, 1);
39                 GUINandGate notS1 = new GUINandGate(submodelModifiable, 1);
40                 GUIand andY00 = new GUIand(submodelModifiable);
41                 GUIand andY01 = new GUIand(submodelModifiable);
42                 GUIand andY10 = new GUIand(submodelModifiable);
43                 GUIand andY11 = new GUIand(submodelModifiable);
44
45                 WireCrossPoint cpS01 = new WireCrossPoint(submodelModifiable, 1);
46                 WireCrossPoint cpS02 = new WireCrossPoint(submodelModifiable, 1);
47                 WireCrossPoint cpS03 = new WireCrossPoint(submodelModifiable, 1);
48                 WireCrossPoint cpS11 = new WireCrossPoint(submodelModifiable, 1);
49                 WireCrossPoint cpS12 = new WireCrossPoint(submodelModifiable, 1);
50                 WireCrossPoint cpS13 = new WireCrossPoint(submodelModifiable, 1);
51                 WireCrossPoint cpNotS0 = new WireCrossPoint(submodelModifiable, 1);
52                 WireCrossPoint cpNotS1 = new WireCrossPoint(submodelModifiable, 1);
53
54                 notS0.moveTo(10, 2.5);
55                 notS1.moveTo(10, 27.5);
56                 andY00.moveTo(40, 2.5);
57                 andY01.moveTo(40, 27.5);
58                 andY10.moveTo(40, 52.5);
59                 andY11.moveTo(40, 77.5);
60                 cpS01.moveCenterTo(7.5, 12.5);
61                 cpS11.moveCenterTo(5, 37.5);
62                 cpS02.moveCenterTo(7.5, 17.5);
63                 cpS12.moveCenterTo(5, 42.5);
64                 cpS03.moveCenterTo(37.5, 62.5);
65                 cpS13.moveCenterTo(32.5, 67.5);
66                 cpNotS0.moveCenterTo(32.5, 12.5);
67                 cpNotS1.moveCenterTo(35, 37.5);
68
69                 new GUIWire(submodelModifiable, S0, cpS01, new Point[0]);
70                 new GUIWire(submodelModifiable, S1, cpS11, new Point[0]);
71                 new GUIWire(submodelModifiable, cpS01, notS0.getPin("A"), new Point(7.5, 7.5));
72                 new GUIWire(submodelModifiable, cpS11, notS1.getPin("A"), new Point(5, 32.5));
73                 new GUIWire(submodelModifiable, cpS01, cpS02, new Point[0]);
74                 new GUIWire(submodelModifiable, cpS11, cpS12, new Point[0]);
75                 new GUIWire(submodelModifiable, cpS02, notS0.getPin("B"), new Point[0]);
76                 new GUIWire(submodelModifiable, cpS12, notS1.getPin("B"), new Point[0]);
77                 new GUIWire(submodelModifiable, cpS02, cpS03, new Point(7.5, 62.5));
78                 new GUIWire(submodelModifiable, cpS12, cpS13, new Point(5, 67.5), new Point(32.5, 67.5));
79                 new GUIWire(submodelModifiable, notS0.getPin("Y"), cpNotS0, new Point[0]);
80                 new GUIWire(submodelModifiable, notS1.getPin("Y"), cpNotS1, new Point[0]);
81                 new GUIWire(submodelModifiable, cpNotS0, andY00.getPin("A"), new Point(32.5, 7.5));
82                 new GUIWire(submodelModifiable, cpNotS1, andY00.getPin("B"), new Point(35, 17.5));
83                 new GUIWire(submodelModifiable, cpS03, andY01.getPin("A"), new Point(37.5, 32.5));
84                 new GUIWire(submodelModifiable, cpNotS1, andY01.getPin("B"), new Point(35, 42.5));
85                 new GUIWire(submodelModifiable, cpNotS0, andY10.getPin("A"), new Point(32.5, 57.5));
86                 new GUIWire(submodelModifiable, cpS13, andY10.getPin("B"), new Point[0]);
87                 new GUIWire(submodelModifiable, cpS03, andY11.getPin("A"), new Point(37.5, 82.5));
88                 new GUIWire(submodelModifiable, cpS13, andY11.getPin("B"), new Point(32.5, 92.5));
89                 new GUIWire(submodelModifiable, andY00.getPin("Y"), Y00);
90                 new GUIWire(submodelModifiable, andY01.getPin("Y"), Y01);
91                 new GUIWire(submodelModifiable, andY10.getPin("Y"), Y10);
92                 new GUIWire(submodelModifiable, andY11.getPin("Y"), Y11);
93         }
94
95         static
96         {
97                 IndirectGUIComponentCreator.setComponentSupplier(GUIdemux2.class.getCanonicalName(), (m, p, n) -> new GUIdemux2(m, n));
98         }
99 }