Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java')
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java61
1 files changed, 32 insertions, 29 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java
index 8f2f95b4f4..1540cb0ee6 100644
--- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java
+++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java
@@ -421,40 +421,43 @@ public class Message extends AbstractSequenceElement implements ISequenceEvent {
*/
public int getReflexiveMessageWidth() {
Collection<ISequenceEvent> events = getSurroundedSameLifelineEvents();
- final Range range = getVerticalRange();
- Predicate<ISequenceEvent> toConsider = new Predicate<ISequenceEvent>() {
- @Override
- public boolean apply(ISequenceEvent input) {
- boolean toConsider = range.includes(input.getVerticalRange());
- if (input instanceof Message) {
- toConsider = toConsider && ((Message) input).isReflective();
+
+ int width = LayoutConstants.MESSAGE_TO_SELF_BENDPOINT_HORIZONTAL_GAP;
+ if (!events.isEmpty()) {
+
+ final Range range = getVerticalRange();
+ Predicate<ISequenceEvent> toConsider = new Predicate<ISequenceEvent>() {
+ @Override
+ public boolean apply(ISequenceEvent input) {
+ boolean toConsider = range.includes(input.getVerticalRange());
+ if (input instanceof Message) {
+ toConsider = toConsider && ((Message) input).isReflective();
+ }
+ return toConsider;
}
- return toConsider;
+ };
+
+ List<ISequenceEvent> impactingEvents = Lists.newArrayList(Iterables.filter(events, toConsider));
+ Collections.sort(impactingEvents, Ordering.natural().onResultOf(Functions.compose(RangeHelper.lowerBoundFunction(), ISequenceEvent.VERTICAL_RANGE)));
+ int subMessagesMaxRight = 0;
+ for (Message msg : Iterables.filter(impactingEvents, Message.class)) {
+ int reflexiveMessageWidth = msg.getReflexiveMessageWidth();
+ int origin = msg.getSourceElement().getProperLogicalBounds().right();
+ origin = Math.max(origin, msg.getTargetElement().getProperLogicalBounds().right());
+ subMessagesMaxRight = Math.max(subMessagesMaxRight, origin + reflexiveMessageWidth);
}
- };
-
- List<ISequenceEvent> impactingEvents = Lists.newArrayList(Iterables.filter(events, toConsider));
- Collections.sort(impactingEvents, Ordering.natural().onResultOf(Functions.compose(RangeHelper.lowerBoundFunction(), ISequenceEvent.VERTICAL_RANGE)));
- int subMessagesMaxRight = 0;
- for (Message msg : Iterables.filter(impactingEvents, Message.class)) {
- int reflexiveMessageWidth = msg.getReflexiveMessageWidth();
- int origin = msg.getSourceElement().getProperLogicalBounds().right();
- origin = Math.max(origin, msg.getTargetElement().getProperLogicalBounds().right());
- subMessagesMaxRight = Math.max(subMessagesMaxRight, origin + reflexiveMessageWidth);
- }
- int maxRight = 0;
- for (AbstractNodeEvent node : Iterables.filter(impactingEvents, AbstractNodeEvent.class)) {
- maxRight = Math.max(maxRight, node.getProperLogicalBounds().right());
- }
-
- int origin = getSourceElement().getProperLogicalBounds().right();
- origin = Math.max(origin, getTargetElement().getProperLogicalBounds().right());
+ int maxRight = 0;
+ for (AbstractNodeEvent node : Iterables.filter(impactingEvents, AbstractNodeEvent.class)) {
+ maxRight = Math.max(maxRight, node.getProperLogicalBounds().right());
+ }
- int width = LayoutConstants.MESSAGE_TO_SELF_BENDPOINT_HORIZONTAL_GAP;
- width = Math.max(width, maxRight - origin + LayoutConstants.MESSAGE_TO_SELF_HORIZONTAL_GAP);
- width = Math.max(width, subMessagesMaxRight - origin + LayoutConstants.MESSAGE_TO_SELF_HORIZONTAL_GAP);
+ int origin = getSourceElement().getProperLogicalBounds().right();
+ origin = Math.max(origin, getTargetElement().getProperLogicalBounds().right());
+ width = Math.max(width, maxRight - origin + LayoutConstants.MESSAGE_TO_SELF_HORIZONTAL_GAP);
+ width = Math.max(width, subMessagesMaxRight - origin + LayoutConstants.MESSAGE_TO_SELF_HORIZONTAL_GAP);
+ }
return width;
}

Back to the top