From ec1eec4e9f6ea607486ab4354768b727b3f68f0c Mon Sep 17 00:00:00 2001 From: Ludovic Apvrille <ludovic.apvrille@telecom-paristech.fr> Date: Mon, 3 May 2010 11:46:20 +0000 Subject: [PATCH] Update on interactive simulation --- src/ui/MainGUI.java | 8 +++ src/ui/TDiagramPanel.java | 1 + src/ui/TGComponent.java | 65 ++++++++++--------- .../JFrameInteractiveSimulation.java | 12 +++- 4 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/ui/MainGUI.java b/src/ui/MainGUI.java index 6c7b290f63..656293f192 100755 --- a/src/ui/MainGUI.java +++ b/src/ui/MainGUI.java @@ -5443,6 +5443,14 @@ public class MainGUI implements ActionListener, WindowListener, KeyListener { } } + public void setTransationProgression(boolean b) { + TDiagramPanel.DIPLO_TRANSACTION_PROGRESSION_ON = b; + TDiagramPanel tdp = getCurrentTDiagramPanel(); + if (tdp != null) { + tdp.repaint(); + } + } + public synchronized RunningInfo isRunningID(int id) { if (runningIDs == null) { return null; diff --git a/src/ui/TDiagramPanel.java b/src/ui/TDiagramPanel.java index b3c6832d1c..6ceb138e60 100755 --- a/src/ui/TDiagramPanel.java +++ b/src/ui/TDiagramPanel.java @@ -191,6 +191,7 @@ public abstract class TDiagramPanel extends JPanel implements GenericTree { // DIPLO ID -> for simulation purpose public static boolean DIPLO_ID_ON; + public static boolean DIPLO_TRANSACTION_PROGRESSION_ON; // Constructor public TDiagramPanel(MainGUI _mgui, TToolBar _ttb) { diff --git a/src/ui/TGComponent.java b/src/ui/TGComponent.java index bbfff0860b..3abf176f18 100755 --- a/src/ui/TGComponent.java +++ b/src/ui/TGComponent.java @@ -469,45 +469,48 @@ public abstract class TGComponent implements CDElement, GenericTree { g.fillPolygon(xp, yp, 7); String s, s1, s2; - if (ri.progression != null) { - s = ri.progression + "%"; - } else { - s = ""; - } - int ww = g.getFontMetrics().stringWidth(s); - - if (ri.startTime != null) { - g.drawString(ri.startTime, x - sep - wb -wh, y + ((height-hb) / 2) - 1); - } - g.drawString(s, x - sep - wb -wh -ww, y + 4 + ((height) / 2)); - if (ri.finishTime != null) { - s = ri.finishTime; - if (s.compareTo("-1") == 0) { - s = "?"; - } - g.drawString(s, x - sep - wb -wh, y + ((height+hb) / 2) + 10); - } - // Transaction - if (ri.transStartTime != null) { - g.setColor(ColorManager.DIPLOID); - s1 = ri.transStartTime; - if (s1.compareTo("-1") == 0) { - s1 = "?/?"; + if (TDiagramPanel.DIPLO_TRANSACTION_PROGRESSION_ON) { + if (ri.progression != null) { + s = ri.progression + "%"; } else { - s2 = ri.transFinishTime; - if (s2 == null) { - s1 = s1 + "/?"; + s = ""; + } + int ww = g.getFontMetrics().stringWidth(s); + + if (ri.startTime != null) { + g.drawString(ri.startTime, x - sep - wb -wh, y + ((height-hb) / 2) - 1); + } + g.drawString(s, x - sep - wb -wh -ww, y + 4 + ((height) / 2)); + if (ri.finishTime != null) { + s = ri.finishTime; + if (s.compareTo("-1") == 0) { + s = "?"; + } + g.drawString(s, x - sep - wb -wh, y + ((height+hb) / 2) + 10); + } + + // Transaction + if (ri.transStartTime != null) { + g.setColor(ColorManager.DIPLOID); + s1 = ri.transStartTime; + if (s1.compareTo("-1") == 0) { + s1 = "?/?"; } else { - if (s1.compareTo("-1") == 0) { + s2 = ri.transFinishTime; + if (s2 == null) { s1 = s1 + "/?"; } else { - s1 = s1 + "/" + s2; + if (s1.compareTo("-1") == 0) { + s1 = s1 + "/?"; + } else { + s1 = s1 + "/" + s2; + } } } + g.drawString(s1, x - sep - wb -wh + 2, y + 4 + ((height) / 2)); + } - g.drawString(s1, x - sep - wb -wh + 2, y + 4 + ((height) / 2)); - } } diff --git a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java index d5f65d7707..edbc70af53 100755 --- a/src/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -119,7 +119,7 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene // Commands JPanel main, mainTop, commands, save, state, infos, outputs, cpuPanel, variablePanel; // from MGUI - JCheckBox latex, debug, animate, update, openDiagram; + JCheckBox latex, debug, animate, update, openDiagram, animateWithInfo; JTabbedPane commandTab, infoTab; protected JTextField paramMainCommand; protected JTextField saveFileName; @@ -597,6 +597,10 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene jp01.add(animate, c01); animate.addItemListener(this); animate.setSelected(true); + animateWithInfo = new JCheckBox("Show transaction progression on UML diagrams"); + jp01.add(animateWithInfo, c01); + animateWithInfo.addItemListener(this); + animateWithInfo.setSelected(true); update = new JCheckBox("Automatically update information (task, CPU, etc.)"); jp01.add(update, c01); update.addItemListener(this); @@ -1413,6 +1417,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene hashOK = true; animate.setSelected(true); animate.setEnabled(true); + animateWithInfo.setSelected(true); + animateWithInfo.setEnabled(true); openDiagram.setEnabled(true); cpus.setEnabled(true); busses.setEnabled(true); @@ -1436,6 +1442,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene openDiagram.setEnabled(false); animate.setEnabled(false); animate.setSelected(false); + animateWithInfo.setSelected(false); + animateWithInfo.setEnabled(false); update.setEnabled(false); update.setSelected(false); @@ -2058,6 +2066,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene public void itemStateChanged(ItemEvent e) { if (e.getSource() == animate) { mgui.setDiploIDs(animate.isSelected()); + } else if (e.getSource() == animateWithInfo) { + mgui.setTransationProgression(animateWithInfo.isSelected()); } } -- GitLab