91b2d0e5bbe83fde82dfb8e5f64faf21fc32804b
[Mograsim.git] / LogicUI / src / era / mi / gui / examples / RSLatchExample.java
1 package era.mi.gui.examples;
2
3 import era.mi.gui.SimpleLogicUIStandalone;
4 import era.mi.gui.model.ViewModel;
5 import era.mi.gui.model.components.GUIManualSwitch;
6 import era.mi.gui.model.components.GUINotGate;
7 import era.mi.gui.model.components.GUIOrGate;
8 import era.mi.gui.model.wires.GUIWire;
9 import era.mi.gui.model.wires.WireCrossPoint;
10 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
11
12 public class RSLatchExample
13 {
14         public static void main(String[] args)
15         {
16                 SimpleLogicUIStandalone.executeVisualisation(RSLatchExample::createRSLatchExample);
17         }
18
19         private static void createRSLatchExample(ViewModel model)
20         {
21                 GUIManualSwitch rIn = new GUIManualSwitch(model);
22                 rIn.moveTo(100, 100);
23                 GUIManualSwitch sIn = new GUIManualSwitch(model);
24                 sIn.moveTo(100, 200);
25
26                 GUIOrGate or1 = new GUIOrGate(model, 1);
27                 or1.moveTo(160, 102.5);
28                 new GUIWire(model, rIn.getOutputPin(), or1.getInputPins().get(0));
29
30                 GUIOrGate or2 = new GUIOrGate(model, 1);
31                 or2.moveTo(160, 192.5);
32                 new GUIWire(model, sIn.getOutputPin(), or2.getInputPins().get(1));
33
34                 GUINotGate not1 = new GUINotGate(model, 1);
35                 not1.moveTo(200, 107.5);
36                 new GUIWire(model, or1.getOutputPin(), not1.getInputPins().get(0));
37
38                 GUINotGate not2 = new GUINotGate(model, 1);
39                 not2.moveTo(200, 197.5);
40                 new GUIWire(model, or2.getOutputPin(), not2.getInputPins().get(0));
41
42                 WireCrossPoint p1 = new WireCrossPoint(model, 1);
43                 p1.moveTo(250, 112.5);
44                 new GUIWire(model, not1.getOutputPin(), p1.getPin());
45                 new GUIWire(model, p1.getPin(), or2.getInputPins().get(0), new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
46
47                 WireCrossPoint p2 = new WireCrossPoint(model, 1);
48                 p2.moveTo(250, 202.5);
49                 new GUIWire(model, not2.getOutputPin(), p2.getPin());
50                 new GUIWire(model, p2.getPin(), or1.getInputPins().get(1), new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
51
52                 WireCrossPoint o1 = new WireCrossPoint(model, 1);
53                 o1.moveTo(270, 112.5);
54                 new GUIWire(model, p1.getPin(), o1.getPin());
55
56                 WireCrossPoint o2 = new WireCrossPoint(model, 1);
57                 o2.moveTo(270, 202.5);
58                 new GUIWire(model, p2.getPin(), o2.getPin());
59         }
60 }