1 package net.mograsim.logic.ui.examples;
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.ui.SimpleLogicUIStandalone;
5 import net.mograsim.logic.ui.model.ViewModelModifiable;
6 import net.mograsim.logic.ui.model.components.GUIManualSwitch;
7 import net.mograsim.logic.ui.model.components.GUINotGate;
8 import net.mograsim.logic.ui.model.components.GUIOrGate;
9 import net.mograsim.logic.ui.model.wires.GUIWire;
10 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
12 public class RSLatchExample
14 public static void main(String[] args)
16 SimpleLogicUIStandalone.executeVisualisation(RSLatchExample::createRSLatchExample);
19 @SuppressWarnings("unused") // for GUIWires being created
20 public static void createRSLatchExample(ViewModelModifiable model)
22 GUIManualSwitch rIn = new GUIManualSwitch(model);
24 GUIManualSwitch sIn = new GUIManualSwitch(model);
27 GUIOrGate or1 = new GUIOrGate(model, 1);
28 or1.moveTo(160, 102.5);
29 new GUIWire(model, rIn.getOutputPin(), or1.getInputPins().get(0));
31 GUIOrGate or2 = new GUIOrGate(model, 1);
32 or2.moveTo(160, 192.5);
33 new GUIWire(model, sIn.getOutputPin(), or2.getInputPins().get(1));
35 GUINotGate not1 = new GUINotGate(model, 1);
36 not1.moveTo(200, 107.5);
37 new GUIWire(model, or1.getOutputPin(), not1.getInputPins().get(0));
39 GUINotGate not2 = new GUINotGate(model, 1);
40 not2.moveTo(200, 197.5);
41 new GUIWire(model, or2.getOutputPin(), not2.getInputPins().get(0));
43 WireCrossPoint p1 = new WireCrossPoint(model, 1);
44 p1.moveCenterTo(250, 112.5);
45 new GUIWire(model, not1.getOutputPin(), p1);
46 new GUIWire(model, p1, or2.getInputPins().get(0), new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
48 WireCrossPoint p2 = new WireCrossPoint(model, 1);
49 p2.moveCenterTo(250, 202.5);
50 new GUIWire(model, not2.getOutputPin(), p2);
51 new GUIWire(model, p2, or1.getInputPins().get(1), new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
53 WireCrossPoint o1 = new WireCrossPoint(model, 1);
54 o1.moveCenterTo(270, 112.5);
55 new GUIWire(model, p1, o1);
57 WireCrossPoint o2 = new WireCrossPoint(model, 1);
58 o2.moveCenterTo(270, 202.5);
59 new GUIWire(model, p2, o2);