I'm in the process of writing a "Paint" application in Java consisting of rectangular nodes and undirected edges. The problem is that the begiing of the edge is in the center of the rectangle the edge is coected to, and the end of the edge is in the center of the other rectangle this edge is coected to.
To avoid drawing the intersection between the rectangle and the edge, I draw edges first and nodes afterwards, so that they are placed on top of the edges, thus hiding the intersection.
The problem arises when another node, which does not correspond to that edge is placed along the edge. In this scenario, because edges are drawn first, the node appears on top of the edge. However, that is not what I want. I want the edge to show on top of the node.
Images: how it is and how it should be
The most comprehensive way I can think of to fix this would be to draw nodes first and afterwards draw the edges avoiding the intersections of the edge with the two nodes it is coected to. However that is difficult to do on paper because I draw edges using drawLine, and I do not have the possibility to check for intersections.
This is why I draw edges first, but then the problem I mentioned arises. Any ideas?
