From 8602c18db94281afd5bc0ceb5930a3d99fbe7a38 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 17 May 2008 21:50:44 +0000 Subject: Manual crash/recover implemented. --- sources/simulator/VSSimulationPanel.java | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'sources/simulator/VSSimulationPanel.java') diff --git a/sources/simulator/VSSimulationPanel.java b/sources/simulator/VSSimulationPanel.java index e750b0a..8d792a9 100644 --- a/sources/simulator/VSSimulationPanel.java +++ b/sources/simulator/VSSimulationPanel.java @@ -278,14 +278,29 @@ public class VSSimulationPanel extends JPanel implements Runnable, MouseMotionLi g.setColor(process.getColor()); g.fillPolygon(xPoints, yPoints, 5); - if (process.isCrashed()) { - final VSTask crashTask = process.getCrashTask(); - final int crashPos = (int) getTimeXPosition(crashTask.getTaskTime()); - final int xPointsCrashed[] = { crashPos, xoffset_plus_xpaintsize, xoffset_plus_xpaintsize, crashPos, crashPos }; + + if (process.hasCrashed()) { g.setColor(process.getCrashedColor()); - g.fillPolygon(xPointsCrashed, yPoints, 5); + final Long crashHistory[] = process.getCrashHistoryArray(); + final int length = crashHistory.length; + + for (int i = 0; i < length; i += 2) { + final int crashStartPos = (int) getTimeXPosition(crashHistory[i].longValue()); + int crashEndPos; + + if (i == length - 1) + crashEndPos = xoffset_plus_xpaintsize; + else + crashEndPos = (int) getTimeXPosition(crashHistory[i+1].longValue()); + + final int xPointsCrashed[] = { crashStartPos, crashEndPos, + crashEndPos, crashStartPos, crashStartPos + }; + g.fillPolygon(xPointsCrashed, yPoints, 5); + } } + g.setColor(process.getColor()); g.drawString("P" + process.getProcessID() + ":", XOFFSET - 30, yPoints[0] + LINE_WIDTH); final long tmp = localTime > untilTime ? untilTime : localTime; @@ -635,14 +650,14 @@ public class VSSimulationPanel extends JPanel implements Runnable, MouseMotionLi popup.add(item); item = new JMenuItem(prefs.getString("lang.crash")); - if (process.isCrashed() || isPaused || time == 0) + if (process.isCrashed() || isPaused || time == 0 || isFinished) item.setEnabled(false); else item.addActionListener(actionListener); popup.add(item); item = new JMenuItem(prefs.getString("lang.recover")); - if (!process.isCrashed() || isPaused || time == 0) + if (!process.isCrashed() || isPaused || time == 0 || isFinished) item.setEnabled(false); else item.addActionListener(actionListener); -- cgit v1.2.3