<Swing Dev> RFR: 8256713: SwingSet2 : Slider leaves tracks in uiScale=2

Sergey Bylokhov serb at openjdk.java.net
Sun Nov 22 09:20:36 UTC 2020


The problem became visible, when we draw a border across the component using drawLine, and expected that fillRect will clear a border of the component. This is incorrect because in the case of the scaled graphics(retina) some part of the line can be placed outside of the bounds of the rectangle. See additional information here:
https://bugs.openjdk.java.net/browse/JDK-8011764

This bug has occurred when the old default metal theme is used(DefaultMetalTheme) or thems based on it(Custom themes in the SwingSet2).

The fix applies the clip before the rendering so the paint method will not touch pixels outside the component.

As a fix, we could try to draw the lines using subpixel coordinates, but that code is expected to work using Graphics object(unlike current default metal theme: Ocean)  which uses the only int as a coordinate, not a Graphics2D

To make rendering a little bit better I tried antialiasing but it does not produce a better result, so did not use it in the fix.

-------------

Commit messages:
 - Update PaintThumbSize.java
 - Create PaintThumbSize.java
 - Initial fix

Changes: https://git.openjdk.java.net/jdk/pull/1373/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=1373&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8256713
  Stats: 192 lines in 3 files changed: 177 ins; 2 del; 13 mod
  Patch: https://git.openjdk.java.net/jdk/pull/1373.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/1373/head:pull/1373

PR: https://git.openjdk.java.net/jdk/pull/1373


More information about the swing-dev mailing list