Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2017-04-20 11:32:48 +0000
committerLaurent Redor2017-06-20 09:01:02 +0000
commitece4d8aaeed35b2d153b81fe3f4d9d61f24523a5 (patch)
tree310acee4936cfcc81a577d415faf4489c456fe7e
parent88db77e391631348f68415ba67b069157bc6912b (diff)
downloadorg.eclipse.sirius-ece4d8aaeed35b2d153b81fe3f4d9d61f24523a5.tar.gz
org.eclipse.sirius-ece4d8aaeed35b2d153b81fe3f4d9d61f24523a5.tar.xz
org.eclipse.sirius-ece4d8aaeed35b2d153b81fe3f4d9d61f24523a5.zip
[518439] Avoid ArithmeticException caused by a division by zero
Bug: 518439 Cherry-picked-from: 515553 Change-Id: I3bc37070e02658abdebd5acea58967e2b67b761b Cherry-picks: I081c10def3fb5550ae8ca3b12682529eaf02aaba Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/locator/EdgeLabelQuery.java8
1 files changed, 6 insertions, 2 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/locator/EdgeLabelQuery.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/locator/EdgeLabelQuery.java
index 3e0ee45f67..4e37efe7ff 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/locator/EdgeLabelQuery.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/edit/parts/locator/EdgeLabelQuery.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 THALES GLOBAL SERVICES.
+ * Copyright (c) 2015, 2017 THALES GLOBAL SERVICES and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -411,7 +411,11 @@ public class EdgeLabelQuery {
if (oldNearestSeg.isHorizontal() == newNearestSegment.isHorizontal()) {
Vector oldVector = new Vector(oldNearestSeg.getTerminus().x - oldNearestSeg.getOrigin().x, oldNearestSeg.getTerminus().y - oldNearestSeg.getOrigin().y);
Vector newVector = new Vector(newNearestSegment.getTerminus().x - newNearestSegment.getOrigin().x, newNearestSegment.getTerminus().y - newNearestSegment.getOrigin().y);
- fromOldToNewCenterVector = applyOldRatioOnNewSegment(oldNearestSeg, oldNearestPoint, oldCenterLabel, newNearestSegment, oldVector.getAngle(newVector) == 180, false);
+ boolean oppositeDirection = false;
+ if (oldVector.getLength() != 0 && newVector.getLength() != 0) {
+ oppositeDirection = oldVector.getAngle(newVector) == 180;
+ }
+ fromOldToNewCenterVector = applyOldRatioOnNewSegment(oldNearestSeg, oldNearestPoint, oldCenterLabel, newNearestSegment, oppositeDirection, false);
}
}
return fromOldToNewCenterVector;

Back to the top