|
|
@ -44,8 +44,7 @@ import javax.swing.event.*; |
|
|
* @author Andrew Hinton |
|
|
* @author Andrew Hinton |
|
|
*/ |
|
|
*/ |
|
|
public class GUISimulator extends GUIPlugin implements MouseListener, ListSelectionListener, PrismSettingsListener |
|
|
public class GUISimulator extends GUIPlugin implements MouseListener, ListSelectionListener, PrismSettingsListener |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
//ATTRIBUTES |
|
|
//ATTRIBUTES |
|
|
private GUIPrism gui; //reference to the gui |
|
|
private GUIPrism gui; //reference to the gui |
|
|
private GUIMultiProperties guiProp; //reference to the properties information |
|
|
private GUIMultiProperties guiProp; //reference to the properties information |
|
|
@ -2356,7 +2355,8 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
private boolean stepsVisible; |
|
|
private boolean stepsVisible; |
|
|
private boolean hideEmptyRewards; |
|
|
private boolean hideEmptyRewards; |
|
|
private boolean showTime; |
|
|
private boolean showTime; |
|
|
|
|
|
|
|
|
|
|
|
private boolean showCumulativeTime; |
|
|
|
|
|
|
|
|
public SimulationView() |
|
|
public SimulationView() |
|
|
{ |
|
|
{ |
|
|
this.visibleVariables = new ArrayList(); |
|
|
this.visibleVariables = new ArrayList(); |
|
|
@ -2398,10 +2398,28 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
{ |
|
|
{ |
|
|
return showTime && mf.getType() == ModulesFile.STOCHASTIC; |
|
|
return showTime && mf.getType() == ModulesFile.STOCHASTIC; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean showCumulativeTime() |
|
|
|
|
|
{ |
|
|
|
|
|
return showCumulativeTime && mf.getType() == ModulesFile.STOCHASTIC; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public boolean canShowTime() |
|
|
|
|
|
{ |
|
|
|
|
|
return mf.getType() == ModulesFile.STOCHASTIC; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public void showTime(boolean showTime) |
|
|
public void showTime(boolean showTime) |
|
|
{ |
|
|
{ |
|
|
this.showTime = stepsVisible; |
|
|
|
|
|
|
|
|
this.showTime = showTime; |
|
|
|
|
|
|
|
|
|
|
|
this.setChanged(); |
|
|
|
|
|
this.notifyObservers(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void showCumulativeTime(boolean showCumulativeTime) |
|
|
|
|
|
{ |
|
|
|
|
|
this.showCumulativeTime = showCumulativeTime; |
|
|
|
|
|
|
|
|
this.setChanged(); |
|
|
this.setChanged(); |
|
|
this.notifyObservers(); |
|
|
this.notifyObservers(); |
|
|
@ -2464,6 +2482,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
stepsVisible = true; |
|
|
stepsVisible = true; |
|
|
hideEmptyRewards = true; |
|
|
hideEmptyRewards = true; |
|
|
showTime = mf.getType() == ModulesFile.STOCHASTIC; |
|
|
showTime = mf.getType() == ModulesFile.STOCHASTIC; |
|
|
|
|
|
showCumulativeTime = false; |
|
|
|
|
|
|
|
|
for (int i = 0; i < engine.getNumVariables(); i++) |
|
|
for (int i = 0; i < engine.getNumVariables(); i++) |
|
|
{ |
|
|
{ |
|
|
@ -2515,7 +2534,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
if (view.getVisibleVariables().size() > 0) |
|
|
if (view.getVisibleVariables().size() > 0) |
|
|
{ groupCount++; } |
|
|
{ groupCount++; } |
|
|
|
|
|
|
|
|
if (view.showTime()) |
|
|
|
|
|
|
|
|
if (view.showTime() || view.showCumulativeTime()) |
|
|
{ groupCount++; } |
|
|
{ groupCount++; } |
|
|
|
|
|
|
|
|
if (view.getVisibleRewards().size() > 0) |
|
|
if (view.getVisibleRewards().size() > 0) |
|
|
@ -2562,7 +2581,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
groupCount++; |
|
|
groupCount++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (view.showTime()) |
|
|
|
|
|
|
|
|
if (view.showTime() || view.showCumulativeTime()) |
|
|
{ |
|
|
{ |
|
|
if (groupCount == groupIndex) |
|
|
if (groupCount == groupIndex) |
|
|
{ return "Time"; } |
|
|
{ return "Time"; } |
|
|
@ -2588,7 +2607,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
int stepStart = 0; |
|
|
int stepStart = 0; |
|
|
int varStart = stepStart + (view.showSteps() ? 1 : 0); |
|
|
int varStart = stepStart + (view.showSteps() ? 1 : 0); |
|
|
int timeStart = varStart + view.getVisibleVariables().size(); |
|
|
int timeStart = varStart + view.getVisibleVariables().size(); |
|
|
int rewardStart = timeStart + (view.showTime() ? 1 : 0); |
|
|
|
|
|
|
|
|
int rewardStart = timeStart + (view.showTime() ? 1 : 0) + (view.showCumulativeTime() ? 1 : 0); |
|
|
|
|
|
|
|
|
int groupCount = 0; |
|
|
int groupCount = 0; |
|
|
|
|
|
|
|
|
@ -2608,10 +2627,15 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
groupCount++; |
|
|
groupCount++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (view.showTime()) |
|
|
|
|
|
|
|
|
if (view.showTime() || view.showCumulativeTime()) |
|
|
{ |
|
|
{ |
|
|
if (groupCount == groupIndex) |
|
|
if (groupCount == groupIndex) |
|
|
{ return timeStart; } |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
if (view.showTime() && view.showCumulativeTime()) |
|
|
|
|
|
return timeStart + 1; |
|
|
|
|
|
else |
|
|
|
|
|
return timeStart; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
groupCount++; |
|
|
groupCount++; |
|
|
} |
|
|
} |
|
|
@ -2642,7 +2666,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
|
|
|
|
|
|
colCount += (view.showSteps() ? 1 : 0); |
|
|
colCount += (view.showSteps() ? 1 : 0); |
|
|
colCount += view.getVisibleVariables().size(); |
|
|
colCount += view.getVisibleVariables().size(); |
|
|
colCount += (view.showTime() ? 1 : 0); |
|
|
|
|
|
|
|
|
colCount += (view.showTime() ? 1 : 0) + (view.showCumulativeTime() ? 1 : 0); |
|
|
colCount += view.getVisibleRewards().size(); |
|
|
colCount += view.getVisibleRewards().size(); |
|
|
|
|
|
|
|
|
return colCount; |
|
|
return colCount; |
|
|
@ -2687,7 +2711,8 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
int stepStart = 0; |
|
|
int stepStart = 0; |
|
|
int varStart = stepStart + (view.showSteps() ? 1 : 0); |
|
|
int varStart = stepStart + (view.showSteps() ? 1 : 0); |
|
|
int timeStart = varStart + view.getVisibleVariables().size(); |
|
|
int timeStart = varStart + view.getVisibleVariables().size(); |
|
|
int rewardStart = timeStart + (view.showTime() ? 1 : 0); |
|
|
|
|
|
|
|
|
int cumulativeTimeStart = timeStart + (view.showTime() ? 1 : 0); |
|
|
|
|
|
int rewardStart = cumulativeTimeStart + (view.showCumulativeTime() ? 1 : 0); |
|
|
|
|
|
|
|
|
// The step column |
|
|
// The step column |
|
|
if (stepStart <= columnIndex && columnIndex < varStart) |
|
|
if (stepStart <= columnIndex && columnIndex < varStart) |
|
|
@ -2699,10 +2724,14 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
{ |
|
|
{ |
|
|
return ((Variable)view.getVisibleVariables().get(columnIndex - varStart)).toString(); |
|
|
return ((Variable)view.getVisibleVariables().get(columnIndex - varStart)).toString(); |
|
|
} |
|
|
} |
|
|
else if (timeStart <= columnIndex && columnIndex < rewardStart) |
|
|
|
|
|
|
|
|
else if (timeStart <= columnIndex && columnIndex < cumulativeTimeStart) |
|
|
{ |
|
|
{ |
|
|
return "Time"; |
|
|
return "Time"; |
|
|
} |
|
|
} |
|
|
|
|
|
else if (cumulativeTimeStart <= columnIndex && columnIndex < rewardStart) |
|
|
|
|
|
{ |
|
|
|
|
|
return "Time (+)"; |
|
|
|
|
|
} |
|
|
else if (rewardStart <= columnIndex) |
|
|
else if (rewardStart <= columnIndex) |
|
|
{ |
|
|
{ |
|
|
return ((RewardStructure)view.getVisibleRewards().get(columnIndex - rewardStart)).getColumnName(); |
|
|
return ((RewardStructure)view.getVisibleRewards().get(columnIndex - rewardStart)).getColumnName(); |
|
|
@ -2720,7 +2749,8 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
int stepStart = 0; |
|
|
int stepStart = 0; |
|
|
int varStart = stepStart + (view.showSteps() ? 1 : 0); |
|
|
int varStart = stepStart + (view.showSteps() ? 1 : 0); |
|
|
int timeStart = varStart + view.getVisibleVariables().size(); |
|
|
int timeStart = varStart + view.getVisibleVariables().size(); |
|
|
int rewardStart = timeStart + (view.showTime() ? 1 : 0); |
|
|
|
|
|
|
|
|
int cumulativeTimeStart = timeStart + (view.showTime() ? 1 : 0); |
|
|
|
|
|
int rewardStart = cumulativeTimeStart + (view.showCumulativeTime() ? 1 : 0); |
|
|
|
|
|
|
|
|
// The step column |
|
|
// The step column |
|
|
if (stepStart <= columnIndex && columnIndex < varStart) |
|
|
if (stepStart <= columnIndex && columnIndex < varStart) |
|
|
@ -2740,7 +2770,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
else if (type == Expression.INT) |
|
|
else if (type == Expression.INT) |
|
|
{ return new Integer(result); } |
|
|
{ return new Integer(result); } |
|
|
} |
|
|
} |
|
|
else if (timeStart <= columnIndex && columnIndex < rewardStart) |
|
|
|
|
|
|
|
|
else if (timeStart <= columnIndex && columnIndex < cumulativeTimeStart) |
|
|
{ |
|
|
{ |
|
|
if (rowIndex < SimulatorEngine.getPathSize() - 1) |
|
|
if (rowIndex < SimulatorEngine.getPathSize() - 1) |
|
|
{ |
|
|
{ |
|
|
@ -2750,10 +2780,20 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect |
|
|
{ |
|
|
{ |
|
|
return "..."; |
|
|
return "..."; |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if (cumulativeTimeStart <= columnIndex && columnIndex < rewardStart) |
|
|
|
|
|
{ |
|
|
|
|
|
if (rowIndex < SimulatorEngine.getPathSize() - 1) |
|
|
|
|
|
{ |
|
|
|
|
|
return new Double(SimulatorEngine.getCumulativeTimeSpentInPathState(rowIndex)); |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
return "..."; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
else if (rewardStart <= columnIndex) |
|
|
else if (rewardStart <= columnIndex) |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
RewardStructure reward = (RewardStructure)view.getVisibleRewards().get(columnIndex - rewardStart); |
|
|
RewardStructure reward = (RewardStructure)view.getVisibleRewards().get(columnIndex - rewardStart); |
|
|
Object objValue = reward.getValue(rowIndex, (rowIndex == SimulatorEngine.getPathSize() - 1)); |
|
|
Object objValue = reward.getValue(rowIndex, (rowIndex == SimulatorEngine.getPathSize() - 1)); |
|
|
|
|
|
|
|
|
|