Weird behaviour with coordinates in a BorderLayout
posted 1 year ago
strange title, I know, but I hope I can explain it in what follows. It is
about what I thought was an error in my program, but after spending
the whole afternoon up to now, I can circumvent the problem, but I
do not exactly know why I witness this behaviour.
I have a frame, and its contentpane contains two panels, one in the
north and one in the center.
For the center panel, I have user coordinates, ranging from (-1, -1)
bottom left to (1,1) top right.
If I create an AffineTransform to do this, then I see that my points
in user coordinates do get mapped to the normal panel coordinates
that range from (0,0) top left to (width, height) bottom right.
However, when I set the affine transfom of my Graphics2D to this transform,
then I notice that the user coordinates suddenly are relative to
the top left of the frame itself, in stead of to the center panel.
When I leave out this north panel, everything works as it should.
Here is an SSCC that demonstrates my issue.
Does anyone know if this behaviour is described somewhere? I had
never encountered it. I have written a new library routine
that maps one coordinate system to another one, optionally
keeping the aspect ratio unchanged. When I tested it this morning,
I noticed what I am describing here.