Changed GUIram2/4's cell order for high level state ID "q"
[Mograsim.git] / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / model / components / mi / nandbased / GUIxor.java
1 package net.mograsim.logic.model.model.components.mi.nandbased;
2
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;
11
12 public class GUIxor extends SimpleRectangularSubmodelComponent
13 {
14         public GUIxor(ViewModelModifiable model)
15         {
16                 this(model, null);
17         }
18
19         public GUIxor(ViewModelModifiable model, String name)
20         {
21                 super(model, 1, "GUIxor", name);
22                 setSubmodelScale(.4);
23                 setInputPins("A", "B");
24                 setOutputPins("Y");
25                 initSubmodelComponents();
26         }
27
28         @SuppressWarnings("unused") // for GUIWires being created
29         private void initSubmodelComponents()
30         {
31                 Pin A = getSubmodelPin("A");
32                 Pin B = getSubmodelPin("B");
33                 Pin Y = getSubmodelPin("Y");
34
35                 GUINandGate nandAB = new GUINandGate(submodelModifiable, 1);
36                 GUINandGate nandYA = new GUINandGate(submodelModifiable, 1);
37                 GUINandGate nandYB = new GUINandGate(submodelModifiable, 1);
38                 GUINandGate nandY = new GUINandGate(submodelModifiable, 1);
39
40                 WireCrossPoint cpA = new WireCrossPoint(submodelModifiable, 1);
41                 WireCrossPoint cpB = new WireCrossPoint(submodelModifiable, 1);
42                 WireCrossPoint cpAB = new WireCrossPoint(submodelModifiable, 1);
43
44                 nandAB.moveTo(7.5, 15);
45                 nandYA.moveTo(35, 2.5);
46                 nandYB.moveTo(35, 27.5);
47                 nandY.moveTo(62.5, 15);
48                 cpA.moveCenterTo(5, 12.5);
49                 cpB.moveCenterTo(5, 37.5);
50                 cpAB.moveCenterTo(30, 25);
51
52                 new GUIWire(submodelModifiable, A, cpA, new Point[0]);
53                 new GUIWire(submodelModifiable, B, cpB, new Point[0]);
54                 new GUIWire(submodelModifiable, cpA, nandAB.getPin("A"), new Point(5, 20));
55                 new GUIWire(submodelModifiable, cpB, nandAB.getPin("B"), new Point(5, 30));
56                 new GUIWire(submodelModifiable, nandAB.getPin("Y"), cpAB);
57                 new GUIWire(submodelModifiable, cpAB, nandYA.getPin("B"), new Point(30, 17.5));
58                 new GUIWire(submodelModifiable, cpAB, nandYB.getPin("A"), new Point(30, 32.5));
59                 new GUIWire(submodelModifiable, cpA, nandYA.getPin("A"), new Point(5, 7.5));
60                 new GUIWire(submodelModifiable, cpB, nandYB.getPin("B"), new Point(5, 42.5));
61                 new GUIWire(submodelModifiable, nandYA.getPin("Y"), nandY.getPin("A"));
62                 new GUIWire(submodelModifiable, nandYB.getPin("Y"), nandY.getPin("B"));
63                 new GUIWire(submodelModifiable, nandY.getPin("Y"), Y);
64         }
65
66         static
67         {
68                 IndirectGUIComponentCreator.setComponentSupplier(GUIxor.class.getCanonicalName(), (m, p, n) -> new GUIxor(m, n));
69         }
70 }