1 package net.mograsim.logic.ui;
3 import org.eclipse.swt.SWT;
4 import org.eclipse.swt.layout.FillLayout;
5 import org.eclipse.swt.widgets.Display;
6 import org.eclipse.swt.widgets.Shell;
8 import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasOverlay;
9 import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
10 import net.mograsim.logic.ui.model.ViewModel;
13 * Standalone simulation visualizer graphical user interface.
15 * @author Daniel Kirschten
17 public class LogicUIStandaloneGUI
19 private final Display display;
20 private final Shell shell;
21 private final LogicUICanvas ui;
23 public LogicUIStandaloneGUI(ViewModel model)
25 display = new Display();
26 shell = new Shell(display);
27 shell.setLayout(new FillLayout());
28 ui = new LogicUICanvas(shell, SWT.NONE, model);
30 ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui);
31 userInput.buttonDrag = 3;
32 userInput.buttonZoom = 2;
33 userInput.enableUserInput();
34 new ZoomableCanvasOverlay(ui, null).enableScale();
37 public LogicUICanvas getLogicUICanvas()
43 * Opens the UI shell. Returns when the shell is closed.
48 while (!shell.isDisposed())
49 if (!display.readAndDispatch())