diff --git a/src/avatartranslator/directsimulation/AvatarSimulationBlock.java b/src/avatartranslator/directsimulation/AvatarSimulationBlock.java index ea7e8ff4e2818486c4521e729399c0350eea7c06..4bd59daac434d047538237847ffa79fb1c8a4675 100644 --- a/src/avatartranslator/directsimulation/AvatarSimulationBlock.java +++ b/src/avatartranslator/directsimulation/AvatarSimulationBlock.java @@ -167,7 +167,7 @@ public class AvatarSimulationBlock { String s = Conversion.replaceAllString(guard, "[", "").trim(); s = Conversion.replaceAllString(s, "]", "").trim(); guardOk = evaluateBoolExpression(s, lastTransaction.attributeValues); - TraceManager.addDev("guard ok=" + guardOk); + //TraceManager.addDev("guard ok=" + guardOk); } } @@ -208,7 +208,7 @@ public class AvatarSimulationBlock { aspt.myMaxDelay = evaluateIntExpression(trans.getMaxDelay(), lastTransaction.attributeValues); aspt.hasDelay = true; - TraceManager.addDev(">>>>> Signal with delay before"); + //TraceManager.addDev(">>>>> Signal with delay before"); if (lastTransaction != null) { if (lastTransaction.clockValueWhenFinished < _clockValue) { @@ -309,7 +309,7 @@ public class AvatarSimulationBlock { ast.clockValueWhenFinished = _aspt.selectedDuration + _clockValue; _aspt.clockValueAtEnd = ast.clockValueWhenFinished; } - TraceManager.addDev("Id= " + ast.id + " duration=" + ast.duration + " elapsed=" + _aspt.elapsedTime + " selectedDur=" + _aspt.selectedDuration + " at end: " + _aspt.clockValueAtEnd + "clockValue=" + _clockValue); + //TraceManager.addDev("Id= " + ast.id + " duration=" + ast.duration + " elapsed=" + _aspt.elapsedTime + " selectedDur=" + _aspt.selectedDuration + " at end: " + _aspt.clockValueAtEnd + "clockValue=" + _clockValue); } @@ -367,7 +367,7 @@ public class AvatarSimulationBlock { // Synchronous Sending! // Must be in the receiving transaction the right parameters Vector<String> parameters = new Vector<String>(); - TraceManager.addDev("Adding value in :" + aaos); + //TraceManager.addDev("Adding value in :" + aaos); for(i=0; i<aaos.getNbOfValues(); i++) { value = aaos.getValue(i); // Must get the type of the value @@ -381,7 +381,7 @@ public class AvatarSimulationBlock { result += evaluateBoolExpression(value, lastTransaction.attributeValues); } - TraceManager.addDev("Adding value:" + result); + //TraceManager.addDev("Adding value:" + result); parameters.add(result); } catch (Exception e) { TraceManager.addDev("EXCEPTION on adding value " + aaos); @@ -393,7 +393,7 @@ public class AvatarSimulationBlock { // Synchronous Receiving String myAction = ""; for(i=0; i<aaos.getNbOfValues(); i++) { - TraceManager.addDev("Reading value #" + i); + //TraceManager.addDev("Reading value #" + i); param = _aspt.parameters.get(i); name = aaos.getValue(i); index = block.getIndexOfAvatarAttributeWithName(name); @@ -401,7 +401,7 @@ public class AvatarSimulationBlock { if (index != -1) { attributeValues.remove(index); attributeValues.add(index, param); - TraceManager.addDev("Reading value:" + param); + //TraceManager.addDev("Reading value:" + param); if (myAction.length() == 0) { myAction += "" + param; } else { @@ -422,6 +422,7 @@ public class AvatarSimulationBlock { // Asynchronous Sending String myAction = ""; + _aspt.linkedAsynchronousMessage.firstTransaction = ast; for(i=0; i<aaos.getNbOfValues(); i++) { value = aaos.getValue(i); // Must get the type of the value @@ -432,9 +433,9 @@ public class AvatarSimulationBlock { } else if (avat.getType() == AvatarType.BOOLEAN) { result += evaluateBoolExpression(value, lastTransaction.attributeValues); } - TraceManager.addDev("Adding value:" + result); + //TraceManager.addDev("Adding value:" + result); _aspt.linkedAsynchronousMessage.addParameter(result); - _aspt.linkedAsynchronousMessage.firstTransaction = ast; + if (myAction.length() == 0) { myAction += "" + result; } else { @@ -467,6 +468,9 @@ public class AvatarSimulationBlock { myAction += ", " + param; } } + } + if (_aspt.linkedAsynchronousMessage == null) { + TraceManager.addDev("NULL ASYN MSG"); } if (myAction.length() > 0) { ast.actions = new Vector<String>(); diff --git a/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java b/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java index a5f738bfe5710c4563cf93dea8469005627aaf92..d611c259067e65fe23c5379942b02bc1635b50ae 100644 --- a/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java +++ b/src/avatartranslator/directsimulation/AvatarSpecificationSimulation.java @@ -323,6 +323,9 @@ public class AvatarSpecificationSimulation { if (asat != null) { _aspt.linkedAsynchronousMessage = asat; transactions.add(_aspt); + /*if (asat.firstTransaction == null) { + TraceManager.addDev("NULL FIRST"); + }*/ } } } else { diff --git a/src/ui/avatarinteractivesimulation/AvatarSpecificationSimulationSDPanel.java b/src/ui/avatarinteractivesimulation/AvatarSpecificationSimulationSDPanel.java index 1be6299c8ac7f694f1ac3484a94ac58c7ae33f7f..643577734a08cfbc95b25d1bfaddae8c674366a8 100644 --- a/src/ui/avatarinteractivesimulation/AvatarSpecificationSimulationSDPanel.java +++ b/src/ui/avatarinteractivesimulation/AvatarSpecificationSimulationSDPanel.java @@ -73,7 +73,9 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous 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; @@ -120,6 +122,10 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous int oldMaxY = maxY; int oldMaxX = maxX; + if (!spaceBetweenLifeLinesComputed) { + computeSpaceBetweenLifeLines(g); + } + currentY = paintTopElements(g, currentX, currentY); paintTransactions(g, currentX, currentY); @@ -171,6 +177,20 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous return currentY + verticalSpaceUnderBlocks; } + private void computeSpaceBetweenLifeLines(Graphics g) { + int w; + + spaceBetweenLifeLinesComputed = true; + + for(AvatarSimulationBlock block: ass.getSimulationBlocks()) { + w = g.getFontMetrics().stringWidth(block.getBlock().getName()); + if ((w+minSpaceBetweenLifeLines) > spaceBetweenLifeLines) { + spaceBetweenLifeLines = w+minSpaceBetweenLifeLines; + } + } + + } + // returns the currentY position protected int paintTransactions(Graphics g, int currentX, int currentY) { AvatarSimulationTransaction ast; @@ -449,7 +469,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous } } } else { - TraceManager.addDev("No linked transaction"); + //TraceManager.addDev("No linked transaction"); } currentY += 10; @@ -525,7 +545,7 @@ public class AvatarSpecificationSimulationSDPanel extends JPanel implements Mous public void mouseMoved(MouseEvent e) { xMouse = e.getX(); yMouse = e.getY(); - if ((xMouse > minLimit) && (xMouse<maxX-spaceAtEnd) && (yMouse> spaceAtTop) && (yMouse<(maxY))) { + if ((xMouse > minLimit) && (xMouse<maxX) && (yMouse> spaceAtTop) && (yMouse<(maxY))) { drawInfo = true; repaint(); return;