projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'development' of
[Mograsim.git]
/
LogicUI
/
src
/
era
/
mi
/
gui
/
LogicUIStandalone.java
diff --git
a/LogicUI/src/era/mi/gui/LogicUIStandalone.java
b/LogicUI/src/era/mi/gui/LogicUIStandalone.java
index
fea7e18
..
3312308
100644
(file)
--- a/
LogicUI/src/era/mi/gui/LogicUIStandalone.java
+++ b/
LogicUI/src/era/mi/gui/LogicUIStandalone.java
@@
-7,7
+7,10
@@
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
-import era.mi.logic.Simulation;
+import era.mi.gui.model.ViewModel;
+import era.mi.gui.modeladapter.LogicModelParameters;
+import era.mi.gui.modeladapter.ViewLogicModelAdapter;
+import era.mi.logic.timeline.Timeline;
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasOverlay;
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasOverlay;
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;
@@
-18,22
+21,32
@@
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInpu
*/
public class LogicUIStandalone
{
*/
public class LogicUIStandalone
{
+ private ViewModel model;
+ private Timeline timeline;
+
private final Display display;
private final Shell shell;
private final LogicUICanvas ui;
private final Display display;
private final Shell shell;
private final LogicUICanvas ui;
- public LogicUIStandalone()
+ public LogicUIStandalone(
ViewModel model
)
{
{
+ this.model = model;
display = new Display();
shell = new Shell(display);
shell.setLayout(new FillLayout());
display = new Display();
shell = new Shell(display);
shell.setLayout(new FillLayout());
- ui = new LogicUICanvas(shell, SWT.NONE);
+ ui = new LogicUICanvas(shell, SWT.NONE
, model
);
ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui);
userInput.buttonDrag = 3;
userInput.buttonZoom = 2;
userInput.enableUserInput();
new ZoomableCanvasOverlay(ui, null).enableScale();
ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui);
userInput.buttonDrag = 3;
userInput.buttonZoom = 2;
userInput.enableUserInput();
new ZoomableCanvasOverlay(ui, null).enableScale();
+
+ // TODO don't do this here
+ LogicModelParameters params = new LogicModelParameters();
+ params.gateProcessTime = 50;
+ params.wireTravelTime = 10;
+ timeline = ViewLogicModelAdapter.convert(model, params);
}
public LogicUICanvas getLogicUICanvas()
}
public LogicUICanvas getLogicUICanvas()
@@
-52,10
+65,10
@@
public class LogicUIStandalone
while (running.get())
{
// always execute to keep timeline from "hanging behind" for too long
while (running.get())
{
// always execute to keep timeline from "hanging behind" for too long
-
Simulation.TIMELINE.executeUpTo(System.currentTimeMillis(
), System.currentTimeMillis() + 10);
+
timeline.executeUntil(timeline.laterThan(System.currentTimeMillis()
), System.currentTimeMillis() + 10);
long sleepTime;
long sleepTime;
- if (
Simulation.TIMELINE
.hasNext())
- sleepTime =
Simulation.TIMELINE
.nextEventTime() - System.currentTimeMillis();
+ if (
timeline
.hasNext())
+ sleepTime =
timeline
.nextEventTime() - System.currentTimeMillis();
else
sleepTime = 10;
try
else
sleepTime = 10;
try
@@
-69,7
+82,7
@@
public class LogicUIStandalone
}
});
simulationThread.start();
}
});
simulationThread.start();
-
Simulation.TIMELINE
.addEventAddedListener(event ->
+
timeline
.addEventAddedListener(event ->
{
if (event.getTiming() <= System.currentTimeMillis())
simulationThread.interrupt();
{
if (event.getTiming() <= System.currentTimeMillis())
simulationThread.interrupt();
@@
-80,6
+93,6
@@
public class LogicUIStandalone
if (!display.readAndDispatch())
display.sleep();
running.set(false);
if (!display.readAndDispatch())
display.sleep();
running.set(false);
-
simulationThread.interrupt();
+
//
simulationThread.interrupt();
}
}
\ No newline at end of file
}
}
\ No newline at end of file