Bug 518437 - "/ by zero" ArithmeticException in EdgeLabelQuery center computation
Summary: "/ by zero" ArithmeticException in EdgeLabelQuery center computation
Status: CLOSED FIXED
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 3.1.0   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.1.9   Edit
Assignee: Laurent Redor CLA
QA Contact: Laurent Redor CLA
URL:
Whiteboard:
Keywords: triaged
Depends on: 485010
Blocks: 510851 515553 518439
  Show dependency tree
 
Reported: 2017-06-19 04:20 EDT by Laurent Redor CLA
Modified: 2017-07-07 07:20 EDT (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Redor CLA 2017-06-19 04:20:20 EDT
+++ This bug was initially created as a clone of Bug #485010 +++

Steps to reproduce: 
> In a runtime, on master, open the docbook sample VSP
> open the sample aird model
> open the obvious diagram and create a chapter, a big section, a medium section, a tiny section and a note
> open the evoluate view diagram
> select "Sect2" and try to move it

You will get the following stack
> org.eclipse.core.commands.ExecutionException: While executing ... exception occurred
> at org.eclipse.core.commands.operations.DefaultOperationHistory.execute(:524)
> at org.eclipse.sirius.diagram.ui.tools.internal.editor.DDiagramCommandStack.exe..(71
> ...
> Caused by: java.lang.ArithmeticException: / by zero
>	at java.math.BigDecimal.divideAndRound(BigDecimal.java:4106)
>	at java.math.BigDecimal.divide(BigDecimal.java:5153)
>	at java.math.BigDecimal.divide(BigDecimal.java:1561)
>       at org.eclipse.draw2d.geometry.PrecisionGeometry.preciseDivide(l48)
>	at org.eclipse.draw2d.geometry.Vector.getAngle(Vector.java:168)
>	at oesd.ui.internal.edit.parts.locator.EdgeLabelQuery.getSameLineStatus(l507)

For the current case, both vectors are horizontal (and the edge is hidden, we see only the arrow), it seems we might use referenceVector.isParallelTo(vector) and then check the horizontallity/verticallity and direction before computing the angle.
Comment 1 Eclipse Genie CLA 2017-06-19 10:02:53 EDT
New Gerrit change created: https://git.eclipse.org/r/99586
Comment 2 Eclipse Genie CLA 2017-06-19 10:02:55 EDT
New Gerrit change created: https://git.eclipse.org/r/99585
Comment 5 Laurent Redor CLA 2017-06-30 02:31:43 EDT
For scenario of bug 485010 comment 1, the files compatible with this version can be found here : http://git.eclipse.org/c/sirius/org.eclipse.sirius.git/tree/plugins/org.eclipse.sirius.tests.junit/data/unit/mappings/edges_on_edges?h=v3.1.x
Comment 6 Laurent Redor CLA 2017-07-03 03:37:14 EDT
Verified with Sirius 3.1.9-S20170627-085227 (scenario of bug 485010 comment 1)
Comment 7 Pierre-Charles David CLA 2017-07-07 07:20:07 EDT
Available in Sirius 3.1.9, see https://wiki.eclipse.org/Sirius/3.1.9 for details.