Edges in state diagrams connecting to the corner SW and SE points of rounded rectangles are positioned incorrectly. This can happen at either endpoints of the edge, as shown below.
Location of Error
The error was in GeomUtils#intersectRectangle, which is called by GeomUtils#intersectRoundedRectangle to calculate the precise connection point on the rounded portions of the rounded rectangle.
What was Wrong
The problem occurs when the edge is positioned on the exact corner point in the SW and SE direction.
The if conditions in intersectRectangle uses the ifBetween(start, end) method to check whether a direction is between start and end. The start and end value themselves are exclusive. For instance, 60° would not be between 60° (start) and 90° (end). (The documentation, which says that the starting direction is inclusive, may have been the reason for the oversight which led to this miscalculation).
So, by the logic of the if/else-if/else branch in intersectRectangle, if a user positions two nodes such that the edge is pointing in the exact direction of diagonalSE, the flow of execution would be delegated to the else branch, despite the fact that it should be handled by one of the appropriate if/else if branch, which in this case could be else if( pDirection.isBetween(diagonalNE, diagonalSE) ). Interestingly, this did not impact the NW and NE corners because these two cases can be handled appropriately by the else branch in any case.
Fix
By incrementing the range of the end values by 1 to include corner directions, we can ensure that the calculation is handled by the correct branch of if statements, and thus compute the offset for the connection points between node and edge correctly. To continue the example above, to fix the connection point for the SE corner, we can include the SE corner direction with the following code: else if( pDirection.isBetween(diagonalNE, diagonalSE.rotatedBy(1)) )
Issue
Edges in state diagrams connecting to the corner SW and SE points of rounded rectangles are positioned incorrectly. This can happen at either endpoints of the edge, as shown below.![image](https://github.com/prmr/JetUML/assets/113862811/42d24e4d-99e3-41bf-8940-d0b5c604c239)
Location of Error
The error was in
GeomUtils#intersectRectangle
, which is called byGeomUtils#intersectRoundedRectangle
to calculate the precise connection point on the rounded portions of the rounded rectangle.What was Wrong
The problem occurs when the edge is positioned on the exact corner point in the SW and SE direction. The if conditions in
intersectRectangle
uses theifBetween(start, end)
method to check whether a direction is between start and end. The start and end value themselves are exclusive. For instance, 60° would not be between 60° (start) and 90° (end). (The documentation, which says that the starting direction is inclusive, may have been the reason for the oversight which led to this miscalculation).So, by the logic of the if/else-if/else branch in
intersectRectangle
, if a user positions two nodes such that the edge is pointing in the exact direction ofdiagonalSE
, the flow of execution would be delegated to theelse
branch, despite the fact that it should be handled by one of the appropriateif/else if
branch, which in this case could beelse if( pDirection.isBetween(diagonalNE, diagonalSE) )
. Interestingly, this did not impact the NW and NE corners because these two cases can be handled appropriately by theelse
branch in any case.Fix
By incrementing the range of the end values by 1 to include corner directions, we can ensure that the calculation is handled by the correct branch of if statements, and thus compute the offset for the connection points between node and edge correctly. To continue the example above, to fix the connection point for the SE corner, we can include the SE corner direction with the following code:
else if( pDirection.isBetween(diagonalNE, diagonalSE.rotatedBy(1)) )