Added getter for submodel interface pins in GUIand and GUI_rsLatch
[Mograsim.git] / net.mograsim.logic.ui / 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.GUINandGate;
6 import net.mograsim.logic.ui.model.components.SubmodelComponent;
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
11 public class GUIand extends SubmodelComponent
12 {
13         private final Pin pinA;
14         private final Pin pinB;
15         private final Pin pinY;
16
17         public GUIand(ViewModelModifiable model)
18         {
19                 super(model, "GUIand");
20                 setSize(35, 25);
21                 setSubmodelScale(.4);
22
23                 Pin A = addSubmodelInterface(1, 0, 5);
24                 Pin B = addSubmodelInterface(1, 0, 20);
25                 Pin Y = addSubmodelInterface(1, 35, 12.5);
26
27                 this.pinA = getSupermodelPin(A);
28                 this.pinB = getSupermodelPin(B);
29                 this.pinY = getSupermodelPin(Y);
30
31                 initSubmodelComponents(A, B, Y);
32         }
33
34         @SuppressWarnings("unused") // for GUIWires being created
35         private void initSubmodelComponents(Pin A, Pin B, Pin Y)
36         {
37                 GUINandGate nand = new GUINandGate(submodelModifiable, 1);
38                 nand.moveTo(20, 21.25);
39                 GUINandGate not = new GUINandGate(submodelModifiable, 1);
40                 not.moveTo(50, 21.25);
41
42                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
43                 cp1.moveTo(45, 31.25);
44
45                 new GUIWire(submodelModifiable, A, nand.getInputPins().get(0), new Point(10, 12.5), new Point(10, 26.25));
46                 new GUIWire(submodelModifiable, B, nand.getInputPins().get(1), new Point(10, 50), new Point(10, 36.25));
47                 new GUIWire(submodelModifiable, nand.getOutputPin(), cp1.getPin());
48                 new GUIWire(submodelModifiable, cp1.getPin(), not.getInputPins().get(0), new Point(45, 26.25));
49                 new GUIWire(submodelModifiable, cp1.getPin(), not.getInputPins().get(1), new Point(45, 36.25));
50                 new GUIWire(submodelModifiable, not.getOutputPin(), Y);
51         }
52
53         public Pin getPinA()
54         {
55                 return pinA;
56         }
57
58         public Pin getPinB()
59         {
60                 return pinB;
61         }
62
63         public Pin getPinY()
64         {
65                 return pinY;
66         }
67
68 }