Changed formatting of initSubmodelComponents
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUI_rsLatch.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 GUI_rsLatch extends SubmodelComponent
12 {
13         private final Pin pin_S;
14         private final Pin pin_R;
15         private final Pin pinQ;
16         private final Pin pin_Q;
17
18         public GUI_rsLatch(ViewModelModifiable model)
19         {
20                 super(model, "_rsLatch");
21                 setSize(35, 25);
22                 setSubmodelScale(.2);
23
24                 Pin _S = addSubmodelInterface(1, 0, 5);
25                 Pin _R = addSubmodelInterface(1, 0, 20);
26                 Pin Q = addSubmodelInterface(1, 35, 5);
27                 Pin _Q = addSubmodelInterface(1, 35, 20);
28
29                 this.pin_S = getSupermodelPin(_S);
30                 this.pin_R = getSupermodelPin(_R);
31                 this.pinQ = getSupermodelPin(Q);
32                 this.pin_Q = getSupermodelPin(_Q);
33
34                 initSubmodelComponents(_S, _R, Q, _Q);
35         }
36
37         @SuppressWarnings("unused") // for GUIWires being created
38         private void initSubmodelComponents(Pin _S, Pin _R, Pin Q, Pin _Q)
39         {
40
41                 GUINandGate nand1 = new GUINandGate(submodelModifiable, 1);
42                 GUINandGate nand2 = new GUINandGate(submodelModifiable, 1);
43
44                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
45                 WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1);
46
47                 nand1.moveTo(80, 20);
48                 nand2.moveTo(80, 85);
49                 cp1.moveTo(120, 30);
50                 cp2.moveTo(120, 95);
51
52                 new GUIWire(submodelModifiable, _S, nand1.getInputPins().get(0));
53                 new GUIWire(submodelModifiable, _R, nand2.getInputPins().get(1));
54                 new GUIWire(submodelModifiable, nand1.getOutputPin(), cp1.getPin());
55                 new GUIWire(submodelModifiable, nand2.getOutputPin(), cp2.getPin());
56                 new GUIWire(submodelModifiable, cp1.getPin(), nand2.getInputPins().get(0), new Point(120, 50), new Point(60, 75),
57                                 new Point(60, 90));
58                 new GUIWire(submodelModifiable, cp2.getPin(), nand1.getInputPins().get(1), new Point(120, 75), new Point(60, 50),
59                                 new Point(60, 35));
60                 new GUIWire(submodelModifiable, cp1.getPin(), Q, new Point(150, 30), new Point(150, 25));
61                 new GUIWire(submodelModifiable, cp2.getPin(), _Q, new Point(150, 95), new Point(150, 100));
62         }
63
64         public Pin getPin_S()
65         {
66                 return pin_S;
67         }
68
69         public Pin getPin_R()
70         {
71                 return pin_R;
72         }
73
74         public Pin getPinQ()
75         {
76                 return pinQ;
77         }
78
79         public Pin getPin_Q()
80         {
81                 return pin_Q;
82         }
83 }