Commit 9a3b7d13 authored by Simon Tenbusch's avatar Simon Tenbusch

[sequencechart]

- fixed a bug in critical path visualization
parent 92b45026
......@@ -3236,15 +3236,19 @@ public class SequenceChart
int currentLineWidth = 0;
boolean changedLineStyleForCriticalPath = false;
if (sequenceChartFacade.IMessageDependency_isReuse(messageDependencyPtr) && !showOtherMessageReuses)
if (sequenceChartFacade.IMessageDependency_isReuse(messageDependencyPtr) && !showOtherMessageReuses) {
return false;
}
if (sequenceChartFacade.IMessageDependency_isSelfMessageReuse(messageDependencyPtr) && !showSelfMessageReuses)
return false;
if (sequenceChartFacade.IMessageDependency_isSelfMessageReuse(messageDependencyPtr) && !showSelfMessageReuses) {
return false;
}
// events may be omitted from the log
if (causeEventPtr == 0 || consequenceEventPtr == 0)
if (causeEventPtr == 0 || consequenceEventPtr == 0) {
return false;
}
// cache message dependency state
long beginSendEntryPtr = sequenceChartFacade.IMessageDependency_getBeginSendEntry(messageDependencyPtr);
......@@ -3317,8 +3321,9 @@ public class SequenceChart
}
// at least one of the events must be in range or we don't draw anything
if (x1 == invalid && x2 == invalid)
return false;
if (x1 == invalid && x2 == invalid) {
return false;
}
// line color and style depends on message kind
if (graphics != null) {
......@@ -3333,7 +3338,7 @@ public class SequenceChart
}
// change line style if critical path should be visualized
if (showCriticalPath && graphics != null) {
if (showCriticalPath && graphics != null && (showMessageSends || showSelfMessages)) {
boolean causeOnPath = sequenceChartFacade.isOnCriticalPath(sequenceChartFacade.IEvent_getEvent(causeEventPtr));
boolean consequenceOnPath = sequenceChartFacade.isOnCriticalPath(sequenceChartFacade.IEvent_getEvent(consequenceEventPtr));
if (causeOnPath && consequenceOnPath) {
......@@ -3349,8 +3354,10 @@ public class SequenceChart
// test if self-message
if (y1 == y2) {
// FIXME: this filters out non self messages too, e.g. filtered and returns to same module
if (!showSelfMessages)
if (!showSelfMessages) {
resetGraphicsFromCriticalPath(graphics, changedLineStyleForCriticalPath, currentLineWidth, currentForegroundColor);
return false;
}
long eventNumberDelta = messageId + consequenceEventNumber - causeEventNumber;
int numberOfPossibleEllipseHeights = Math.max(1, (int)Math.round((getAxisSpacing() - fontHeight) / (fontHeight + 10)));
......@@ -3370,8 +3377,10 @@ public class SequenceChart
if (showMessageNames)
drawMessageDependencyLabel(graphics, messageDependencyPtr, x1, y1, 2, -fontHeight);
}
else
else {
resetGraphicsFromCriticalPath(graphics, changedLineStyleForCriticalPath, currentLineWidth, currentForegroundColor);
return lineContainsPoint(x1, y1, x2, y2, fitX, fitY, tolerance);
}
}
else {
boolean showArrowHeads = this.showArrowHeads;
......@@ -3394,9 +3403,12 @@ public class SequenceChart
if (isFilteredMessageDependency)
drawFilteredMessageDependencySign(graphics, x1, ym, x2, ym);
}
else
else {
resetGraphicsFromCriticalPath(graphics, changedLineStyleForCriticalPath, currentLineWidth, currentForegroundColor);
return lineContainsPoint(x1, ym, xm, ym, fitX, fitY, tolerance) ||
halfEllipseContainsPoint(1, x1, x2, y1, halfEllipseHeight, fitX, fitY, tolerance);
}
}
// consequence is too far away
else if (x2 == invalid) {
......@@ -3420,9 +3432,12 @@ public class SequenceChart
showArrowHeads = false;
}
else
else {
resetGraphicsFromCriticalPath(graphics, changedLineStyleForCriticalPath, currentLineWidth, currentForegroundColor);
return lineContainsPoint(xm, ym, x2, ym, fitX, fitY, tolerance) ||
halfEllipseContainsPoint(0, x1, x2, y1, halfEllipseHeight, fitX, fitY, tolerance);
}
}
// both events are close enough
else {
......@@ -3436,8 +3451,10 @@ public class SequenceChart
if (isFilteredMessageDependency)
drawFilteredMessageDependencySign(graphics, x1, ym, x2, ym);
}
else
else {
resetGraphicsFromCriticalPath(graphics, changedLineStyleForCriticalPath, currentLineWidth, currentForegroundColor);
return halfEllipseContainsPoint(-1, x1, x2, y1, halfEllipseHeight, fitX, fitY, tolerance);
}
}
if (showArrowHeads) {
......@@ -3469,8 +3486,10 @@ public class SequenceChart
}
}
else {
if (!showMessageSends)
return false;
if (!showMessageSends) {
resetGraphicsFromCriticalPath(graphics, changedLineStyleForCriticalPath, currentLineWidth, currentForegroundColor);
return false;
}
int y = (y2 + y1) / 2;
Color arrowHeadFillColor = null;
......@@ -3545,8 +3564,11 @@ public class SequenceChart
}
}
if (graphics == null)
if (graphics == null) {
resetGraphicsFromCriticalPath(graphics, changedLineStyleForCriticalPath, currentLineWidth, currentForegroundColor);
return lineContainsPoint(x1, y1, x2, y2, fitX, fitY, tolerance);
}
if (graphics != null && isFilteredMessageDependency)
drawFilteredMessageDependencySign(graphics, x1, y1, x2, y2);
......@@ -3570,13 +3592,20 @@ public class SequenceChart
// when fitting we should have already returned
Assert.isTrue(graphics != null);
resetGraphicsFromCriticalPath(graphics, changedLineStyleForCriticalPath, currentLineWidth, currentForegroundColor);
return false;
}
/*
* Resets the graphic line style. Only called from within drawOrFitMessageDependency
*/
private void resetGraphicsFromCriticalPath(Graphics graphics, boolean changedLineStyleForCriticalPath, int currentLineWidth, Color currentForegroundColor) {
// reset line style
if (changedLineStyleForCriticalPath && graphics != null) {
graphics.setLineWidth(currentLineWidth);
graphics.setForegroundColor(currentForegroundColor);
}
return false;
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment