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 GUIxor extends SimpleRectangularSubmodelComponent
14 public GUIxor(ViewModelModifiable model)
16 super(model, 1, "GUIxor");
18 setInputPins("A", "B");
20 initSubmodelComponents();
23 @SuppressWarnings("unused") // for GUIWires being created
24 private void initSubmodelComponents()
26 Pin A = getSubmodelPin("A");
27 Pin B = getSubmodelPin("B");
28 Pin Y = getSubmodelPin("Y");
30 GUINandGate nandAB = new GUINandGate(submodelModifiable, 1);
31 GUINandGate nandYA = new GUINandGate(submodelModifiable, 1);
32 GUINandGate nandYB = new GUINandGate(submodelModifiable, 1);
33 GUINandGate nandY = new GUINandGate(submodelModifiable, 1);
35 WireCrossPoint cpA = new WireCrossPoint(submodelModifiable, 1);
36 WireCrossPoint cpB = new WireCrossPoint(submodelModifiable, 1);
37 WireCrossPoint cpAB = new WireCrossPoint(submodelModifiable, 1);
39 nandAB.moveTo(7.5, 15);
40 nandYA.moveTo(35, 2.5);
41 nandYB.moveTo(35, 27.5);
42 nandY.moveTo(62.5, 15);
43 cpA.moveCenterTo(5, 12.5);
44 cpB.moveCenterTo(5, 37.5);
45 cpAB.moveCenterTo(30, 25);
47 new GUIWire(submodelModifiable, A, cpA, new Point[0]);
48 new GUIWire(submodelModifiable, B, cpB, new Point[0]);
49 new GUIWire(submodelModifiable, cpA, nandAB.getPin("A"), new Point(5, 20));
50 new GUIWire(submodelModifiable, cpB, nandAB.getPin("B"), new Point(5, 30));
51 new GUIWire(submodelModifiable, nandAB.getPin("Y"), cpAB);
52 new GUIWire(submodelModifiable, cpAB, nandYA.getPin("B"), new Point(30, 17.5));
53 new GUIWire(submodelModifiable, cpAB, nandYB.getPin("A"), new Point(30, 32.5));
54 new GUIWire(submodelModifiable, cpA, nandYA.getPin("A"), new Point(5, 7.5));
55 new GUIWire(submodelModifiable, cpB, nandYB.getPin("B"), new Point(5, 42.5));
56 new GUIWire(submodelModifiable, nandYA.getPin("Y"), nandY.getPin("A"));
57 new GUIWire(submodelModifiable, nandYB.getPin("Y"), nandY.getPin("B"));
58 new GUIWire(submodelModifiable, nandY.getPin("Y"), Y);
63 IndirectGUIComponentCreator.setComponentProvider(GUIxor.class.getCanonicalName(), (m, p) -> new GUIxor(m));