4443e21ae8ea71416228f04e5e174fff61d5b4ee
[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                 super(model, 1, "GUInand3");
17                 setSubmodelScale(.4);
18                 setInputPins("A", "B", "C");
19                 setOutputPins("Y");
20                 initSubmodelComponents();
21         }
22
23         @SuppressWarnings("unused") // for GUIWires being created
24         private void initSubmodelComponents()
25         {
26                 Pin A = getSubmodelPin("A");
27                 Pin B = getSubmodelPin("B");
28                 Pin C = getSubmodelPin("C");
29                 Pin Y = getSubmodelPin("Y");
30
31                 GUINandGate nandAB = new GUINandGate(submodelModifiable, 1);
32                 GUINandGate andAB = new GUINandGate(submodelModifiable, 1);
33                 GUINandGate nandABC = new GUINandGate(submodelModifiable, 1);
34
35                 WireCrossPoint cpNandAB = new WireCrossPoint(submodelModifiable, 1);
36
37                 nandAB.moveTo(10, 15);
38                 andAB.moveTo(35, 15);
39                 nandABC.moveTo(62.5, 2.5);
40                 cpNandAB.moveCenterTo(32.5, 25);
41
42                 new GUIWire(submodelModifiable, A, nandAB.getPin("A"));
43                 new GUIWire(submodelModifiable, B, nandAB.getPin("B"));
44                 new GUIWire(submodelModifiable, nandAB.getPin("Y"), cpNandAB, new Point[0]);
45                 new GUIWire(submodelModifiable, cpNandAB, andAB.getPin("A"), new Point(32.5, 20));
46                 new GUIWire(submodelModifiable, cpNandAB, andAB.getPin("B"), new Point(32.5, 30));
47                 new GUIWire(submodelModifiable, andAB.getPin("Y"), nandABC.getPin("A"), new Point(57.5, 25), new Point(57.5, 7.5));
48                 new GUIWire(submodelModifiable, C, nandABC.getPin("B"), new Point(60, 62.5), new Point(60, 17.5));
49                 new GUIWire(submodelModifiable, nandABC.getPin("Y"), Y, new Point[0]);
50         }
51
52         static
53         {
54                 IndirectGUIComponentCreator.setComponentSupplier(GUInand3.class.getCanonicalName(), (m, p) -> new GUInand3(m));
55         }
56 }