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