I have a source component and a target component and I want to calculate the corner point where they will be connected. I am implementing a method that takes the source and target points and their orientations (either horizontal or vertical) as inputs. Here is the skeleton of the method:
private final static int HORIZONTAL = 0;
private final static int VERTICAL = 1;
private PointF computeCornerPoint(PointF sourcePoint, int sourceComponentOrientation, PointF targetPoint, int targetComponentOrientation) {
PointF cornerPoint = new PointF();
// TODO: Calculate the corner point here
return cornerPoint;
}
I have created a diagram that shows all the possible cases. In the diagram, the green points are the source and target points, and the red point is the corner point that I want to compute.
Also, note that this problem is symmetric, so the source and target components can be swapped, and the diagram I provided only shows one case.
In Android, the x-coordinate increases from left to right, and the y-coordinate increases from top to bottom.
Can you suggest an algorithm or a solution to compute the corner point for all these cases?
Additionally, please let me know if there is any information missing that would be helpful in solving this problem.