1 package era.mi.gui.examples;
3 import era.mi.gui.LogicUIStandalone;
4 import era.mi.gui.model.ViewModel;
5 import era.mi.gui.model.components.GUIAndGate;
6 import era.mi.gui.model.components.GUIManualSwitch;
7 import era.mi.gui.model.components.GUINotGate;
8 import era.mi.gui.model.components.GUIOrGate;
9 import era.mi.gui.model.wires.GUIWire;
10 import era.mi.gui.model.wires.WireCrossPoint;
11 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
13 public class Playground
15 public static void main(String[] args)
17 ViewModel model = new ViewModel();
18 createRSLatchExample(model);
19 LogicUIStandalone ui = new LogicUIStandalone(model);
23 private static void createRSLatchExample(ViewModel model)
25 GUIManualSwitch rIn = new GUIManualSwitch(model);
27 GUIManualSwitch sIn = new GUIManualSwitch(model);
30 GUIOrGate or1 = new GUIOrGate(model, 1);
31 or1.moveTo(160, 102.5);
32 new GUIWire(model, rIn.getOutputPin(), or1.getInputPins().get(0));
34 GUIOrGate or2 = new GUIOrGate(model, 1);
35 or2.moveTo(160, 192.5);
36 new GUIWire(model, sIn.getOutputPin(), or2.getInputPins().get(1));
38 GUINotGate not1 = new GUINotGate(model, 1);
39 not1.moveTo(200, 107.5);
40 new GUIWire(model, or1.getOutputPin(), not1.getInputPins().get(0));
42 GUINotGate not2 = new GUINotGate(model, 1);
43 not2.moveTo(200, 197.5);
44 new GUIWire(model, or2.getOutputPin(), not2.getInputPins().get(0));
46 WireCrossPoint p1 = new WireCrossPoint(model, 1);
47 p1.moveTo(250, 112.5);
48 new GUIWire(model, not1.getOutputPin(), p1.getPin());
49 new GUIWire(model, p1.getPin(), or2.getInputPins().get(0), new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
51 WireCrossPoint p2 = new WireCrossPoint(model, 1);
52 p2.moveTo(250, 202.5);
53 new GUIWire(model, not2.getOutputPin(), p2.getPin());
54 new GUIWire(model, p2.getPin(), or1.getInputPins().get(1), new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
56 WireCrossPoint o1 = new WireCrossPoint(model, 1);
57 o1.moveTo(270, 112.5);
58 new GUIWire(model, p1.getPin(), o1.getPin());
60 WireCrossPoint o2 = new WireCrossPoint(model, 1);
61 o2.moveTo(270, 202.5);
62 new GUIWire(model, p2.getPin(), o2.getPin());
65 @SuppressWarnings("unused")
66 private static void createBasicExample(ViewModel model)
68 GUIAndGate andGate = new GUIAndGate(model, 1);
69 andGate.moveTo(10, 10);
70 GUINotGate notGate = new GUINotGate(model, 1);
71 notGate.moveTo(10, 40);
73 WireCrossPoint wcp1 = new WireCrossPoint(model, 1);
76 new GUIWire(model, andGate.getOutputPin(), notGate.getInputPins().get(0), new Point(60, 50));
77 new GUIWire(model, notGate.getOutputPin(), wcp1.getPin());
79 GUIManualSwitch sw1 = new GUIManualSwitch(model);
81 GUIManualSwitch sw2 = new GUIManualSwitch(model);
84 new GUIWire(model, sw1.getOutputPin(), andGate.getInputPins().get(0));
85 new GUIWire(model, sw2.getOutputPin(), andGate.getInputPins().get(1));