On Sat, 12 Feb 2022 01:10:49 GMT, Sergey Bylokhov <[email protected]> wrote:
>> Changed the drawing area to be increased by 0.5 on the left side to prevent
>> clipping
>
> src/java.desktop/share/classes/javax/swing/border/TitledBorder.java line 354:
>
>> 352: Graphics2D g2d = (Graphics2D) g2;
>> 353: Path2D path = new Path2D.Float();
>> 354: path.append(new Rectangle2D.Float((float)
>> borderX, borderY, borderW, labelY - borderY), false);
>
> Why the current coordinates do not work, is it because we calculate them in
> the wrong way or probably the insets are wrong?
I think there's a rounding error when doing x.5 scalings causing the drawing
area to be one pixel too small on the left side
> test/jdk/java/awt/TitledBorder/TitledBorderTest.java line 51:
>
>> 49: saveImage(buff, "test.png");
>> 50: throw new RuntimeException("Border was clipped or overdrawn.");
>> 51: }
>
> Can we draw directly to the buffered image using the scaled graphics to
> reproduce the bug?
Yea, the test fails before the fix, and when inspecting the saved image it
looks identical to the actual frame.
-------------
PR: https://git.openjdk.java.net/jdk/pull/7449