Renamed project folders to match the respective project name
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / examples / RSLatchExample.java
1 package net.mograsim.logic.ui.examples;
2
3 import net.mograsim.logic.ui.SimpleLogicUIStandalone;
4 import net.mograsim.logic.ui.model.ViewModel;
5 import net.mograsim.logic.ui.model.components.GUIManualSwitch;
6 import net.mograsim.logic.ui.model.components.GUINotGate;
7 import net.mograsim.logic.ui.model.components.GUIOrGate;
8 import net.mograsim.logic.ui.model.wires.GUIWire;
9 import net.mograsim.logic.ui.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         @SuppressWarnings("unused") // for GUIWires being created
20         public static void createRSLatchExample(ViewModel model)
21         {
22                 GUIManualSwitch rIn = new GUIManualSwitch(model);
23                 rIn.moveTo(100, 100);
24                 GUIManualSwitch sIn = new GUIManualSwitch(model);
25                 sIn.moveTo(100, 200);
26
27                 GUIOrGate or1 = new GUIOrGate(model, 1);
28                 or1.moveTo(160, 102.5);
29                 new GUIWire(model, rIn.getOutputPin(), or1.getInputPins().get(0));
30
31                 GUIOrGate or2 = new GUIOrGate(model, 1);
32                 or2.moveTo(160, 192.5);
33                 new GUIWire(model, sIn.getOutputPin(), or2.getInputPins().get(1));
34
35                 GUINotGate not1 = new GUINotGate(model, 1);
36                 not1.moveTo(200, 107.5);
37                 new GUIWire(model, or1.getOutputPin(), not1.getInputPins().get(0));
38
39                 GUINotGate not2 = new GUINotGate(model, 1);
40                 not2.moveTo(200, 197.5);
41                 new GUIWire(model, or2.getOutputPin(), not2.getInputPins().get(0));
42
43                 WireCrossPoint p1 = new WireCrossPoint(model, 1);
44                 p1.moveTo(250, 112.5);
45                 new GUIWire(model, not1.getOutputPin(), p1.getPin());
46                 new GUIWire(model, p1.getPin(), or2.getInputPins().get(0), new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
47
48                 WireCrossPoint p2 = new WireCrossPoint(model, 1);
49                 p2.moveTo(250, 202.5);
50                 new GUIWire(model, not2.getOutputPin(), p2.getPin());
51                 new GUIWire(model, p2.getPin(), or1.getInputPins().get(1), new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
52
53                 WireCrossPoint o1 = new WireCrossPoint(model, 1);
54                 o1.moveTo(270, 112.5);
55                 new GUIWire(model, p1.getPin(), o1.getPin());
56
57                 WireCrossPoint o2 = new WireCrossPoint(model, 1);
58                 o2.moveTo(270, 202.5);
59                 new GUIWire(model, p2.getPin(), o2.getPin());
60         }
61 }