From 29d7f80740fcb2b7e3ca789d14962535dc19d508 Mon Sep 17 00:00:00 2001
From: Florian Lugou <florian.lugou@telecom-paristech.fr>
Date: Mon, 19 Jun 2017 17:37:08 +0200
Subject: [PATCH] fixed bug with simulation window (index out of range)

---
 .../GenericTransaction.java                   |   14 +-
 .../JSimulationSDPanel.java                   | 1687 ++++++++---------
 2 files changed, 841 insertions(+), 860 deletions(-)

diff --git a/src/main/java/ui/interactivesimulation/GenericTransaction.java b/src/main/java/ui/interactivesimulation/GenericTransaction.java
index 1282d277c1..6a27ca9168 100755
--- a/src/main/java/ui/interactivesimulation/GenericTransaction.java
+++ b/src/main/java/ui/interactivesimulation/GenericTransaction.java
@@ -50,14 +50,12 @@ package ui.interactivesimulation;
  */
 public class GenericTransaction  {
 
-    public final static int NOT_DEFINED = 0;
-    public final static int FUNCTION_CALL = 1;
-    public final static int STATE_ENTERING = 2;
-    public final static int VAR_MODIFICATION = 3;
-    public final static int SEND_SYNCHRO = 4;
-    public final static int SYNCHRO = 5;
-    public final static int SEND_ASYNCHRO = 6;
-    public final static int RECEIVE_ASYNCHRO = 7;
+    final static int FUNCTION_CALL = 1;
+    final static int STATE_ENTERING = 2;
+    final static int SEND_SYNCHRO = 4;
+    final static int SYNCHRO = 5;
+    final static int SEND_ASYNCHRO = 6;
+    final static int RECEIVE_ASYNCHRO = 7;
 
     public int ID;
     public int type;
diff --git a/src/main/java/ui/interactivesimulation/JSimulationSDPanel.java b/src/main/java/ui/interactivesimulation/JSimulationSDPanel.java
index f7c44f444c..6dd0931771 100644
--- a/src/main/java/ui/interactivesimulation/JSimulationSDPanel.java
+++ b/src/main/java/ui/interactivesimulation/JSimulationSDPanel.java
@@ -57,516 +57,503 @@ import java.util.Hashtable;
 import java.util.Vector;
 
 /**
-* Class JSimulationSDPanel
-* Generic panel for displaying simulation transactions in the form
-* of a Sequence Diagram
-* Creation: 26/05/2011
-* @version 1.0 26/05/2011
-* @author Ludovic APVRILLE
+ * Class JSimulationSDPanel
+ * Generic panel for displaying simulation transactions in the form
+ * of a Sequence Diagram
+ * Creation: 26/05/2011
+ * @version 1.0 26/05/2011
+ * @author Ludovic APVRILLE
  */
 public class JSimulationSDPanel extends JPanel implements MouseMotionListener, Runnable  {
-	
-	private static int MAX_X = 800;
-	private static int MAX_Y = 200;
-	private static long stamp = 0;
-	
-	// Drawing area
-	private int minLimit = 10;
-	private int maxX = MAX_X;
-	private int maxY = MAX_Y;
-	private final int limit = 10;
-	
-	// Drawing parameters
-	private int minSpaceBetweenLifeLines = 5;
-	private int spaceBetweenLifeLines = 150;
-	private boolean spaceBetweenLifeLinesComputed = false;
-	private int spaceAtEnd = 50;
-	private int spaceAtTop = 50;
-	private int verticalSpaceUnderBlocks = 15;
-	private int spaceVerticalText = 2;
-	private int spaceHorizontalText = 2;
-	private int spaceStop = 20;
-	private int verticalLink = 10;
-	private int lengthAsync = 50;
-	private int spaceBroadcast = 25;
-	
-	// Transactions
-        private BufferedReader inputStream;
-        private String fileReference;
-	
-	private int maxNbOfTransactions = 10000;
-	private int drawnTransactions = 10000;
-	
-	// My scroll panel
-	private JScrollPane jsp;
-	private boolean mustScroll = true;
-	
-	// Mouse
-	private int xMouse, yMouse;
-	private boolean drawInfo = false;
-	private long clockValueMouse;
-	private long clockDiviser = 1000000; //ms
-	private Vector<Point> points;
-	private Vector<GenericTransaction> transactionsOfPoints;
-	private Hashtable<String, Point> asyncMsgs;
-	
-	// List of entities ... List is discovered progressively
-	// Or the list is described in the trace (header information)
-	Vector <String> entityNames;
-	
-	private final int NO_MODE = 0;
-	private final int FILE_MODE = 1;
-	private final int STREAM_MODE = 2;
-	private int mode;
-	private boolean go;
-	private Thread t;
-	
-	private int excluOnList = 1; 
-	
-	Vector<GenericTransaction> transactions;
-	
-	JFrameSimulationSDPanel jfssdp;
-	
-	
-	public JSimulationSDPanel(JFrameSimulationSDPanel _jfssdp) {
-		//points = new Vector<Point>();
-		//transactionsOfPoints = new Vector<AvatarSimulationTransaction>();
-		jfssdp = _jfssdp;
-		
-		entityNames = new Vector <String>();
-		transactions = new Vector<GenericTransaction>();
-		transactionsOfPoints = new Vector<GenericTransaction>();
-		points = new Vector<Point>();
-		
-		asyncMsgs = new Hashtable<String, Point>();
-		
-		mode = NO_MODE;
-		
-		setBackground(Color.WHITE);
-		setNewSize();
-		addMouseMotionListener(this);
-		
-	}
-	
-	//Return true iff exclu was obtained
-	private synchronized boolean tryToGetExclu() {
-		if (excluOnList == 1) {
-			excluOnList = 0;
-			return true;
-		}
-		return false;
-	}
-	
-	private synchronized void getExclu() {
-		//TraceManager.addDev("Trying to get exlu");
-		while(excluOnList == 0) {
-			try {
-				//TraceManager.addDev("Waiting");
-				wait();
-			} catch (Exception e) {
-			}
-		}
-		//TraceManager.addDev("got the exlu");
-		excluOnList = 0;
-	}
-	
-	private synchronized void removeExclu() {
-		excluOnList = 1;
-		notifyAll();
-	}
-	
-	public void setMyScrollPanel(JScrollPane _jsp) {
-		jsp = _jsp;
-	}
 
-        public void resized() {
-            this.spaceBetweenLifeLinesComputed = false;
-            this.repaint();
+    private static int MAX_X = 800;
+    private static int MAX_Y = 200;
+    private static long stamp = 0;
+
+    private int maxX = MAX_X;
+    private int maxY = MAX_Y;
+    private final static int limit = 10;
+
+    // Drawing parameters
+    private final static int minSpaceBetweenLifeLines = 5;
+    private final static int verticalSpaceUnderBlocks = 15;
+    private int spaceBetweenLifeLines = 150;
+    private boolean spaceBetweenLifeLinesComputed = false;
+    private int spaceAtEnd = 50;
+    private int spaceAtTop = 50;
+    private int spaceVerticalText = 2;
+    private int spaceHorizontalText = 2;
+    private int verticalLink = 10;
+
+    // Transactions
+    private BufferedReader inputStream;
+    private String fileReference;
+
+    private int drawnTransactions = 10000;
+
+    // My scroll panel
+    private JScrollPane jsp;
+    private boolean mustScroll = true;
+
+    private int yMouse;
+    private boolean drawInfo = false;
+    private long clockValueMouse;
+    private long clockDiviser = 1000000; //ms
+    private Vector<Point> points;
+    private Vector<GenericTransaction> transactionsOfPoints;
+    private Hashtable<String, Point> asyncMsgs;
+
+    // List of entities ... List is discovered progressively
+    // Or the list is described in the trace (header information)
+    private Vector <String> entityNames;
+
+    private final int NO_MODE = 0;
+    private final int FILE_MODE = 1;
+    private final int STREAM_MODE = 2;
+    private int mode;
+
+    private int excluOnList = 1;
+
+    private Vector<GenericTransaction> transactions;
+
+    private JFrameSimulationSDPanel jfssdp;
+
+
+    JSimulationSDPanel(JFrameSimulationSDPanel _jfssdp) {
+        //points = new Vector<Point>();
+        //transactionsOfPoints = new Vector<AvatarSimulationTransaction>();
+        jfssdp = _jfssdp;
+
+        entityNames = new Vector <>();
+        transactions = new Vector<>();
+        transactionsOfPoints = new Vector<>();
+        points = new Vector<>();
+
+        asyncMsgs = new Hashtable<>();
+
+        mode = NO_MODE;
+
+        setBackground(Color.WHITE);
+        setNewSize();
+        addMouseMotionListener(this);
+
+    }
+
+    //Return true iff exclu was obtained
+    private synchronized boolean tryToGetExclu() {
+        if (excluOnList == 1) {
+            excluOnList = 0;
+            return true;
         }
-	
-	protected void paintComponent(Graphics g) {
-		super.paintComponent(g);
-		int currentY = spaceAtTop;
-		int currentX = spaceAtEnd;
-		int oldMaxY = maxY;
-		int oldMaxX = maxX;
-		
-		boolean mustDraw = tryToGetExclu();
-		if (mustDraw) {
-			if (!spaceBetweenLifeLinesComputed) {
-				computeSpaceBetweenLifeLines(g);
-			}
-			
-			
-			currentY = paintTopElements(g, currentX, currentY);
-			paintTransactions(g, currentX, currentY);
-			stamp ++;
-			
-			if ((oldMaxY != maxY) || (oldMaxX != maxX)) {
-				maxX = Math.max(maxX, MAX_X);
-				maxY = Math.max(maxY, MAX_Y);
-				if ((oldMaxY != maxY) || (oldMaxX != maxX)) {
-					setNewSize();
-					//repaint();
-				}
-			} else {
-				if (mustScroll) {
-					scrollToLowerPosition();
-					mustScroll = false;
-				}
-			}
-			
-			if (drawInfo) {
-				drawInfo(g);
-			}
-			
-			removeExclu();
-		}
-	}
-	
-	protected void scrollToLowerPosition() {
-		if (jsp != null) {
-			jsp.getVerticalScrollBar().setValue(jsp.getVerticalScrollBar().getMaximum());
-		}
-	}
-	
-	// Returns the currentY position
-	protected int paintTopElements(Graphics g, int currentX, int currentY) {
-		int w;
-		
-		for(String name : entityNames) {
-			g.drawLine(currentX + (spaceBetweenLifeLines/4), currentY, currentX + (3*spaceBetweenLifeLines/4), currentY);
-			g.drawLine(currentX + (spaceBetweenLifeLines/2), currentY, currentX + (spaceBetweenLifeLines/2), currentY + verticalSpaceUnderBlocks);
-			w = g.getFontMetrics().stringWidth(name);
-			g.drawString(name, currentX + ((spaceBetweenLifeLines-w)/2), currentY - spaceVerticalText);
-			currentX += spaceBetweenLifeLines;
-		}
-		
-		maxX = currentX;
-		
-		return currentY + verticalSpaceUnderBlocks;
-	}
-	
-	private void computeSpaceBetweenLifeLines(Graphics g) {
-		int w;
-		
-		spaceBetweenLifeLinesComputed = true;
-		
-		for(String name : entityNames) {
-			w = g.getFontMetrics().stringWidth(name);
-			if ((w+minSpaceBetweenLifeLines) > spaceBetweenLifeLines) {
-				spaceBetweenLifeLines = w+minSpaceBetweenLifeLines;
-			}
-		}
-
-                for (GenericTransaction gt: this.transactions) {
-                    if (gt.type == GenericTransaction.SYNCHRO) {
-		        String messageName = gt.name + "(" + gt.params + ")";
-                        w = g.getFontMetrics().stringWidth(messageName);
-                        if (w+this.minSpaceBetweenLifeLines > this.spaceBetweenLifeLines)
-                            this.spaceBetweenLifeLines = w+this.minSpaceBetweenLifeLines;
+        return false;
+    }
+
+    private synchronized void getExclu() {
+        //TraceManager.addDev("Trying to get exlu");
+        while(excluOnList == 0) {
+            try {
+                //TraceManager.addDev("Waiting");
+                wait();
+            } catch (Exception ignored) {
+            }
+        }
+        //TraceManager.addDev("got the exlu");
+        excluOnList = 0;
+    }
+
+    private synchronized void removeExclu() {
+        excluOnList = 1;
+        notifyAll();
+    }
+
+    void setMyScrollPanel(JScrollPane _jsp) {
+        jsp = _jsp;
+    }
+
+    void resized() {
+        this.spaceBetweenLifeLinesComputed = false;
+        this.repaint();
+    }
+
+    protected void paintComponent(Graphics g) {
+        super.paintComponent(g);
+        int currentY = spaceAtTop;
+        int currentX = spaceAtEnd;
+        int oldMaxY = maxY;
+        int oldMaxX = maxX;
+
+        boolean mustDraw = tryToGetExclu();
+        if (mustDraw) {
+            if (!spaceBetweenLifeLinesComputed) {
+                computeSpaceBetweenLifeLines(g);
+            }
+
+
+            currentY = paintTopElements(g, currentX, currentY);
+            paintTransactions(g, currentX, currentY);
+            stamp ++;
+
+            if ((oldMaxY != maxY) || (oldMaxX != maxX)) {
+                maxX = Math.max(maxX, MAX_X);
+                maxY = Math.max(maxY, MAX_Y);
+                if ((oldMaxY != maxY) || (oldMaxX != maxX)) {
+                    setNewSize();
+                    //repaint();
+                }
+            } else {
+                if (mustScroll) {
+                    scrollToLowerPosition();
+                    mustScroll = false;
+                }
+            }
+
+            if (drawInfo) {
+                drawInfo(g);
+            }
+
+            removeExclu();
+        }
+    }
+
+    private void scrollToLowerPosition() {
+        if (jsp != null) {
+            jsp.getVerticalScrollBar().setValue(jsp.getVerticalScrollBar().getMaximum());
+        }
+    }
+
+    // Returns the currentY position
+    private int paintTopElements(Graphics g, int currentX, int currentY) {
+        int w;
+
+        for(String name : entityNames) {
+            g.drawLine(currentX + (spaceBetweenLifeLines/4), currentY, currentX + (3*spaceBetweenLifeLines/4), currentY);
+            g.drawLine(currentX + (spaceBetweenLifeLines/2), currentY, currentX + (spaceBetweenLifeLines/2), currentY + verticalSpaceUnderBlocks);
+            w = g.getFontMetrics().stringWidth(name);
+            g.drawString(name, currentX + ((spaceBetweenLifeLines-w)/2), currentY - spaceVerticalText);
+            currentX += spaceBetweenLifeLines;
+        }
+
+        maxX = currentX;
+
+        return currentY + verticalSpaceUnderBlocks;
+    }
+
+    private void computeSpaceBetweenLifeLines(Graphics g) {
+        int w;
+
+        spaceBetweenLifeLinesComputed = true;
+
+        for(String name : entityNames) {
+            w = g.getFontMetrics().stringWidth(name);
+            if ((w+minSpaceBetweenLifeLines) > spaceBetweenLifeLines) {
+                spaceBetweenLifeLines = w+minSpaceBetweenLifeLines;
+            }
+        }
+
+        for (GenericTransaction gt: this.transactions) {
+            if (gt.type == GenericTransaction.SYNCHRO) {
+                String messageName = gt.name + "(" + gt.params + ")";
+                w = g.getFontMetrics().stringWidth(messageName);
+                if (w+ minSpaceBetweenLifeLines > this.spaceBetweenLifeLines)
+                    this.spaceBetweenLifeLines = w+ minSpaceBetweenLifeLines;
+            }
+        }
+
+        int m = this.getSize().width / (this.entityNames.size()+1);
+        if (this.spaceBetweenLifeLines > m)
+            this.spaceBetweenLifeLines = m;
+    }
+
+    private void setNewSize() {
+        setPreferredSize(new Dimension(maxX + limit, maxY + limit));
+        mustScroll = true;
+        revalidate();
+    }
+
+    public void limitShownTransactions(int limit) {
+        this.drawnTransactions = limit;
+    }
+
+    // returns the currentY position
+    private void paintTransactions(Graphics g, int currentX, int currentY) {
+        long clockValue = -1;
+        int index;
+        int xOfBlock;
+        int newCurrentY = currentY;
+        GenericTransaction gt;
+
+
+        if (transactions.size() == 0) {
+            return;
+        }
+
+        // Draw only the last "drawnTransactions"
+
+        if (transactions.size() > 0) {
+            gt = transactions.get(Math.max(0, transactions.size()-1000));
+            clockValue = gt.startingTime;
+            clockValueMouse = clockValue;
+            g.drawString("@" + clockValue/clockDiviser, 10, currentY+g.getFontMetrics().getHeight()/2);
+        }
+
+        for(int i=Math.max(transactions.size()-drawnTransactions, 0); i<transactions.size(); i++) {
+            gt = transactions.get(i);
+            gt.stamp = stamp;
+
+            index = getIndexOfEntityName(gt.entityName);
+            xOfBlock = currentX + (index * spaceBetweenLifeLines) + spaceBetweenLifeLines/2;
+
+            points.clear();
+            transactionsOfPoints.clear();
+            //TraceManager.addDev("Clearing hash");
+            //asyncMsgs.clear();
+
+            if (gt.type == GenericTransaction.STATE_ENTERING) {
+                newCurrentY = drawState(g, gt, xOfBlock, currentY);
+            }  else if (gt.type == GenericTransaction.FUNCTION_CALL) {
+                newCurrentY = drawFunctionCall(g, gt, xOfBlock, currentY);
+            } else if (gt.type == GenericTransaction.SEND_SYNCHRO) {
+                //newCurrentY = drawSendSynchro(g, gt, xOfBlock, currentY);
+            } else if (gt.type == GenericTransaction.SYNCHRO) {
+                newCurrentY = drawSendSynchro(g, gt, xOfBlock, currentY);
+            } else if (gt.type == GenericTransaction.SEND_ASYNCHRO) {
+                newCurrentY = drawSendAsynchro(g, gt, xOfBlock, currentY);
+            } else if (gt.type == GenericTransaction.RECEIVE_ASYNCHRO) {
+                newCurrentY = drawReceiveAsynchro(g, gt, xOfBlock, currentY);
+            }
+
+            if ((yMouse>= currentY) && (yMouse <= newCurrentY)) {
+                for(int cpt = 0; cpt<points.size(); cpt++) {
+                    drawIDInfo(g, points.get(cpt).x, points.get(cpt).y, transactionsOfPoints.get(cpt).ID);
+                }
+            }
+
+
+            // Draw the line of other blocks
+            if (currentY != newCurrentY) {
+                xOfBlock = currentX + spaceBetweenLifeLines/2;
+                for(String s: entityNames) {
+                    if (s.compareTo(gt.entityName) != 0) {
+                        g.drawLine(xOfBlock, currentY, xOfBlock, newCurrentY);
                     }
+                    xOfBlock += spaceBetweenLifeLines;
                 }
+                if (gt.finishTime != clockValue) {
+                    boolean alsoText = false;
+                    if ((gt.finishTime / clockDiviser) != (clockValue / clockDiviser)) {
+                        alsoText = true;
+                    }
+                    clockValue = gt.finishTime;
+                    if (yMouse >= newCurrentY) {
+                        clockValueMouse = clockValue;
+                    }
+                    if (alsoText) {
+                        g.drawString("@" + clockValue/clockDiviser, 10, newCurrentY+g.getFontMetrics().getHeight()/2);
+                    }
+                }
+            }
 
-                int m = this.getSize().width / (this.entityNames.size()+1);
-                if (this.spaceBetweenLifeLines > m)
-                    this.spaceBetweenLifeLines = m;
-	}
-	
-	public void setNewSize() {
-		setPreferredSize(new Dimension(maxX + limit, maxY + limit));
-		mustScroll = true;
-		revalidate();
-	}
-	
-	// returns the currentY position
-	protected int paintTransactions(Graphics g, int currentX, int currentY) {
-		long clockValue = -1;
-		int index;
-		int xOfBlock;
-		int newCurrentY = currentY;
-		GenericTransaction gt;
-		
-		
-		if (transactions.size() == 0) {
-			return currentY;
-		}
-		
-		// Draw only the last "drawnTransactions"
-		
-		if (transactions.size() > 0) {
-			gt = transactions.get(Math.max(0, transactions.size()-1000));
-			clockValue = gt.startingTime;
-			clockValueMouse = clockValue;
-			g.drawString("@" + clockValue/clockDiviser, 10, currentY+g.getFontMetrics().getHeight()/2); 
-		}
-		
-		for(int i=Math.max(transactions.size()-drawnTransactions, 0); i<transactions.size(); i++) {
-			gt = transactions.get(i);
-			gt.stamp = stamp;
-			
-			index = getIndexOfEntityName(gt.entityName);
-			xOfBlock = currentX + (index * spaceBetweenLifeLines) + spaceBetweenLifeLines/2;
-			
-			points.clear();
-			transactionsOfPoints.clear();
-			//TraceManager.addDev("Clearing hash");
-			//asyncMsgs.clear();
-			
-			
-			if (gt.type == GenericTransaction.STATE_ENTERING) {
-				newCurrentY = drawState(g, gt, xOfBlock, currentY); 
-			}  else if (gt.type == GenericTransaction.FUNCTION_CALL) {
-				newCurrentY = drawFunctionCall(g, gt, xOfBlock, currentY); 
-			} else if (gt.type == GenericTransaction.SEND_SYNCHRO) {
-				//newCurrentY = drawSendSynchro(g, gt, xOfBlock, currentY); 
-			} else if (gt.type == GenericTransaction.SYNCHRO) {
-				newCurrentY = drawSendSynchro(g, gt, xOfBlock, currentY); 
-			} else if (gt.type == GenericTransaction.SEND_ASYNCHRO) {
-				newCurrentY = drawSendAsynchro(g, gt, xOfBlock, currentY); 
-			} else if (gt.type == GenericTransaction.RECEIVE_ASYNCHRO) {
-				newCurrentY = drawReceiveAsynchro(g, gt, xOfBlock, currentY); 
-			} 
-			
-			if ((yMouse>= currentY) && (yMouse <= newCurrentY)) {
-				for(int cpt = 0; cpt<points.size(); cpt++) {
-					drawIDInfo(g, points.get(cpt).x, points.get(cpt).y, transactionsOfPoints.get(cpt).ID);
-				}
-			}
-			
-			
-			// Draw the line of other blocks
-			if (currentY != newCurrentY) {
-				xOfBlock = currentX + spaceBetweenLifeLines/2;
-				for(String s: entityNames) {
-					if (s.compareTo(gt.entityName) != 0) {
-						g.drawLine(xOfBlock, currentY, xOfBlock, newCurrentY);
-					}
-					xOfBlock += spaceBetweenLifeLines;
-				}
-				if (gt.finishTime != clockValue) {
-					boolean alsoText = false;
-					if ((gt.finishTime / clockDiviser) != (clockValue / clockDiviser)) {
-						alsoText = true;
-					}
-					clockValue = gt.finishTime;
-					if (yMouse >= newCurrentY) {
-						clockValueMouse = clockValue;
-					}
-					if (alsoText) {
-						g.drawString("@" + clockValue/clockDiviser, 10, newCurrentY+g.getFontMetrics().getHeight()/2);
-					}
-				}
-			}
-			
-			// Update currentY;
-			currentY = newCurrentY;
-			
-		}
-		maxY = currentY;
-		return currentY;
-	}
-	
-	private int drawState(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
-		int w;
-		int x, y, width, height;
-		
-		g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
-		currentY += verticalLink;
-		
-		w = g.getFontMetrics().stringWidth(_gt.action);
-		Color c = g.getColor();
-		Color avat = ColorManager.AVATAR_STATE;
-		g.setColor(avat);
-		
-		x = currentX - w/2 - spaceHorizontalText;
-		y = currentY;
-		width = w + 2*spaceHorizontalText;
-		height = g.getFontMetrics().getHeight() + spaceVerticalText * 2;
-		
-		g.fillRoundRect(x, y, width, height, 5, 5);
-		points.add(new Point(x+width, y));
-		transactionsOfPoints.add(_gt);
-		g.setColor(c);
-		g.drawRoundRect(x, y, width, height, 5, 5);
-		
-		g.drawString(_gt.action, x + spaceHorizontalText, y+height-2*spaceVerticalText);
-		
-		currentY += height;
-		g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
-		return currentY + verticalLink;
-	}
-	
-	private int drawFunctionCall(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
-		int w;
-		int x, y, width, height;
-		
-		g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
-		currentY += verticalLink;
-		
-		w = g.getFontMetrics().stringWidth(_gt.action);
-		Color c = g.getColor();
-		
-		x = currentX - w/2 - spaceHorizontalText;
-		y = currentY;
-		width = w + 2*spaceHorizontalText;
-		height = g.getFontMetrics().getHeight() + spaceVerticalText * 2;
-		
-		
-		g.setColor(Color.WHITE);
-		g.fillRoundRect(x, y, width, height, 5, 5);
-		g.setColor(c);
-		g.drawRoundRect(x, y, width, height, 5, 5);
-		points.add(new Point(x+width, y));
-		transactionsOfPoints.add(_gt);
-		g.setColor(c);
-		g.drawString(_gt.action, x + spaceHorizontalText, y+height-2*spaceVerticalText);
-		
-		currentY += height;
-		g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
-		return currentY + verticalLink;
-	}
-	
-	private int drawSendSynchro(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
-		int w;
-		int x, y, width, height;
-		String messageName;
-		
-		g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
-		currentY += verticalLink;
-		
-		messageName = _gt.name + "(" + _gt.params + ")";
-		
-		Color c = g.getColor();
-		
-		x = currentX;
-		y = currentY;
-		
-		int index = getIndexOfEntityName(_gt.otherEntityName);
-		int xOf2ndBlock = spaceAtEnd + (index * spaceBetweenLifeLines) + spaceBetweenLifeLines/2;
-		
-		g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
-		g.drawLine(xOf2ndBlock, currentY-1, currentX, currentY-1);
-		g.setColor(c);
-		GraphicLib.arrowWithLine(g, 1, 0, 10, currentX, currentY, xOf2ndBlock, currentY, true);
-		transactionsOfPoints.add(_gt);
-		points.add(new Point(currentX, currentY));
-		
-		// Putting the message name
-		w = g.getFontMetrics().stringWidth(messageName);
-		int xtmp = (xOf2ndBlock + currentX)/2 - w/2;
-		g.drawString(messageName, xtmp, currentY-4); 
-		
-		currentY += 10;
-		
-		// Vertical line of receiving block
-		g.drawLine(currentX, currentY-20, currentX, currentY);
-		return currentY;
-	}
-	
-	private int drawSendAsynchro(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
-		int w;
-		int x, y, width, height;
-		String messageName;
-		
-		g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
-		currentY += verticalLink;
-		
-		messageName = _gt.name + "(" + _gt.params + ")";
-		
-		Color c = g.getColor();
-		
-		x = currentX;
-		y = currentY;
-		
-		int xOf2ndBlock = x + 2*spaceBetweenLifeLines/3;
-		
-		g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
-		g.drawLine(xOf2ndBlock, currentY-1, currentX, currentY-1);
-		g.setColor(c);
-		GraphicLib.arrowWithLine(g, 1, 2, 10, currentX, currentY, xOf2ndBlock, currentY, false);
-		transactionsOfPoints.add(_gt);
-		points.add(new Point(currentX, currentY));
-		//TraceManager.addDev("Putting " + _gt.messageID + " in hash");
-		asyncMsgs.put(_gt.messageID, new Point(currentX, currentY));
-		
-		// Putting the message name
-		w = g.getFontMetrics().stringWidth(messageName);
-		int xtmp = (xOf2ndBlock + currentX)/2 - w/2;
-		g.drawString(messageName, xtmp, currentY-2); 
-		
-		currentY += 10;
-		
-		// Vertical line of receiving block
-		g.drawLine(currentX, currentY-20, currentX, currentY);
-		return currentY;
-	}
-	
-	private int drawReceiveAsynchro(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
-		int w;
-		int x, y, width, height;
-		String messageName;
-		
-		g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
-		currentY += verticalLink;
-		
-		messageName = _gt.name + "(" + _gt.params + ")";
-		
-		Color c = g.getColor();
-		
-		x = currentX;
-		y = currentY;
-		
-		int xOf2ndBlock = x - 2*spaceBetweenLifeLines/3;
-		
-		g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
-		g.drawLine(xOf2ndBlock, currentY-1, currentX, currentY-1);
-		g.setColor(c);
-		GraphicLib.arrowWithLine(g, 1, 2, 10, xOf2ndBlock, currentY, currentX, currentY, false);
-		transactionsOfPoints.add(_gt);
-		points.add(new Point(currentX, currentY));
-		
-		// Putting the message name
-		w = g.getFontMetrics().stringWidth(messageName);
-		int xtmp = (xOf2ndBlock + currentX)/2 - w/2;
-		g.drawString(messageName, xtmp, currentY-2);
-		
-		
-		// Linking to sender?
-		Point p = asyncMsgs.get(_gt.messageID);
-		//TraceManager.addDev("Testing " + _gt.messageID + " in hash = " + p + " hashsize=" + asyncMsgs.size() );
-		if (p != null) {
-			x = p.x;
-			y = p.y;
-			int lengthAsync = 2*spaceBetweenLifeLines/3;
-			
-			if ((x +  lengthAsync) < (currentX-lengthAsync)) {
-				// Forward
-				g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
-				GraphicLib.dashedLine(g, x + lengthAsync - 1, y, x + lengthAsync-1, currentY);
-				GraphicLib.dashedLine(g, x + lengthAsync, currentY-1, currentX-lengthAsync, currentY-1);
-				g.setColor(c);
-				GraphicLib.dashedLine(g, x + lengthAsync, y, x + lengthAsync, currentY);
-				GraphicLib.dashedLine(g, x + lengthAsync, currentY, currentX-lengthAsync, currentY);
-			} else {
-				// Backward
-				g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
-				GraphicLib.dashedLine(g, x + lengthAsync-1, y, x + lengthAsync-1, y+7);
-				GraphicLib.dashedLine(g, x + lengthAsync, y+6, currentX-lengthAsync, y+6);
-				GraphicLib.dashedLine(g, currentX-lengthAsync-1, currentY, currentX-lengthAsync-1, y+7);
-				g.setColor(c);
-				GraphicLib.dashedLine(g, x + lengthAsync, y, x + lengthAsync, y+7);
-				GraphicLib.dashedLine(g, x + lengthAsync, y+7, currentX-lengthAsync, y+7);
-				GraphicLib.dashedLine(g, currentX-lengthAsync, currentY, currentX-lengthAsync, y+7);
-			}
-		}
-		
-		currentY += 10;
-		
-		// Vertical line of receiving block
-		g.drawLine(currentX, currentY-20, currentX, currentY);
-		return currentY;
-	}
+            // Update currentY;
+            currentY = newCurrentY;
+
+        }
+        maxY = currentY;
+    }
+
+    private int drawState(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
+        int w;
+        int x, y, width, height;
+
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        currentY += verticalLink;
+
+        w = g.getFontMetrics().stringWidth(_gt.action);
+        Color c = g.getColor();
+        Color avat = ColorManager.AVATAR_STATE;
+        g.setColor(avat);
+
+        x = currentX - w/2 - spaceHorizontalText;
+        y = currentY;
+        width = w + 2*spaceHorizontalText;
+        height = g.getFontMetrics().getHeight() + spaceVerticalText * 2;
+
+        g.fillRoundRect(x, y, width, height, 5, 5);
+        points.add(new Point(x+width, y));
+        transactionsOfPoints.add(_gt);
+        g.setColor(c);
+        g.drawRoundRect(x, y, width, height, 5, 5);
+
+        g.drawString(_gt.action, x + spaceHorizontalText, y+height-2*spaceVerticalText);
+
+        currentY += height;
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        return currentY + verticalLink;
+    }
+
+    private int drawFunctionCall(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
+        int w;
+        int x, y, width, height;
+
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        currentY += verticalLink;
+
+        w = g.getFontMetrics().stringWidth(_gt.action);
+        Color c = g.getColor();
+
+        x = currentX - w/2 - spaceHorizontalText;
+        y = currentY;
+        width = w + 2*spaceHorizontalText;
+        height = g.getFontMetrics().getHeight() + spaceVerticalText * 2;
+
+
+        g.setColor(Color.WHITE);
+        g.fillRoundRect(x, y, width, height, 5, 5);
+        g.setColor(c);
+        g.drawRoundRect(x, y, width, height, 5, 5);
+        points.add(new Point(x+width, y));
+        transactionsOfPoints.add(_gt);
+        g.setColor(c);
+        g.drawString(_gt.action, x + spaceHorizontalText, y+height-2*spaceVerticalText);
+
+        currentY += height;
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        return currentY + verticalLink;
+    }
+
+    private int drawSendSynchro(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
+        int w;
+        String messageName;
+
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        currentY += verticalLink;
+
+        messageName = _gt.name + "(" + _gt.params + ")";
+
+        Color c = g.getColor();
+
+        int index = getIndexOfEntityName(_gt.otherEntityName);
+        int xOf2ndBlock = spaceAtEnd + (index * spaceBetweenLifeLines) + spaceBetweenLifeLines/2;
+
+        g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
+        g.drawLine(xOf2ndBlock, currentY-1, currentX, currentY-1);
+        g.setColor(c);
+        GraphicLib.arrowWithLine(g, 1, 0, 10, currentX, currentY, xOf2ndBlock, currentY, true);
+        transactionsOfPoints.add(_gt);
+        points.add(new Point(currentX, currentY));
+
+        // Putting the message name
+        w = g.getFontMetrics().stringWidth(messageName);
+        int xtmp = (xOf2ndBlock + currentX)/2 - w/2;
+        g.drawString(messageName, xtmp, currentY-4);
+
+        currentY += 10;
+
+        // Vertical line of receiving block
+        g.drawLine(currentX, currentY-20, currentX, currentY);
+        return currentY;
+    }
+
+    private int drawSendAsynchro(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
+        int w;
+        int x;
+        String messageName;
+
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        currentY += verticalLink;
+
+        messageName = _gt.name + "(" + _gt.params + ")";
+
+        Color c = g.getColor();
+
+        x = currentX;
+
+        int xOf2ndBlock = x + 2*spaceBetweenLifeLines/3;
+
+        g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
+        g.drawLine(xOf2ndBlock, currentY-1, currentX, currentY-1);
+        g.setColor(c);
+        GraphicLib.arrowWithLine(g, 1, 2, 10, currentX, currentY, xOf2ndBlock, currentY, false);
+        transactionsOfPoints.add(_gt);
+        points.add(new Point(currentX, currentY));
+        //TraceManager.addDev("Putting " + _gt.messageID + " in hash");
+        asyncMsgs.put(_gt.messageID, new Point(currentX, currentY));
+
+        // Putting the message name
+        w = g.getFontMetrics().stringWidth(messageName);
+        int xtmp = (xOf2ndBlock + currentX)/2 - w/2;
+        g.drawString(messageName, xtmp, currentY-2);
+
+        currentY += 10;
+
+        // Vertical line of receiving block
+        g.drawLine(currentX, currentY-20, currentX, currentY);
+        return currentY;
+    }
+
+    private int drawReceiveAsynchro(Graphics g, GenericTransaction _gt, int currentX, int currentY) {
+        int w;
+        int x, y;
+        String messageName;
+
+        g.drawLine(currentX, currentY, currentX, currentY+verticalLink);
+        currentY += verticalLink;
+
+        messageName = _gt.name + "(" + _gt.params + ")";
+
+        Color c = g.getColor();
+
+        x = currentX;
+
+        int xOf2ndBlock = x - 2*spaceBetweenLifeLines/3;
+
+        g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
+        g.drawLine(xOf2ndBlock, currentY-1, currentX, currentY-1);
+        g.setColor(c);
+        GraphicLib.arrowWithLine(g, 1, 2, 10, xOf2ndBlock, currentY, currentX, currentY, false);
+        transactionsOfPoints.add(_gt);
+        points.add(new Point(currentX, currentY));
+
+        // Putting the message name
+        w = g.getFontMetrics().stringWidth(messageName);
+        int xtmp = (xOf2ndBlock + currentX)/2 - w/2;
+        g.drawString(messageName, xtmp, currentY-2);
+
+
+        // Linking to sender?
+        Point p = asyncMsgs.get(_gt.messageID);
+        //TraceManager.addDev("Testing " + _gt.messageID + " in hash = " + p + " hashsize=" + asyncMsgs.size() );
+        if (p != null) {
+            x = p.x;
+            y = p.y;
+            int lengthAsync = 2*spaceBetweenLifeLines/3;
+
+            if ((x +  lengthAsync) < (currentX-lengthAsync)) {
+                // Forward
+                g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
+                GraphicLib.dashedLine(g, x + lengthAsync - 1, y, x + lengthAsync-1, currentY);
+                GraphicLib.dashedLine(g, x + lengthAsync, currentY-1, currentX-lengthAsync, currentY-1);
+                g.setColor(c);
+                GraphicLib.dashedLine(g, x + lengthAsync, y, x + lengthAsync, currentY);
+                GraphicLib.dashedLine(g, x + lengthAsync, currentY, currentX-lengthAsync, currentY);
+            } else {
+                // Backward
+                g.setColor(ColorManager.AVATAR_RECEIVE_SIGNAL);
+                GraphicLib.dashedLine(g, x + lengthAsync-1, y, x + lengthAsync-1, y+7);
+                GraphicLib.dashedLine(g, x + lengthAsync, y+6, currentX-lengthAsync, y+6);
+                GraphicLib.dashedLine(g, currentX-lengthAsync-1, currentY, currentX-lengthAsync-1, y+7);
+                g.setColor(c);
+                GraphicLib.dashedLine(g, x + lengthAsync, y, x + lengthAsync, y+7);
+                GraphicLib.dashedLine(g, x + lengthAsync, y+7, currentX-lengthAsync, y+7);
+                GraphicLib.dashedLine(g, currentX-lengthAsync, currentY, currentX-lengthAsync, y+7);
+            }
+        }
+
+        currentY += 10;
+
+        // Vertical line of receiving block
+        g.drawLine(currentX, currentY-20, currentX, currentY);
+        return currentY;
+    }
 	
 	/*private int drawTransition(Graphics g, AvatarTransition at, AvatarSimulationTransaction ast, int currentX, int currentY) {
 	int w;
@@ -875,361 +862,357 @@ public class JSimulationSDPanel extends JPanel implements MouseMotionListener, R
 	mustScroll = true;
 	revalidate();
 	}*/
-	
-	public void mouseDragged(MouseEvent e) {
-	}
-	
-	public void mouseMoved(MouseEvent e) {
-		xMouse = e.getX();
-		yMouse = e.getY();
-		if ((xMouse > minLimit) && (xMouse<maxX) && (yMouse> spaceAtTop) && (yMouse<(maxY))) {
-			drawInfo = true;
-			repaint();
-			return;
-		}
-		
-		if( drawInfo == true) {
-			drawInfo = false;
-			repaint();
-			return;
-		}
-		
-		drawInfo = false;
-	}
-	
-	private void drawInfo(Graphics g) {
-		String timeValue = "@" + clockValueMouse/clockDiviser;
-		Color c = g.getColor();
-		g.setColor(ColorManager.AVATAR_ACTION);
-		GraphicLib.dashedLine(g, spaceAtEnd, yMouse, maxX-spaceAtEnd, yMouse);
-		g.drawString(timeValue, 10, yMouse+g.getFontMetrics().getHeight()/2);
-		g.drawString(timeValue, maxX-spaceAtEnd + 1, yMouse+g.getFontMetrics().getHeight()/2);
-		
-		int w;
-		int x = spaceAtEnd;
-		
-		for(String name: entityNames) {
-			w = g.getFontMetrics().stringWidth(name);
-			g.drawString(name, x + ((spaceBetweenLifeLines-w)/2), yMouse - spaceVerticalText);
-			x += spaceBetweenLifeLines;
-		}
-		g.setColor(c);
-	}
-	
-	private void drawIDInfo(Graphics g, int _x, int _y, long _id) {
-		Color c = g.getColor();
-		g.setColor(ColorManager.AVATAR_EXPIRE_TIMER);
-		g.fillOval(_x-3, _y-3, 6, 6);
-		g.drawLine(_x, _y, _x+6, _y-6);
-		g.drawLine(_x+6, _y-6, _x+12, _y-6);
-		g.drawString(""+_id, _x+13, _y-6);
-		g.setColor(c);
-	}
-	
-	public BufferedImage performCapture() {
-		int w = this.getWidth();
-		int h = this.getHeight();
-		BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
-		Graphics2D g = image.createGraphics();
-		g.setColor(Color.black);
-		paintComponent(g);
-		g.dispose();
-		return image;
-	}
-	
-	public void setFileReference(String _fileReference) {
-            try {
-                // Open the file that is the first 
-                // command line parameter
-                this.fileReference = _fileReference;
-                this.mode = FILE_MODE;
-                FileInputStream fstream = new FileInputStream(_fileReference);
-                BufferedReader br = new BufferedReader(new InputStreamReader(new DataInputStream(fstream)));
-                // Get the object of DataInputStream
-                this.setFileReference(br, _fileReference);
-            } catch(FileNotFoundException e) {
-                TraceManager.addDev("File " + _fileReference + " not found.");
-            } catch(SecurityException e) {
-                TraceManager.addDev("Reading file Error: " + e.getMessage());
-            }
-	}
 
-        public void setFileReference(BufferedReader inputStream) {
-            this.mode = STREAM_MODE;
-            this.setFileReference(inputStream, "from unnamed input stream");
+    public void mouseDragged(MouseEvent e) {
+    }
+
+    public void mouseMoved(MouseEvent e) {
+        int xMouse = e.getX();
+        yMouse = e.getY();
+        int minLimit = 10;
+        if ((xMouse > minLimit) && (xMouse <maxX) && (yMouse> spaceAtTop) && (yMouse<(maxY))) {
+            drawInfo = true;
+            repaint();
+            return;
+        }
+
+        if(drawInfo) {
+            drawInfo = false;
+            repaint();
+            return;
+        }
+
+        drawInfo = false;
+    }
+
+    private void drawInfo(Graphics g) {
+        String timeValue = "@" + clockValueMouse/clockDiviser;
+        Color c = g.getColor();
+        g.setColor(ColorManager.AVATAR_ACTION);
+        GraphicLib.dashedLine(g, spaceAtEnd, yMouse, maxX-spaceAtEnd, yMouse);
+        g.drawString(timeValue, 10, yMouse+g.getFontMetrics().getHeight()/2);
+        g.drawString(timeValue, maxX-spaceAtEnd + 1, yMouse+g.getFontMetrics().getHeight()/2);
+
+        int w;
+        int x = spaceAtEnd;
+
+        for(String name: entityNames) {
+            w = g.getFontMetrics().stringWidth(name);
+            g.drawString(name, x + ((spaceBetweenLifeLines-w)/2), yMouse - spaceVerticalText);
+            x += spaceBetweenLifeLines;
+        }
+        g.setColor(c);
+    }
+
+    private void drawIDInfo(Graphics g, int _x, int _y, long _id) {
+        Color c = g.getColor();
+        g.setColor(ColorManager.AVATAR_EXPIRE_TIMER);
+        g.fillOval(_x-3, _y-3, 6, 6);
+        g.drawLine(_x, _y, _x+6, _y-6);
+        g.drawLine(_x+6, _y-6, _x+12, _y-6);
+        g.drawString(""+_id, _x+13, _y-6);
+        g.setColor(c);
+    }
+
+    public BufferedImage performCapture() {
+        int w = this.getWidth();
+        int h = this.getHeight();
+        BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
+        Graphics2D g = image.createGraphics();
+        g.setColor(Color.black);
+        paintComponent(g);
+        g.dispose();
+        return image;
+    }
+
+    void setFileReference(String _fileReference) {
+        try {
+            // Open the file that is the first
+            // command line parameter
+            this.fileReference = _fileReference;
+            this.mode = FILE_MODE;
+            FileInputStream fstream = new FileInputStream(_fileReference);
+            BufferedReader br = new BufferedReader(new InputStreamReader(new DataInputStream(fstream)));
+            // Get the object of DataInputStream
+            this.setFileReference(br, _fileReference);
+        } catch(FileNotFoundException e) {
+            TraceManager.addDev("File " + _fileReference + " not found.");
+        } catch(SecurityException e) {
+            TraceManager.addDev("Reading file Error: " + e.getMessage());
+        }
+    }
+
+    void setFileReference(BufferedReader inputStream) {
+        this.mode = STREAM_MODE;
+        this.setFileReference(inputStream, "from unnamed input stream");
+    }
+
+    private void setFileReference(BufferedReader inputStream, String fileReference) {
+        getExclu();
+        jfssdp.setStatus("Reading " + fileReference);
+        this.inputStream = inputStream;
+        this.entityNames.clear();
+        this.transactions.clear();
+        this.transactionsOfPoints.clear();
+        this.points.clear();
+        removeExclu();
+
+        Thread t = new Thread(this);
+        t.start();
+    }
+
+    synchronized void refresh() {
+        if (mode == FILE_MODE) {
+            this.setFileReference(this.fileReference);
+        }
+    }
+
+    public void run() {
+        //TraceManager.addDev("Reading file");
+
+        if (mode == NO_MODE) {
+            return;
         }
 
-        private void setFileReference(BufferedReader inputStream, String fileReference) {
+        if ((this.mode == FILE_MODE || this.mode == STREAM_MODE) && this.inputStream != null) {
+            // Read the content of the file
+            // Read line by line
+            // Upate the graphic regularly
             getExclu();
-            jfssdp.setStatus("Reading " + fileReference);
-            this.inputStream = inputStream;
-            this.entityNames.clear();
-            this.transactions.clear();
-            this.transactionsOfPoints.clear();
-            this.points.clear();
+
+            try{
+                String strLine;
+                //Read File Line By Line
+                while ((strLine = this.inputStream.readLine()) != null)   {
+                    addGenericTransaction(strLine);
+                }
+                //Close the input stream
+                this.inputStream.close();
+            } catch (Exception e){//Catch exception if any
+                TraceManager.addDev("Closing file Error: " + e.getMessage());
+            }
+
+            if (jfssdp != null) {
+                updateInfoOnTransactions();
+            }
             removeExclu();
-            
-            Thread t = new Thread(this);
-            t.start();
+
+            repaint();
         }
-	
-	public synchronized void refresh() {
-            if (mode == FILE_MODE) {
-                this.setFileReference(this.fileReference);
+
+        this.inputStream = null;
+    }
+
+    private void updateInfoOnTransactions() {
+        if (transactions.size() == 0) {
+            jfssdp.setNbOfTransactions(transactions.size(), 0, 0);
+        } else {
+            jfssdp.setNbOfTransactions(transactions.size(), transactions.get(0).startingTime/clockDiviser, transactions.get(transactions.size()-1).finishTime/clockDiviser);
+        }
+    }
+
+    private void addGenericTransaction(String trans) {
+        int index0;
+        String tmp, tmp1, tmp2;
+        long value;
+        int value1, value2;
+
+        if (!(trans.startsWith("#"))) {
+            return;
+        }
+
+        GenericTransaction gt = new GenericTransaction();
+
+        // Adding the ID
+        index0 = trans.indexOf(" ");
+        if (index0 == -1) {
+            return;
+        }
+        tmp = trans.substring(1, index0);
+        try {
+            gt.ID = Integer.decode(tmp);
+        } catch (Exception ignored) {
+        }
+
+
+        //TraceManager.addDev("1");
+
+        // Time
+        tmp = extract(trans, "time");
+        if (tmp == null) {
+            return;
+        }
+
+        //TraceManager.addDev("2 tmp=" + tmp);
+
+        try {
+            index0 = tmp.indexOf('.');
+            if (index0 == -1) {
+                TraceManager.addDev("Invalid time value");
+                return;
             }
-	}
-	
-	public void run() {
-		//TraceManager.addDev("Reading file");
-		
-		go = true;
-		Thread t;
-		
-		if (mode == NO_MODE) {
-			go = false;
-			t = null;
-			return;
-		}
-		
-		if ((this.mode == FILE_MODE || this.mode == STREAM_MODE) && this.inputStream != null) {
-			// Read the content of the file
-			// Read line by line
-			// Upate the graphic regularly
-			getExclu();
-
-			try{
-                                String strLine;
-                                //Read File Line By Line
-                                while ((strLine = this.inputStream.readLine()) != null)   {
-                                        addGenericTransaction(strLine);
-                                }
-				//Close the input stream
-				this.inputStream.close();
-			} catch (Exception e){//Catch exception if any
-				TraceManager.addDev("Closing file Error: " + e.getMessage());
-			}
-			
-			if (jfssdp != null) {
-				updateInfoOnTransactions();
-			}
-			removeExclu();
-			
-			repaint();
-		} 
-		
-		t = null;
-                this.inputStream = null;
-	}
-	
-	private void updateInfoOnTransactions() {
-		if (transactions.size() == 0) {
-			jfssdp.setNbOfTransactions(transactions.size(), 0, 0);
-		} else {
-			jfssdp.setNbOfTransactions(transactions.size(), transactions.get(0).startingTime/clockDiviser, transactions.get(transactions.size()-1).finishTime/clockDiviser);
-		}
-	}
-	
-	public void addGenericTransaction(String trans) {
-		int index0, index1;
-		String tmp, tmp1, tmp2;
-		long value;
-		int value1, value2;
-		
-		if (!(trans.startsWith("#"))) {
-			return;
-		}
-		
-		
-		GenericTransaction gt = new GenericTransaction();
-		
-		// Adding the ID
-		index0 = trans.indexOf(" ");
-		if (index0 == -1) {
-			return;
-		}
-		tmp = trans.substring(1, index0);
-		try {
-			gt.ID = Integer.decode(tmp).intValue(); 
-		} catch (Exception e) {
-		}
-		
-		
-		//TraceManager.addDev("1");
-		
-		// Time
-		tmp = extract(trans, "time");
-		if (tmp == null) {
-			return;
-		}
-		
-		//TraceManager.addDev("2 tmp=" + tmp);
-		
-		try {
-			index0 = tmp.indexOf('.');
-			if (index0 == -1) {
-				TraceManager.addDev("Invalid time value");
-				return;
-			}
-			tmp1 = tmp.substring(0, index0);
-			tmp2 = Conversion.removeStartingCharacters(tmp.substring(index0+1, tmp.length()), "0");
-			//TraceManager.addDev("2 tmp1=" + tmp1 + " tmp2=" + tmp2);
-			value1 = Integer.decode(tmp1).intValue();
-			if (tmp2.length() == 0) {
-				value2 = 0;
-			} else {
-				value2 = Integer.decode(tmp2).intValue();
-			}
-			value = ((long)value1)*1000000000+value2;
-			gt.startingTime = value;
-			gt.finishTime = value;
-		} catch (Exception e) {
-			TraceManager.addDev("Exception: " + e.getMessage() + " on transaction " + trans);
-			return;
-		}
-		
-		//TraceManager.addDev("3");
-		
-		// Name of the block
-		tmp = extract(trans, "block");
-		if (tmp == null) {
-			return;
-		}
-		
-		//TraceManager.addDev("4");
-		
-		addEntityNameIfApplicable(tmp);
-		gt.entityName = tmp;
-		
-		// Type of the transaction
-		tmp = extract(trans, "type");
-		if (tmp == null) {
-			return;
-		}
-		
-		if (tmp.compareTo("state_entering") == 0) {
-			gt.type = GenericTransaction.STATE_ENTERING;
-		}
-		
-		if (tmp.compareTo("function_call") == 0) {
-			gt.type = GenericTransaction.FUNCTION_CALL;
-		}
-		
-		if (tmp.compareTo("send_synchro") == 0) {
-			gt.type = GenericTransaction.SEND_SYNCHRO;
-		}
-		
-		if (tmp.compareTo("synchro") == 0) {
-			gt.type = GenericTransaction.SYNCHRO;
-		}
-		
-		if (tmp.compareTo("send_async") == 0) {
-			gt.type = GenericTransaction.SEND_ASYNCHRO;
-		}
-		
-		if (tmp.compareTo("receive_async") == 0) {
-			gt.type = GenericTransaction.RECEIVE_ASYNCHRO;
-		}
-		
-		// State of the transaction?
-		tmp = extract(trans, "state");
-		
-		if (tmp != null) {
-			gt.action = tmp;
-		}
-		
-		// Function of the transaction?
-		tmp = extract(trans, "func");
-		
-		if (tmp != null) {
-			gt.action = tmp;
-		}
-		
-		// Parameters of the function
-		tmp = extract(trans, "parameters");
-		gt.action = gt.action + "(";
-		if( tmp != null) {
-			if (!(tmp.startsWith("-"))) {
-				gt.action = gt.action + tmp;
-			}
-		} else {
-		}
-		gt.action = gt.action + ")"; 
-		
-		// Destination of the transaction?
-		tmp = extract(trans, "blockdestination");
-		if (tmp != null) {
-			gt.otherEntityName = tmp;
-			addEntityNameIfApplicable(tmp);
-		}
-		
-		// Channel of the transaction?
-		tmp = extract(trans, "channel");
-		if (tmp != null) {
-			gt.name = tmp;
-		}
-        
+            tmp1 = tmp.substring(0, index0);
+            tmp2 = Conversion.removeStartingCharacters(tmp.substring(index0+1, tmp.length()), "0");
+            //TraceManager.addDev("2 tmp1=" + tmp1 + " tmp2=" + tmp2);
+            value1 = Integer.decode(tmp1);
+            if (tmp2.length() == 0) {
+                value2 = 0;
+            } else {
+                value2 = Integer.decode(tmp2);
+            }
+            value = ((long)value1)*1000000000+value2;
+            gt.startingTime = value;
+            gt.finishTime = value;
+        } catch (Exception e) {
+            TraceManager.addDev("Exception: " + e.getMessage() + " on transaction " + trans);
+            return;
+        }
+
+        //TraceManager.addDev("3");
+
+        // Name of the block
+        tmp = extract(trans, "block");
+        if (tmp == null) {
+            return;
+        }
+
+        //TraceManager.addDev("4");
+
+        addEntityNameIfApplicable(tmp);
+        gt.entityName = tmp;
+
+        // Type of the transaction
+        tmp = extract(trans, "type");
+        if (tmp == null) {
+            return;
+        }
+
+        if (tmp.compareTo("state_entering") == 0) {
+            gt.type = GenericTransaction.STATE_ENTERING;
+        }
+
+        if (tmp.compareTo("function_call") == 0) {
+            gt.type = GenericTransaction.FUNCTION_CALL;
+        }
+
+        if (tmp.compareTo("send_synchro") == 0) {
+            gt.type = GenericTransaction.SEND_SYNCHRO;
+        }
+
+        if (tmp.compareTo("synchro") == 0) {
+            gt.type = GenericTransaction.SYNCHRO;
+        }
+
+        if (tmp.compareTo("send_async") == 0) {
+            gt.type = GenericTransaction.SEND_ASYNCHRO;
+        }
+
+        if (tmp.compareTo("receive_async") == 0) {
+            gt.type = GenericTransaction.RECEIVE_ASYNCHRO;
+        }
+
+        // State of the transaction?
+        tmp = extract(trans, "state");
+
+        if (tmp != null) {
+            gt.action = tmp;
+        }
+
+        // Function of the transaction?
+        tmp = extract(trans, "func");
+
+        if (tmp != null) {
+            gt.action = tmp;
+        }
+
+        // Parameters of the function
+        tmp = extract(trans, "parameters");
+        gt.action = gt.action + "(";
+        if( tmp != null) {
+            if (!(tmp.startsWith("-"))) {
+                gt.action = gt.action + tmp;
+            }
+        }
+        gt.action = gt.action + ")";
+
+        // Destination of the transaction?
+        tmp = extract(trans, "blockdestination");
+        if (tmp != null) {
+            gt.otherEntityName = tmp;
+            addEntityNameIfApplicable(tmp);
+        }
+
+        // Channel of the transaction?
+        tmp = extract(trans, "channel");
+        if (tmp != null) {
+            gt.name = tmp;
+        }
+
         tmp = extract(trans, "params");
-		if (tmp != null) {
-			gt.params = tmp;
-		}
-		
-		tmp = extract(trans, "msgid");
-		if (tmp != null) {
-			gt.messageID = tmp;
-		}
-		
-		transactions.add(gt);
-		//TraceManager.addDev("One transactions added");
-		
-	}
-	
-	public String extract(String main, String selector) {
-		String sel = selector+"=";
-		int index = main.indexOf(sel);
-		if (index == -1) {
-			return null;
-		}
-		
-		String ret = main.substring(index+sel.length(), main.length());
-                if (ret.charAt(0) == '"') {
-                    ret = ret.substring(1);
-                    index = ret.indexOf('"');
-                } else
-                    index = ret.indexOf(' ');
-		
-		if (index >= 0) {
-			ret = ret.substring(0, index);
-		}
-		
-		return ret;
-	}
-	
-	public void addEntityNameIfApplicable(String _entityName) {
-		for(String name: entityNames) {
-			//TraceManager.addDev("Examining name= " + name + " entityName=" + _entityName);
-			if (name.compareTo(_entityName) ==0) {
-				return;
-			}
-		}
-		
-		//TraceManager.addDev("Adding name: " + _entityName);
-		entityNames.add(_entityName);
-	}
-	
-	public int getIndexOfEntityName(String _entityName) {
-		int cpt = 0;
-		for(String name: entityNames) {
-			if (name.compareTo(_entityName) ==0) {
-				return cpt;
-			}
-			cpt ++;
-		}
-		
-		return -1;
-	}
-	
-	public void setClockDiviser(long _clockDiviser) {
-		clockDiviser = _clockDiviser;
-		updateInfoOnTransactions();
-	}
+        if (tmp != null) {
+            gt.params = tmp;
+        }
+
+        tmp = extract(trans, "msgid");
+        if (tmp != null) {
+            gt.messageID = tmp;
+        }
+
+        transactions.add(gt);
+        //TraceManager.addDev("One transactions added");
+
+    }
+
+    private String extract(String main, String selector) {
+        String sel = selector+"=";
+        int index = main.indexOf(sel);
+        if (index == -1) {
+            return null;
+        }
+
+        String ret = main.substring(index+sel.length(), main.length());
+        if (ret.isEmpty())
+            return ret;
+
+        if (ret.charAt(0) == '"') {
+            ret = ret.substring(1);
+            index = ret.indexOf('"');
+        } else
+            index = ret.indexOf(' ');
+
+        if (index >= 0) {
+            ret = ret.substring(0, index);
+        }
+
+        return ret;
+    }
+
+    private void addEntityNameIfApplicable(String _entityName) {
+        for(String name: entityNames) {
+            //TraceManager.addDev("Examining name= " + name + " entityName=" + _entityName);
+            if (name.compareTo(_entityName) ==0) {
+                return;
+            }
+        }
+
+        //TraceManager.addDev("Adding name: " + _entityName);
+        entityNames.add(_entityName);
+    }
+
+    private int getIndexOfEntityName(String _entityName) {
+        int cpt = 0;
+        for(String name: entityNames) {
+            if (name.compareTo(_entityName) ==0) {
+                return cpt;
+            }
+            cpt ++;
+        }
+
+        return -1;
+    }
+
+    void setClockDiviser(long _clockDiviser) {
+        clockDiviser = _clockDiviser;
+        updateInfoOnTransactions();
+    }
 }
-- 
GitLab