1 package era.mi.gui.examples;
3 import era.mi.gui.LogicUI;
4 import era.mi.gui.components.GUIManualSwitch;
5 import era.mi.gui.components.GUINotGate;
6 import era.mi.gui.components.GUIOrGate;
7 import era.mi.gui.wires.WireConnectionPoint;
8 import era.mi.logic.Simulation;
9 import era.mi.logic.wires.WireArray;
10 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
12 public class RSLatchGUIExample
14 private static final int WIRE_DELAY = 40;
15 private static final int OR_DELAY = 100;
16 private static final int NOT_DELAY = 100;
18 public static void main(String[] args)
20 LogicUI ui = new LogicUI();
25 private static void initComponents(LogicUI ui)
27 Simulation.TIMELINE.reset();
28 WireArray r = new WireArray(1, WIRE_DELAY);
29 WireArray s = new WireArray(1, WIRE_DELAY);
30 WireArray t2 = new WireArray(1, WIRE_DELAY);
31 WireArray t1 = new WireArray(1, WIRE_DELAY);
32 WireArray q = new WireArray(1, WIRE_DELAY);
33 WireArray nq = new WireArray(1, WIRE_DELAY);
35 GUIManualSwitch rIn = ui.addComponent(new GUIManualSwitch(r), 100, 100);
36 GUIManualSwitch sIn = ui.addComponent(new GUIManualSwitch(s), 100, 200);
37 GUIOrGate or1 = ui.addComponent(new GUIOrGate(OR_DELAY, t1, r, nq), 160, 102.5);
38 GUIOrGate or2 = ui.addComponent(new GUIOrGate(OR_DELAY, t2, q, s), 160, 192.5);
39 GUINotGate not1 = ui.addComponent(new GUINotGate(NOT_DELAY, t1, q), 200, 107.5);
40 GUINotGate not2 = ui.addComponent(new GUINotGate(NOT_DELAY, t2, nq), 200, 197.5);
42 WireConnectionPoint p1 = ui.addComponent(new WireConnectionPoint(q, 3), 250, 112.5);
43 WireConnectionPoint p2 = ui.addComponent(new WireConnectionPoint(nq, 3), 250, 202.5);
44 WireConnectionPoint o1 = ui.addComponent(new WireConnectionPoint(q, 1), 270, 112.5);
45 WireConnectionPoint o2 = ui.addComponent(new WireConnectionPoint(nq, 1), 270, 202.5);
47 ui.addWire(rIn, 0, or1, 0);
48 ui.addWire(sIn, 0, or2, 1);
49 ui.addWire(or1, 2, not1, 0);
50 ui.addWire(or2, 2, not2, 0);
51 ui.addWire(not1, 1, p1, 0);
52 ui.addWire(not2, 1, p2, 0);
53 ui.addWire(p1, 1, or2, 0, new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
54 ui.addWire(p2, 1, or1, 1, new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
55 ui.addWire(p1, 2, o1, 0);
56 ui.addWire(p2, 2, o2, 0);