Actually use adapter. Somehow this introduced a rendering bug...
[Mograsim.git] / LogicUI / src / era / mi / gui / examples / Playground.java
1 package era.mi.gui.examples;
2
3 import org.eclipse.swt.SWT;
4
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.GUINotGate;
9 import era.mi.gui.model.wires.GUIWire;
10 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
11
12 public class Playground
13 {
14         public static void main(String[] args)
15         {
16                 ViewModel model = new ViewModel();
17                 GUIAndGate andGate = new GUIAndGate(model, 1);
18                 andGate.moveTo(10, 10);
19                 GUINotGate notGate = new GUINotGate(model, 1);
20                 notGate.moveTo(10, 40);
21
22                 new GUIWire(model, andGate.getPins().get(0), notGate.getPins().get(1), new Point(20, 50));
23
24                 LogicUIStandalone ui = new LogicUIStandalone(model);
25
26                 ui.getLogicUICanvas().addListener(SWT.KeyDown, e -> notGate.moveTo(150, 10));
27                 ui.run();
28         }
29
30         public static void addComponentsAndWires(LogicUIStandalone ui, ViewModel model)
31         {
32                 GUIAndGate andGate = new GUIAndGate(model, 1);
33                 andGate.moveTo(10, 10);
34                 GUINotGate notGate = new GUINotGate(model, 1);
35                 notGate.moveTo(10, 40);
36
37                 new GUIWire(model, andGate.getPins().get(0), notGate.getPins().get(1), new Point(20, 50));
38
39                 ui.getLogicUICanvas().addListener(SWT.KeyDown, e -> notGate.moveTo(150, 10));
40         }
41 }