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 GUIor4 extends SimpleRectangularSubmodelComponent
14 public GUIor4(ViewModelModifiable model)
16 super(model, 1, "GUIor4");
18 setInputPins("A1", "A2", "A3", "A4");
20 initSubmodelComponents();
23 @SuppressWarnings("unused") // for GUIWires being created
24 private void initSubmodelComponents()
26 Pin A1 = getSubmodelPin("A1");
27 Pin A2 = getSubmodelPin("A2");
28 Pin A3 = getSubmodelPin("A3");
29 Pin A4 = getSubmodelPin("A4");
30 Pin Y = getSubmodelPin("Y");
32 GUINandGate nandA1 = new GUINandGate(submodelModifiable, 1);
33 GUINandGate nandA2 = new GUINandGate(submodelModifiable, 1);
34 GUINandGate nandA3 = new GUINandGate(submodelModifiable, 1);
35 GUINandGate nandA4 = new GUINandGate(submodelModifiable, 1);
36 GUINandGate or12 = new GUINandGate(submodelModifiable, 1);
37 GUINandGate or34 = new GUINandGate(submodelModifiable, 1);
38 GUINandGate nor12 = new GUINandGate(submodelModifiable, 1);
39 GUINandGate nor34 = new GUINandGate(submodelModifiable, 1);
40 GUINandGate or1234 = new GUINandGate(submodelModifiable, 1);
42 WireCrossPoint cpA1 = new WireCrossPoint(submodelModifiable, 1);
43 WireCrossPoint cpA2 = new WireCrossPoint(submodelModifiable, 1);
44 WireCrossPoint cpA3 = new WireCrossPoint(submodelModifiable, 1);
45 WireCrossPoint cpA4 = new WireCrossPoint(submodelModifiable, 1);
46 WireCrossPoint cpOr12 = new WireCrossPoint(submodelModifiable, 1);
47 WireCrossPoint cpOr34 = new WireCrossPoint(submodelModifiable, 1);
49 nandA1.moveTo(20, 15);
50 nandA2.moveTo(20, 65);
51 nandA3.moveTo(20, 115);
52 nandA4.moveTo(20, 165);
55 nor12.moveTo(110, 40);
56 nor34.moveTo(110, 140);
57 or1234.moveTo(140, 90);
58 cpA1.moveCenterTo(15, 25);
59 cpA2.moveCenterTo(15, 75);
60 cpA3.moveCenterTo(15, 125);
61 cpA4.moveCenterTo(15, 175);
62 cpOr12.moveCenterTo(105, 50);
63 cpOr34.moveCenterTo(105, 150);
65 new GUIWire(submodelModifiable, A1, cpA1, new Point[0]);
66 new GUIWire(submodelModifiable, A2, cpA2, new Point[0]);
67 new GUIWire(submodelModifiable, A3, cpA3, new Point[0]);
68 new GUIWire(submodelModifiable, A4, cpA4, new Point[0]);
69 new GUIWire(submodelModifiable, cpA1, nandA1.getPin("A"), new Point(15, 20));
70 new GUIWire(submodelModifiable, cpA2, nandA2.getPin("A"), new Point(15, 70));
71 new GUIWire(submodelModifiable, cpA3, nandA3.getPin("A"), new Point(15, 120));
72 new GUIWire(submodelModifiable, cpA4, nandA4.getPin("A"), new Point(15, 170));
73 new GUIWire(submodelModifiable, cpA1, nandA1.getPin("B"), new Point(15, 30));
74 new GUIWire(submodelModifiable, cpA2, nandA2.getPin("B"), new Point(15, 80));
75 new GUIWire(submodelModifiable, cpA3, nandA3.getPin("B"), new Point(15, 130));
76 new GUIWire(submodelModifiable, cpA4, nandA4.getPin("B"), new Point(15, 180));
77 new GUIWire(submodelModifiable, nandA1.getPin("Y"), or12.getPin("A"));
78 new GUIWire(submodelModifiable, nandA2.getPin("Y"), or12.getPin("B"));
79 new GUIWire(submodelModifiable, nandA3.getPin("Y"), or34.getPin("A"));
80 new GUIWire(submodelModifiable, nandA4.getPin("Y"), or34.getPin("B"));
81 new GUIWire(submodelModifiable, or12.getPin("Y"), cpOr12, new Point[0]);
82 new GUIWire(submodelModifiable, or34.getPin("Y"), cpOr34, new Point[0]);
83 new GUIWire(submodelModifiable, cpOr12, nor12.getPin("A"), new Point(105, 45));
84 new GUIWire(submodelModifiable, cpOr12, nor12.getPin("B"), new Point(105, 55));
85 new GUIWire(submodelModifiable, cpOr34, nor34.getPin("A"), new Point(105, 145));
86 new GUIWire(submodelModifiable, cpOr34, nor34.getPin("B"), new Point(105, 155));
87 new GUIWire(submodelModifiable, nor12.getPin("Y"), or1234.getPin("A"));
88 new GUIWire(submodelModifiable, nor34.getPin("Y"), or1234.getPin("B"));
89 new GUIWire(submodelModifiable, or1234.getPin("Y"), Y);
94 IndirectGUIComponentCreator.setComponentSupplier(GUIor4.class.getCanonicalName(), (m, p) -> new GUIor4(m));