<Swing Dev> [9] Review request for 8165594 Bad rendering of Swing UI controls with Windows Classic L&F on HiDPI display

Andrej Golovnin andrej.golovnin at gmail.com
Wed Sep 21 20:38:49 UTC 2016


Hi Alexandr,

looks good. Thanks!

Best regards,
Andrej Golovnin

> On 20 Sep 2016, at 18:35, Alexandr Scherbatiy <alexandr.scherbatiy at oracle.com> wrote:
> 
> 
>  Thank you for the suggested code.
> 
>  Could you review the updated fix:
>    http://cr.openjdk.java.net/~alexsch/8165594/webrev.04
> 
>  - the provided method is used to draw triangles in BasicArrowButton class
>  - shift to one pixel right is added for the triangles drawing
>  - AA rendering hint is set to draw a radio button
> 
>  Screenshots [1] and [2] shows difference between icons drawing before and after the fix for scales 2x and 4x.
> 
>  [1] http://cr.openjdk.java.net/~alexsch/8165594/screenshots/icons-windows-classic-2x_03.png
>  [2] http://cr.openjdk.java.net/~alexsch/8165594/screenshots/icons-windows-classic-4x_03.png
> 
>  Thanks,
>  Alexandr.
> 
> On 9/20/2016 5:34 PM, Semyon Sadetsky wrote:
>> I would rewrite the method that draws triangle to simplify it:
>> 
>>    private void paintScaledTriangle(Graphics g, double x, double y, double size,
>>                                     int direction, boolean isEnabled) {
>>        size = Math.max(size , 2);
>>        Path2D.Double path = new Path2D.Double();
>>        path.moveTo(-size, size/2);
>>        path.lineTo(size, size/2);
>>        path.lineTo(0, -size/2);
>>        path.closePath();
>>        AffineTransform affineTransform = new AffineTransform();
>>        affineTransform.rotate(Math.PI * (direction - 1) / 4 );
>>        path.transform(affineTransform);
>> 
>>        Graphics2D g2d = (Graphics2D) g;
>>        g2d.translate(x + size / 2. - 1, y + size / 2);
>>        Color oldColor = g.getColor();
>>        if (!isEnabled) {
>>            g2d.translate(1, 0);
>>            g2d.setColor(highlight);
>>            g2d.fill(path);
>>            g2d.translate(-1, 0);
>>        }
>>        g2d.setColor(isEnabled ? darkShadow : shadow);
>>        g2d.fill(path);
>>        g2d.translate( - x - size / 2. + 1, - y - size / 2);
>>        g2d.setColor(oldColor);
>>    }
>> 
>> I'm suggesting to make the paintTriangle() method accept floating point coordinates to get more precise location and size for the scaled version.
>> 
>> Optionally, 2D AA hints can be added to get better appearance for scales 1.25, 1.5, 1.75.
>> 
>> --Semyon
>> 
>> 
>> On 9/20/2016 2:58 PM, Alexandr Scherbatiy wrote:
>>> 
>>> Hello,
>>> 
>>> Could you review the updated fix:
>>>  http://cr.openjdk.java.net/~alexsch/8165594/webrev.02
>>> 
>>> The code formatting issues are updated.
>>> 
>>> On 9/14/2016 8:02 PM, Semyon Sadetsky wrote:
>>>> Hi Alexander,
>>>> 
>>>> When I press the arrow button (for example in the "111" combo) several times I can see artifacts. They are well seen in scale x4.
>>>  I have filled an issue on it: JDK-8166368 JComboBox drawing has artifacts with Windows Classic L&F on HiDPI display
>>>    https://bugs.openjdk.java.net/browse/JDK-8166368
>>> 
>>>  Thanks,
>>>  Alexandr.
>>> 
>>>> 
>>>> --Semyon
>>>> 
>>>> 
>>>> On 9/14/2016 5:39 PM, Alexandr Scherbatiy wrote:
>>>>> 
>>>>> Hello,
>>>>> 
>>>>> Could you review the updated fix:
>>>>>  http://cr.openjdk.java.net/~alexsch/8165594/webrev.01
>>>>> 
>>>>> - HiDPI icons are only drawn for scaled graphics.
>>>>> 
>>>>>  The screenshots [1], [2], and [3] show difference between icons drawing before and after the fix for scales 1x, 2x, and 4x.
>>>>> 
>>>>>  [1] http://cr.openjdk.java.net/~alexsch/8165594/screenshots/icons-windows-classic-1x_01.png
>>>>>  [2] http://cr.openjdk.java.net/~alexsch/8165594/screenshots/icons-windows-classic-2x_01.png
>>>>>  [3] http://cr.openjdk.java.net/~alexsch/8165594/screenshots/icons-windows-classic-4x_01.png
>>>>> 
>>>>>  Thanks,
>>>>>  Alexandr.
>>>>> 
>>>>> On 9/8/2016 10:59 AM, Andrej Golovnin wrote:
>>>>>> Hi Alexandr,
>>>>>> 
>>>>>>>   [1]
>>>>>>> http://cr.openjdk.java.net/~alexsch/8165594/screenshots/icons-windows-classic-1x.png 
>>>>>> The icons do not look right to me. Take look at the top-left part of
>>>>>> the radio button. There is a white pixel between the shadow lines. And
>>>>>> in the selected state there should be a black circle. But instead it
>>>>>> is a square. The check sign of the checkbox is too thin. And the
>>>>>> arrows of the combobox and the vertical scroll bar should have a
>>>>>> single pixel at the top/bottom side. But now they have two pixels.
>>>>>> 
>>>>>> It would be also nice to see a screen shot of the native Windows
>>>>>> components for comparison.
>>>>>> 
>>>>>> Personally when I would make changes like that, then my code would
>>>>>> look like this:
>>>>>> 
>>>>>> if (isNotHiDPI() || itMakesMoreSenseToUseTheOldCode()) {
>>>>>>    // use the old good code.
>>>>>> } else {
>>>>>>    // use the new code
>>>>>> }
>>>>>> 
>>>>>> Best regards,
>>>>>> Andrej Golovnin
>>>>>> 
>>>>>>>   [2]
>>>>>>> http://cr.openjdk.java.net/~alexsch/8165594/screenshots/icons-windows-classic-2x.png 
>>>>>>>   [3]
>>>>>>> http://cr.openjdk.java.net/~alexsch/8165594/screenshots/icons-windows-classic-4x.png 
>>>>>>> 
>>>>>>>  Thanks,
>>>>>>>  Alexandr.
>>>>>>> 
>>>>>>> 
>>>>> 
>>>> 
>>> 
>> 
> 




More information about the swing-dev mailing list