56076cf4100c4467494cf94c3fdd12f7901754f3
[Mograsim.git] / net.mograsim.logic.ui.am2900 / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUInand3.java
1 package net.mograsim.logic.ui.model.components.mi.nandbased;
2
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;
11
12 public class GUInand3 extends SimpleRectangularSubmodelComponent
13 {
14         public GUInand3(ViewModelModifiable model)
15         {
16                 this(model, null);
17         }
18
19         public GUInand3(ViewModelModifiable model, String name)
20         {
21                 super(model, 1, "GUInand3", name);
22                 setSubmodelScale(.4);
23                 setInputPins("A", "B", "C");
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 C = getSubmodelPin("C");
34                 Pin Y = getSubmodelPin("Y");
35
36                 GUINandGate nandAB = new GUINandGate(submodelModifiable, 1);
37                 GUINandGate andAB = new GUINandGate(submodelModifiable, 1);
38                 GUINandGate nandABC = new GUINandGate(submodelModifiable, 1);
39
40                 WireCrossPoint cpNandAB = new WireCrossPoint(submodelModifiable, 1);
41
42                 nandAB.moveTo(10, 15);
43                 andAB.moveTo(35, 15);
44                 nandABC.moveTo(62.5, 2.5);
45                 cpNandAB.moveCenterTo(32.5, 25);
46
47                 new GUIWire(submodelModifiable, A, nandAB.getPin("A"));
48                 new GUIWire(submodelModifiable, B, nandAB.getPin("B"));
49                 new GUIWire(submodelModifiable, nandAB.getPin("Y"), cpNandAB, new Point[0]);
50                 new GUIWire(submodelModifiable, cpNandAB, andAB.getPin("A"), new Point(32.5, 20));
51                 new GUIWire(submodelModifiable, cpNandAB, andAB.getPin("B"), new Point(32.5, 30));
52                 new GUIWire(submodelModifiable, andAB.getPin("Y"), nandABC.getPin("A"), new Point(57.5, 25), new Point(57.5, 7.5));
53                 new GUIWire(submodelModifiable, C, nandABC.getPin("B"), new Point(60, 62.5), new Point(60, 17.5));
54                 new GUIWire(submodelModifiable, nandABC.getPin("Y"), Y, new Point[0]);
55         }
56
57         static
58         {
59                 IndirectGUIComponentCreator.setComponentSupplier(GUInand3.class.getCanonicalName(), (m, p, n) -> new GUInand3(m, n));
60         }
61 }