1 package era.mi.gui.examples;
3 import org.eclipse.swt.SWT;
5 import era.mi.gui.LogicUIStandalone;
6 import era.mi.gui.model.ViewModel;
7 import era.mi.gui.model.components.GUIAndGate;
8 import era.mi.gui.model.components.GUIManualSwitch;
9 import era.mi.gui.model.components.GUINotGate;
10 import era.mi.gui.model.wires.GUIWire;
11 import era.mi.gui.model.wires.WireCrossPoint;
12 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
14 public class Playground
16 public static void main(String[] args)
18 ViewModel model = new ViewModel();
19 GUIAndGate andGate = new GUIAndGate(model, 1);
20 andGate.moveTo(10, 10);
21 GUINotGate notGate = new GUINotGate(model, 1);
22 notGate.moveTo(10, 40);
24 WireCrossPoint wcp1 = new WireCrossPoint(model, 1);
27 new GUIWire(model, andGate.getOutputPin(), notGate.getInputPins().get(0), new Point(60, 50));
28 new GUIWire(model, notGate.getOutputPin(), wcp1.getPin());
30 GUIManualSwitch sw1 = new GUIManualSwitch(model);
32 GUIManualSwitch sw2 = new GUIManualSwitch(model);
35 new GUIWire(model, sw1.getOutputPin(), andGate.getInputPins().get(0));
36 new GUIWire(model, sw2.getOutputPin(), andGate.getInputPins().get(1));
38 LogicUIStandalone ui = new LogicUIStandalone(model);
40 ui.getLogicUICanvas().addListener(SWT.KeyDown, e -> notGate.moveTo(100, 10));
44 public static void addComponentsAndWires(LogicUIStandalone ui, ViewModel model)
46 GUIAndGate andGate = new GUIAndGate(model, 1);
47 andGate.moveTo(10, 10);
48 GUINotGate notGate = new GUINotGate(model, 1);
49 notGate.moveTo(10, 40);
51 new GUIWire(model, andGate.getPins().get(0), notGate.getPins().get(1), new Point(20, 50));
53 ui.getLogicUICanvas().addListener(SWT.KeyDown, e -> notGate.moveTo(150, 10));