| Summary: | Using orthogonal routing together with static anchors causes end/start segment to be removed when overlaying connection | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Victor Johnsson <victor.johnsson> | ||||||||||
| Component: | GEF MVC | Assignee: | gef-inbox <gef-inbox> | ||||||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||||||
| Severity: | normal | ||||||||||||
| Priority: | P3 | CC: | matthias.wienand, victor.johnsson | ||||||||||
| Version: | unspecified | ||||||||||||
| Target Milestone: | --- | ||||||||||||
| Hardware: | PC | ||||||||||||
| OS: | Windows 7 | ||||||||||||
| Whiteboard: | |||||||||||||
| Attachments: |
|
||||||||||||
Created attachment 265261 [details]
How to replicate (image 1)
Created attachment 265262 [details]
How to replicate (image 2)
Created attachment 265263 [details]
How to replicate (image 3)
I implemented overlay removal for connected StaticAnchors at the start/end points as well as for unconnected start/end points, and added tests for both scenarios.
The erroneous piece of code within BendConnectionPolicy#testAndRemoveSegmentOverlay() was the replacement of the anchors of the overlay removal result segment. This is done to implement proper snapping if the overlain anchor is unconnected. However, the connectedness of the result start/end was not correctly determined. Therefore, I exposed the Connection#isConnected(IAnchor) method in order to use it to determine the connectedness of the result start/end anchor. This fixes the overlay removal for connected StaticAnchors.
Furthermore, I ensured that the start/end point of the connection is never overwritten due to result replacement when removing an overlay.
If you wish to patch an earlier version, the working code for performing result replacement/adjustment is as follows:
Integer resultStartIndex = explicit.get(0);
IAnchor resultStartAnchor = getBendOperation().getNewAnchors()
.get(resultStartIndex);
Connection connection = getBendOperation().getConnection();
if (resultStartIndex > 0
&& !connection.isConnected(resultStartAnchor)) {
getBendOperation().getNewAnchors().set(resultStartIndex,
createUnconnectedAnchor(resultStart));
}
Integer resultEndIndex = explicit.get(explicit.size() - 1)
- removedCount;
IAnchor resultEndAnchor = getBendOperation().getNewAnchors()
.get(resultEndIndex);
if (resultEndIndex < getBendOperation().getNewAnchors().size() - 1
&& !connection.isConnected(resultEndAnchor)) {
getBendOperation().getNewAnchors().set(resultEndIndex,
createUnconnectedAnchor(resultEnd));
}
The code is published on the master branch, therefore, I resolve this ticket as fixed for 5.0.0 M4. Feel free to reopen this ticket if you encounter any related problems.
|
Created attachment 265260 [details] Patch to trigger the bug in the MVC Logo example Dragging the one of the last two segments of a connection with orthogonal routing, connected to a static anchor, causes the segment to be removed as overlaid if it is dragged to a position going straight out from the connector. The issue can be triggered in the MVC Logo example if the anchor provider is exchanged as in the attached patch. The attached images show the replication steps, which are: 1. Set the routing style of a line to orthogonal. 2. Drag the next-to-last segment downward 3. The segment disappears and the connection is disconnected from the anchor once the y coordinates of the segment and the static anchor are close enough. The same thing happens if the last segment is dragged sideways and then returned to its initial position, or if the sideways drag is short enough that the new and previous positions are considered to be overlaid. The same also happens for the two segments closes to the other anchor. The removal is triggered in org.eclipse.gef.mvc.fx.BendConnectionPolicy#testAndRemoveSegmentOverlay.