1 package net.mograsim.logic.ui.model.components.mi.nandbased;
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;
12 public class GUIdemux2 extends SimpleRectangularSubmodelComponent
14 public GUIdemux2(ViewModelModifiable model)
19 public GUIdemux2(ViewModelModifiable model, String name)
21 super(model, 1, "GUIdemux2", name);
23 setInputPins("S0", "S1");
24 setOutputPins("Y00", "Y01", "Y10", "Y11");
25 initSubmodelComponents();
28 @SuppressWarnings("unused") // for GUIWires being created
29 private void initSubmodelComponents()
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");
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);
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);
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);
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);
97 IndirectGUIComponentCreator.setComponentSupplier(GUIdemux2.class.getCanonicalName(), (m, p, n) -> new GUIdemux2(m, n));