diff --git a/prism/src/userinterface/simulator/GUISimulator.java b/prism/src/userinterface/simulator/GUISimulator.java index db34ad59..e0bec79d 100644 --- a/prism/src/userinterface/simulator/GUISimulator.java +++ b/prism/src/userinterface/simulator/GUISimulator.java @@ -44,8 +44,7 @@ import javax.swing.event.*; * @author Andrew Hinton */ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelectionListener, PrismSettingsListener -{ - +{ //ATTRIBUTES private GUIPrism gui; //reference to the gui 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 hideEmptyRewards; private boolean showTime; - + private boolean showCumulativeTime; + public SimulationView() { this.visibleVariables = new ArrayList(); @@ -2398,10 +2398,28 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect { 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) { - this.showTime = stepsVisible; + this.showTime = showTime; + + this.setChanged(); + this.notifyObservers(); + } + + public void showCumulativeTime(boolean showCumulativeTime) + { + this.showCumulativeTime = showCumulativeTime; this.setChanged(); this.notifyObservers(); @@ -2464,6 +2482,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect stepsVisible = true; hideEmptyRewards = true; showTime = mf.getType() == ModulesFile.STOCHASTIC; + showCumulativeTime = false; 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) { groupCount++; } - if (view.showTime()) + if (view.showTime() || view.showCumulativeTime()) { groupCount++; } if (view.getVisibleRewards().size() > 0) @@ -2562,7 +2581,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect groupCount++; } - if (view.showTime()) + if (view.showTime() || view.showCumulativeTime()) { if (groupCount == groupIndex) { return "Time"; } @@ -2588,7 +2607,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect int stepStart = 0; int varStart = stepStart + (view.showSteps() ? 1 : 0); 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; @@ -2608,10 +2627,15 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect groupCount++; } - if (view.showTime()) + if (view.showTime() || view.showCumulativeTime()) { if (groupCount == groupIndex) - { return timeStart; } + { + if (view.showTime() && view.showCumulativeTime()) + return timeStart + 1; + else + return timeStart; + } groupCount++; } @@ -2642,7 +2666,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect colCount += (view.showSteps() ? 1 : 0); colCount += view.getVisibleVariables().size(); - colCount += (view.showTime() ? 1 : 0); + colCount += (view.showTime() ? 1 : 0) + (view.showCumulativeTime() ? 1 : 0); colCount += view.getVisibleRewards().size(); return colCount; @@ -2687,7 +2711,8 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect int stepStart = 0; int varStart = stepStart + (view.showSteps() ? 1 : 0); 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 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(); } - else if (timeStart <= columnIndex && columnIndex < rewardStart) + else if (timeStart <= columnIndex && columnIndex < cumulativeTimeStart) { return "Time"; } + else if (cumulativeTimeStart <= columnIndex && columnIndex < rewardStart) + { + return "Time (+)"; + } else if (rewardStart <= columnIndex) { return ((RewardStructure)view.getVisibleRewards().get(columnIndex - rewardStart)).getColumnName(); @@ -2720,7 +2749,8 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect int stepStart = 0; int varStart = stepStart + (view.showSteps() ? 1 : 0); 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 if (stepStart <= columnIndex && columnIndex < varStart) @@ -2740,7 +2770,7 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect else if (type == Expression.INT) { return new Integer(result); } } - else if (timeStart <= columnIndex && columnIndex < rewardStart) + else if (timeStart <= columnIndex && columnIndex < cumulativeTimeStart) { if (rowIndex < SimulatorEngine.getPathSize() - 1) { @@ -2750,10 +2780,20 @@ public class GUISimulator extends GUIPlugin implements MouseListener, ListSelect { return "..."; } + } + else if (cumulativeTimeStart <= columnIndex && columnIndex < rewardStart) + { + if (rowIndex < SimulatorEngine.getPathSize() - 1) + { + return new Double(SimulatorEngine.getCumulativeTimeSpentInPathState(rowIndex)); + } + else + { + return "..."; + } } else if (rewardStart <= columnIndex) - { - + { RewardStructure reward = (RewardStructure)view.getVisibleRewards().get(columnIndex - rewardStart); Object objValue = reward.getValue(rowIndex, (rowIndex == SimulatorEngine.getPathSize() - 1)); diff --git a/prism/src/userinterface/simulator/GUIViewDialog.form b/prism/src/userinterface/simulator/GUIViewDialog.form index cf323ad5..c596a530 100644 --- a/prism/src/userinterface/simulator/GUIViewDialog.form +++ b/prism/src/userinterface/simulator/GUIViewDialog.form @@ -583,6 +583,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/prism/src/userinterface/simulator/GUIViewDialog.java b/prism/src/userinterface/simulator/GUIViewDialog.java index 88d0e74f..bb2a6dbb 100644 --- a/prism/src/userinterface/simulator/GUIViewDialog.java +++ b/prism/src/userinterface/simulator/GUIViewDialog.java @@ -69,6 +69,7 @@ public class GUIViewDialog extends JDialog implements KeyListener private javax.swing.JScrollPane hiddenRewardScrollList; private javax.swing.JList hiddenVariableList; private javax.swing.JScrollPane hiddenVariableScrollList; + private javax.swing.JPanel innerTimePanel; private javax.swing.JPanel leftRewardColumn; private javax.swing.JPanel leftRewardPanel; private javax.swing.JPanel leftVariableColumn; @@ -90,6 +91,11 @@ public class GUIViewDialog extends JDialog implements KeyListener private javax.swing.JButton selectAllHiddenVariablesButton; private javax.swing.JButton selectAllVisibleRewardsButton; private javax.swing.JButton selectAllVisibleVariablesButton; + private javax.swing.JCheckBox showCumulativeTimeCheckBox; + private javax.swing.JCheckBox showTimeCheckBox; + private javax.swing.JPanel timePanel; + private javax.swing.JPanel timeTabPanel; + private javax.swing.JPanel topInnerTimePanel; private javax.swing.JPanel variablePanel; private javax.swing.JTabbedPane variableTabPane; private javax.swing.JPanel variableTabPanel; @@ -120,6 +126,9 @@ public class GUIViewDialog extends JDialog implements KeyListener this.askOption = ((GUIPrism)this.getParent()).getPrism().getSettings().getBoolean(PrismSettings.SIMULATOR_NEW_PATH_ASK_VIEW); optionCheckBox.setSelected(this.askOption); + showTimeCheckBox.setSelected(view.showTime()); + showCumulativeTimeCheckBox.setSelected(view.showCumulativeTime()); + visibleVariableListModel = new VariableListModel(view.getVisibleVariables()); hiddenVariableListModel = new VariableListModel(view.getHiddenVariables()); @@ -133,6 +142,7 @@ public class GUIViewDialog extends JDialog implements KeyListener hiddenRewardList.setModel(hiddenRewardListModel); emptyRewardVisibleCheckBox.setSelected(!view.hideEmptyRewards()); + variableTabPane.setEnabledAt(2, view.canShowTime()); this.setVisible(true); } @@ -189,6 +199,12 @@ public class GUIViewDialog extends JDialog implements KeyListener selectAllHiddenRewardsButton = new javax.swing.JButton(); rewardOptionPanel = new javax.swing.JPanel(); emptyRewardVisibleCheckBox = new javax.swing.JCheckBox(); + timeTabPanel = new javax.swing.JPanel(); + timePanel = new javax.swing.JPanel(); + innerTimePanel = new javax.swing.JPanel(); + topInnerTimePanel = new javax.swing.JPanel(); + showTimeCheckBox = new javax.swing.JCheckBox(); + showCumulativeTimeCheckBox = new javax.swing.JCheckBox(); visibleLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); visibleLabel.setText("Visible Variables"); @@ -472,6 +488,42 @@ public class GUIViewDialog extends JDialog implements KeyListener variableTabPane.addTab("Reward visibility", rewardTabPanel); + timeTabPanel.setLayout(new java.awt.BorderLayout()); + + timePanel.setLayout(new java.awt.GridBagLayout()); + + timePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + innerTimePanel.setLayout(new java.awt.BorderLayout()); + + innerTimePanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Time properties")); + topInnerTimePanel.setLayout(new java.awt.GridLayout(2, 1, 5, 5)); + + topInnerTimePanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); + showTimeCheckBox.setText("Show the time spend in states"); + showTimeCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + showTimeCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); + topInnerTimePanel.add(showTimeCheckBox); + showTimeCheckBox.getAccessibleContext().setAccessibleName(""); + + showCumulativeTimeCheckBox.setText("Show the cumulative time"); + showCumulativeTimeCheckBox.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); + showCumulativeTimeCheckBox.setMargin(new java.awt.Insets(0, 0, 0, 0)); + topInnerTimePanel.add(showCumulativeTimeCheckBox); + + innerTimePanel.add(topInnerTimePanel, java.awt.BorderLayout.NORTH); + + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.gridwidth = 2; + gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; + gridBagConstraints.weightx = 0.5; + gridBagConstraints.weighty = 1.0; + timePanel.add(innerTimePanel, gridBagConstraints); + + timeTabPanel.add(timePanel, java.awt.BorderLayout.CENTER); + variableTabPane.addTab("Time", timeTabPanel); + getContentPane().add(variableTabPane, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents @@ -586,7 +638,10 @@ public class GUIViewDialog extends JDialog implements KeyListener ((GUIPrism)this.getParent()).getPrism().getSettings().set(PrismSettings.SIMULATOR_NEW_PATH_ASK_VIEW, this.askOption); } catch (PrismException e) {} - } + } + + view.showTime(showTimeCheckBox.isSelected()); + view.showCumulativeTime(showCumulativeTimeCheckBox.isSelected()); view.setVariableVisibility(visibleVariableListModel.getVariables(), hiddenVariableListModel.getVariables()); view.setRewardVisibility(visibleRewardListModel.getRewards(), hiddenRewardListModel.getRewards());