diff options
| author | Pierre-Charles David | 2017-04-20 11:32:48 +0000 |
|---|---|---|
| committer | Pierre-Charles David | 2017-04-20 14:02:11 +0000 |
| commit | da27e5da7495599e9766f487666a96369ee79684 (patch) | |
| tree | 9d43b0a384a08a9bf7080ad438b72df234944d38 | |
| parent | 822d105d621da95022b1d111d14352bcaebd87d5 (diff) | |
| download | org.eclipse.sirius-da27e5da7495599e9766f487666a96369ee79684.tar.gz org.eclipse.sirius-da27e5da7495599e9766f487666a96369ee79684.tar.xz org.eclipse.sirius-da27e5da7495599e9766f487666a96369ee79684.zip | |
[510851] Avoid ArithmeticException caused by a division by zero
Bug: 510851
Change-Id: 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.java | 8 |
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; |
