diff options
Diffstat (limited to 'plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram')
2 files changed, 38 insertions, 35 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; } diff --git a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/layout/horizontal/LostMessageEndHorizontalLayoutHelper.java b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/layout/horizontal/LostMessageEndHorizontalLayoutHelper.java index 8ab3d331c3..69b39335e6 100644 --- a/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/layout/horizontal/LostMessageEndHorizontalLayoutHelper.java +++ b/plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/layout/horizontal/LostMessageEndHorizontalLayoutHelper.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 THALES GLOBAL SERVICES. + * Copyright (c) 2010, 2020 THALES GLOBAL SERVICES. * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 * which accompanies this distribution, and is available at @@ -44,8 +44,8 @@ import com.google.common.collect.Iterables; import com.google.common.collect.Multimap; /** - * Computes the appropriate graphical locations of sequence events and lifelines - * on a sequence diagram to reflect the semantic order. + * Computes the appropriate graphical locations of sequence events and lifelines on a sequence diagram to reflect the + * semantic order. * * @author pcdavid, mporhel */ @@ -71,8 +71,7 @@ public class LostMessageEndHorizontalLayoutHelper { * Constructor. * * @param diagram - * the sequence diagram for which to compute the horizontal - * locations. + * the sequence diagram for which to compute the horizontal locations. */ public LostMessageEndHorizontalLayoutHelper(SequenceDiagram diagram) { this.sequenceDiagram = diagram; @@ -132,7 +131,6 @@ public class LostMessageEndHorizontalLayoutHelper { ISequenceNode sourceElement = msg.getSourceElement(); ISequenceNode targetElement = msg.getTargetElement(); - Option<Operand> parentOperand = msg.getParentOperand(); if (sourceElement != null && targetElement != null) { Option<Lifeline> sourceLifeline = sourceElement.getLifeline(); Option<Lifeline> targetLifeline = targetElement.getLifeline(); @@ -142,6 +140,7 @@ public class LostMessageEndHorizontalLayoutHelper { LostMessageEnd sourceLME = (LostMessageEnd) sourceElement; lostSources.put(targetLifeline.get(), sourceLME); lostMessages.put(sourceLME, msg); + Option<Operand> parentOperand = msg.getParentOperand(); if (parentOperand.some()) { operands.put(sourceLME, parentOperand.get()); operands2lostEnds.put(parentOperand.get(), sourceLME); @@ -152,6 +151,7 @@ public class LostMessageEndHorizontalLayoutHelper { LostMessageEnd targetLME = (LostMessageEnd) targetElement; lostTargets.put(sourceLifeline.get(), targetLME); lostMessages.put(targetLME, msg); + Option<Operand> parentOperand = msg.getParentOperand(); if (parentOperand.some()) { operands.put(targetLME, parentOperand.get()); operands2lostEnds.put(parentOperand.get(), targetLME); |