Added concept of wire width to GUIComponents and GUIWires
[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         private static final int WIRE_DELAY = 10;
15         private static final int OR_DELAY = 50;
16         private static final int NOT_DELAY = 50;
17
18         public static void main(String[] args)
19         {
20                 ViewModel model = new ViewModel();
21                 LogicUIStandalone ui = new LogicUIStandalone(model);
22                 addComponentsAndWires(ui, model);
23                 ui.run();
24         }
25
26         public static void addComponentsAndWires(LogicUIStandalone ui, ViewModel model)
27         {
28                 GUIAndGate andGate = new GUIAndGate(model, 1);
29                 andGate.moveTo(10, 10);
30                 GUINotGate notGate = new GUINotGate(model, 1);
31                 notGate.moveTo(10, 40);
32
33                 new GUIWire(model, andGate.getPins().get(0), notGate.getPins().get(1), new Point(20, 50));
34
35                 ui.getLogicUICanvas().addListener(SWT.KeyDown, e -> notGate.moveTo(150, 10));
36         }
37 }