Merge branch 'development' of
[Mograsim.git] / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / model / components / mi / nandbased / GUIand.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 GUIand extends SimpleRectangularSubmodelComponent
13 {
14         public GUIand(ViewModelModifiable model)
15         {
16                 this(model, null);
17         }
18
19         public GUIand(ViewModelModifiable model, String name)
20         {
21                 super(model, 1, "GUIand", 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 nand = new GUINandGate(submodelModifiable, 1);
36                 GUINandGate not = new GUINandGate(submodelModifiable, 1);
37
38                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
39
40                 nand.moveTo(20, 15);
41                 not.moveTo(50, 15);
42                 cp1.moveCenterTo(45, 25);
43
44                 new GUIWire(submodelModifiable, A, nand.getPin("A"));
45                 new GUIWire(submodelModifiable, B, nand.getPin("B"));
46                 new GUIWire(submodelModifiable, nand.getPin("Y"), cp1, new Point[0]);
47                 new GUIWire(submodelModifiable, cp1, not.getPin("A"), new Point(45, 20));
48                 new GUIWire(submodelModifiable, cp1, not.getPin("B"), new Point(45, 30));
49                 new GUIWire(submodelModifiable, not.getPin("Y"), Y);
50         }
51
52         static
53         {
54                 IndirectGUIComponentCreator.setComponentSupplier(GUIand.class.getCanonicalName(), (m, p, n) -> new GUIand(m, n));
55         }
56 }