Implemented GUI_rsLatch
[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         public GUI_rsLatch(ViewModelModifiable model)
14         {
15                 super(model, "_rsLatch");
16                 setSize(35, 25);
17                 setSubmodelScale(.2);
18                 initSubmodelComponents();
19         }
20
21         @SuppressWarnings("unused")
22         private void initSubmodelComponents()
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                 GUINandGate nand1 = new GUINandGate(submodelModifiable, 1);
30                 nand1.moveTo(80, 20);
31                 GUINandGate nand2 = new GUINandGate(submodelModifiable, 1);
32                 nand2.moveTo(80, 85);
33
34                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
35                 cp1.moveTo(120, 30);
36                 WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1);
37                 cp2.moveTo(120, 95);
38
39                 new GUIWire(submodelModifiable, _S, nand1.getInputPins().get(0));
40                 new GUIWire(submodelModifiable, _R, nand2.getInputPins().get(1));
41                 new GUIWire(submodelModifiable, nand1.getOutputPin(), cp1.getPin());
42                 new GUIWire(submodelModifiable, nand2.getOutputPin(), cp2.getPin());
43                 new GUIWire(submodelModifiable, cp1.getPin(), nand2.getInputPins().get(0), new Point(120, 50), new Point(60, 75),
44                                 new Point(60, 90));
45                 new GUIWire(submodelModifiable, cp2.getPin(), nand1.getInputPins().get(1), new Point(120, 75), new Point(60, 50),
46                                 new Point(60, 35));
47                 new GUIWire(submodelModifiable, cp1.getPin(), Q, new Point(150, 30), new Point(150, 25));
48                 new GUIWire(submodelModifiable, cp2.getPin(), _Q, new Point(150, 95), new Point(150, 100));
49         }
50 }