1 package net.mograsim.logic.model;
3 import static net.mograsim.logic.model.preferences.RenderPreferences.DRAG_BUTTON;
4 import static net.mograsim.logic.model.preferences.RenderPreferences.ZOOM_BUTTON;
6 import org.eclipse.swt.SWT;
7 import org.eclipse.swt.layout.FillLayout;
8 import org.eclipse.swt.widgets.Display;
9 import org.eclipse.swt.widgets.Shell;
11 import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasOverlay;
12 import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
13 import net.mograsim.logic.model.model.LogicModel;
14 import net.mograsim.logic.model.preferences.RenderPreferences;
17 * Standalone simulation visualizer graphical user interface.
19 * @author Daniel Kirschten
21 public class LogicUIStandaloneGUI implements Runnable
23 private final Display display;
24 private final Shell shell;
25 private final LogicUICanvas ui;
27 public LogicUIStandaloneGUI(LogicModel model, RenderPreferences renderPrefs)
29 display = new Display();
30 shell = new Shell(display);
31 shell.setLayout(new FillLayout());
32 ui = new LogicUICanvas(shell, SWT.NONE, model, renderPrefs);
34 ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui);
35 // TODO add a listener
36 userInput.buttonDrag = renderPrefs.getInt(DRAG_BUTTON);
37 // TODO add a listener
38 userInput.buttonZoom = renderPrefs.getInt(ZOOM_BUTTON);
39 userInput.enableUserInput();
40 new ZoomableCanvasOverlay(ui, null).enableScale();
43 public LogicUICanvas getLogicUICanvas()
49 * Opens the UI shell. Returns when the shell is closed.
55 while (!shell.isDisposed())
56 if (!display.readAndDispatch())