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