Completely changed the structure and switched to Eclipse Plugin.
[Mograsim.git] / net.mograsim.logic.ui.am2900 / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIdemux2.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 GUIdemux2 extends SimpleRectangularSubmodelComponent
12 {
13         public GUIdemux2(ViewModelModifiable model)
14         {
15                 super(model, 1, "GUIdemux2");
16                 setSubmodelScale(.4);
17                 setInputPins("S0", "S1");
18                 setOutputPins("Y00", "Y01", "Y10", "Y11");
19                 initSubmodelComponents();
20         }
21
22         @SuppressWarnings("unused") // for GUIWires being created
23         private void initSubmodelComponents()
24         {
25                 Pin S0 = getSubmodelPin("S0");
26                 Pin S1 = getSubmodelPin("S1");
27                 Pin Y00 = getSubmodelPin("Y00");
28                 Pin Y01 = getSubmodelPin("Y01");
29                 Pin Y10 = getSubmodelPin("Y10");
30                 Pin Y11 = getSubmodelPin("Y11");
31
32                 GUINandGate notS0 = new GUINandGate(submodelModifiable, 1);
33                 GUINandGate notS1 = new GUINandGate(submodelModifiable, 1);
34                 GUIand andY00 = new GUIand(submodelModifiable);
35                 GUIand andY01 = new GUIand(submodelModifiable);
36                 GUIand andY10 = new GUIand(submodelModifiable);
37                 GUIand andY11 = new GUIand(submodelModifiable);
38
39                 WireCrossPoint cpS01 = new WireCrossPoint(submodelModifiable, 1);
40                 WireCrossPoint cpS02 = new WireCrossPoint(submodelModifiable, 1);
41                 WireCrossPoint cpS03 = new WireCrossPoint(submodelModifiable, 1);
42                 WireCrossPoint cpS11 = new WireCrossPoint(submodelModifiable, 1);
43                 WireCrossPoint cpS12 = new WireCrossPoint(submodelModifiable, 1);
44                 WireCrossPoint cpS13 = new WireCrossPoint(submodelModifiable, 1);
45                 WireCrossPoint cpNotS0 = new WireCrossPoint(submodelModifiable, 1);
46                 WireCrossPoint cpNotS1 = new WireCrossPoint(submodelModifiable, 1);
47
48                 notS0.moveTo(10, 2.5);
49                 notS1.moveTo(10, 27.5);
50                 andY00.moveTo(40, 2.5);
51                 andY01.moveTo(40, 27.5);
52                 andY10.moveTo(40, 52.5);
53                 andY11.moveTo(40, 77.5);
54                 cpS01.moveCenterTo(7.5, 12.5);
55                 cpS11.moveCenterTo(5, 37.5);
56                 cpS02.moveCenterTo(7.5, 17.5);
57                 cpS12.moveCenterTo(5, 42.5);
58                 cpS03.moveCenterTo(37.5, 62.5);
59                 cpS13.moveCenterTo(32.5, 67.5);
60                 cpNotS0.moveCenterTo(32.5, 12.5);
61                 cpNotS1.moveCenterTo(35, 37.5);
62
63                 new GUIWire(submodelModifiable, S0, cpS01, new Point[0]);
64                 new GUIWire(submodelModifiable, S1, cpS11, new Point[0]);
65                 new GUIWire(submodelModifiable, cpS01, notS0.getPin("A"), new Point(7.5, 7.5));
66                 new GUIWire(submodelModifiable, cpS11, notS1.getPin("A"), new Point(5, 32.5));
67                 new GUIWire(submodelModifiable, cpS01, cpS02, new Point[0]);
68                 new GUIWire(submodelModifiable, cpS11, cpS12, new Point[0]);
69                 new GUIWire(submodelModifiable, cpS02, notS0.getPin("B"), new Point[0]);
70                 new GUIWire(submodelModifiable, cpS12, notS1.getPin("B"), new Point[0]);
71                 new GUIWire(submodelModifiable, cpS02, cpS03, new Point(7.5, 62.5));
72                 new GUIWire(submodelModifiable, cpS12, cpS13, new Point(5, 67.5), new Point(32.5, 67.5));
73                 new GUIWire(submodelModifiable, notS0.getPin("Y"), cpNotS0, new Point[0]);
74                 new GUIWire(submodelModifiable, notS1.getPin("Y"), cpNotS1, new Point[0]);
75                 new GUIWire(submodelModifiable, cpNotS0, andY00.getPin("A"), new Point(32.5, 7.5));
76                 new GUIWire(submodelModifiable, cpNotS1, andY00.getPin("B"), new Point(35, 17.5));
77                 new GUIWire(submodelModifiable, cpS03, andY01.getPin("A"), new Point(37.5, 32.5));
78                 new GUIWire(submodelModifiable, cpNotS1, andY01.getPin("B"), new Point(35, 42.5));
79                 new GUIWire(submodelModifiable, cpNotS0, andY10.getPin("A"), new Point(32.5, 57.5));
80                 new GUIWire(submodelModifiable, cpS13, andY10.getPin("B"), new Point[0]);
81                 new GUIWire(submodelModifiable, cpS03, andY11.getPin("A"), new Point(37.5, 82.5));
82                 new GUIWire(submodelModifiable, cpS13, andY11.getPin("B"), new Point(32.5, 92.5));
83                 new GUIWire(submodelModifiable, andY00.getPin("Y"), Y00);
84                 new GUIWire(submodelModifiable, andY01.getPin("Y"), Y01);
85                 new GUIWire(submodelModifiable, andY10.getPin("Y"), Y10);
86                 new GUIWire(submodelModifiable, andY11.getPin("Y"), Y11);
87         }
88 }