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