Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 483821

Summary: ChopboxAnchor.IComputationStrategy.Impl#getAnchorageReferenceGeometryInLocal() needs to evaluate visual outline rather than geometric outline.
Product: [Tools] GEF Reporter: Alexander Nyßen <nyssen>
Component: GEF FXAssignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: matthias.wienand
Version: 0.2.0   
Target Milestone: 4.0.0 / 3.11.0 (Neon) M5   
Hardware: All   
OS: All   
Whiteboard:

Description Alexander Nyßen CLA 2015-12-07 11:01:28 EST
The default implementation within ChopboxAnchor.IComputationStrategy.Impl#getAnchorageReferenceGeometryInLocal() uses the geometry of a GeometryNode to calculate the intersection point. This geometry however does not include the stroke. 

Anchor positions are only calculated correctly at the moment because GeometryNode's layout bounds do not include the stroke (but are based on the passed in geometry alone). As soon as we fix this, positions will no longer be accurate.
Comment 1 Alexander Nyßen CLA 2015-12-07 11:36:35 EST
The computation needed here will be equal to the one sketched for the VisualOutlineGeometryProvider (see bug #483710).
Comment 2 Matthias Wienand CLA 2015-12-18 04:45:10 EST
I refactored the ChopBoxAnchor.IComputationStrategy.Impl so that anchor positions can also be computed for anchorages with a visual of type JavaFX Shape, as well as for GeometryNodes with a Path geometry. During the refactoring, I performed the following changes:

- In order to determine the anchorage geometry it was necessary to convert from JavaFX Shape to GEF4 Geometry. The conversions are provided within 2 utility classes: Geometry2Shape, and Shape2Geometry.

- In order to determine the outline of a Path geometry, I added a Path#getOutlines() method that returns one ICurve per Path.Segment. In this context, I also fixed a NPE when calling CubicCurve#equals(null).

- The ShapeOutlineProvider (i.e. VisualOutlineGeometryProvider) is implemented by resizing the geometric outline of a JavaFX Node to fit the node's layout-bounds. The same computation is used to expand the anchorage geometry to the anchorage's layout-bounds. For this purpose, I changed the visibility of GeometryNode#resizeGeometry() to public. However, this mechanic is only successful if the stroke around the geometry is uniform. Nonetheless, I extracted this functionality to a method within the NodeUtils utility class. The ChopBoxAnchor and the ShapeOutlineProvider both use this method.

- When determining the layout-bounds of a JavaFX Node, a compensation has to be performed for JavaFX bug 8145499 (https://bugs.openjdk.java.net/browse/JDK-8145499). This compensation was already provided within Connection#getShapeBounds(). I moved the method to the NodeUtils utility class.

- To demonstrate the new capabilities of the ChopBoxAnchor, I added a ChopBoxShapeSnippet.

The code is published on the master branch. Therefore, I resolve this ticket as fixed for 3.11.0M5.