Community
Participate
Working Groups
Created attachment 105424 [details] fix the precision error Build ID: I20080530-1730 Steps To Reproduce: More information: use double instead of float for the weight
API can not be changed. Will this work instead: return new PrecisionPoint((a1.preciseX() + d1.preciseWidth()) * (1f - weight) + weight * (a2.preciseX() + d2.preciseWidth()), (a1.preciseY() + d1.preciseHeight()) * (1f - weight) + weight * (a2.preciseY() + d2.preciseHeight())); Change 1f to 1.0, so that the subtraction is done using double precision.
Well, for my use case, yes your suggestion fixes the bug. Regarding changing the signature from float to double, the API will be backward compatible, so what is the problem ? Because even it fixes my current problem, there is still a potential problem with GMF, https://bugs.eclipse.org/bugs/show_bug.cgi?id=237803 org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart#refreshBendpoints protected void refreshBendpoints() { RelativeBendpoints bendpoints = (RelativeBendpoints) getEdge() .getBendpoints(); List modelConstraint = bendpoints.getPoints(); List figureConstraint = new ArrayList(); for (int i = 0; i < modelConstraint.size(); i++) { org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint wbp = (org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint) modelConstraint .get(i); RelativeBendpoint rbp = new RelativeBendpoint(getConnectionFigure()); rbp.setRelativeDimensions(new Dimension(wbp.getSourceX(), wbp .getSourceY()), new Dimension(wbp.getTargetX(), wbp .getTargetY())); if (modelConstraint.size() == 1) { rbp.setWeight(0.5f); } else { ---> rbp.setWeight(i / ((float) modelConstraint.size() - 1)); } figureConstraint.add(rbp); } getConnectionFigure().setRoutingConstraint(figureConstraint); } Could you include your fix in Ganymede ? Thanks
> Regarding changing the signature from float to double, the API will be backward > compatible, so what is the problem ? How is a signature change backwards compatible? This would break both binary and source compatibility. > Because even it fixes my current problem, there is still a potential problem > with GMF, I don't see the issue with the above fix. Weighting is just a hint about whether the bendpoint should stay closer to the source or target end of the connection. It could be a number from 1-100, and things should still work about the same to the user, even if you had over 100 bendpoints.
> How is a signature change backwards compatible? This would break both binary > and source compatibility. I was speaking about source compatibility. It will be source compatible because there is an automatic casting from float to double. Anyway, your are right on the other part of your comment. You change will fix all the use cases. Thanks
Let me know if you can include your fix in Ganymede? Thx
(In reply to comment #5) > Let me know if you can include your fix in Ganymede? Thx > Ganymede is closed but I think we can put this in the maintenance release.
Created attachment 109526 [details] Patch that contains Randy Hudson's fix.
Thanks for the patch. Stephane, can you confirm this latest patch works for you? Any ideas on how we can add a JUnit test that demonstrates the failure?
This patch works for us. I will write a JUnit test to highlight the bug.
Created attachment 110220 [details] Screenshots, before and after having applied the fix.
Created attachment 110221 [details] Unit test to highlight the bug.
Committed to R3_4_maintenance and HEAD