Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Porhel2020-10-21 15:03:31 +0000
committerMaxime Porhel2020-10-23 13:59:35 +0000
commit6795a234e72d727a8e585e5d09d7229461f797d6 (patch)
tree172b9cda403ba05b82914ed89194e7355c0b21f0 /plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence
parentb93e1893818cdee07e19a6571218b5870c8d3da3 (diff)
downloadorg.eclipse.sirius-6795a234e72d727a8e585e5d09d7229461f797d6.tar.gz
org.eclipse.sirius-6795a234e72d727a8e585e5d09d7229461f797d6.tar.xz
org.eclipse.sirius-6795a234e72d727a8e585e5d09d7229461f797d6.zip
[567517] Optimize Sequence Horizontal Layout
- Compute Message.getParentOperand() only if a lost message end is found. - Fast return the default reflexive message width if there is no surrounded event on the same lifeline. Bug: 567517 Change-Id: I2fab94b454824ff7fc4832d777d21687e55851ac Signed-off-by: Maxime Porhel <maxime.porhel@obeo.fr>
Diffstat (limited to 'plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence')
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/elements/Message.java61
-rw-r--r--plugins/org.eclipse.sirius.diagram.sequence/src/org/eclipse/sirius/diagram/sequence/business/internal/layout/horizontal/LostMessageEndHorizontalLayoutHelper.java12
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);

Back to the top