Added DeserializedSubmodelComponent Editor project
[Mograsim.git] / net.mograsim.logic.ui.am2900 / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUIand.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 GUIand extends SimpleRectangularSubmodelComponent
13 {
14         public GUIand(ViewModelModifiable model)
15         {
16                 super(model, 1, "GUIand");
17                 setSubmodelScale(.4);
18                 setInputPins("A", "B");
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 Y = getSubmodelPin("Y");
29
30                 GUINandGate nand = new GUINandGate(submodelModifiable, 1);
31                 GUINandGate not = new GUINandGate(submodelModifiable, 1);
32
33                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
34
35                 nand.moveTo(20, 15);
36                 not.moveTo(50, 15);
37                 cp1.moveCenterTo(45, 25);
38
39                 new GUIWire(submodelModifiable, A, nand.getPin("A"));
40                 new GUIWire(submodelModifiable, B, nand.getPin("B"));
41                 new GUIWire(submodelModifiable, nand.getPin("Y"), cp1, new Point[0]);
42                 new GUIWire(submodelModifiable, cp1, not.getPin("A"), new Point(45, 20));
43                 new GUIWire(submodelModifiable, cp1, not.getPin("B"), new Point(45, 30));
44                 new GUIWire(submodelModifiable, not.getPin("Y"), Y);
45         }
46
47         static
48         {
49                 IndirectGUIComponentCreator.setComponentProvider(GUIand.class.getCanonicalName(), (m, p) -> new GUIand(m));
50         }
51 }