[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-2d-dev
Subject:    Re: RFR: 8311031: JTable header border vertical lines are not aligned with data grid lines [v10]
From:       Alexey Ivanov <aivanov () openjdk ! org>
Date:       2023-07-31 21:13:00
Message-ID: 6lGmsyusT2v4Q1gJj7d1X0cH3R8GLZIXhIv-eHdpFDw=.90ae0f8c-ed8e-4200-9574-bf913cf206cd () github ! com
[Download RAW message or body]

On Mon, 31 Jul 2023 16:31:21 GMT, Tejesh R <tr@openjdk.org> wrote:

> > The header border uses `g.drawLine` whereas the JTable data grid lines uses \
> > `SwingUtilities2.drawVLine` and `SwingUtilities2.drawHLine` to draw horizontal \
> > and vertical lines. The SwingUtilities2 uses `Graphics.fillRect` which \
> > contributes to the difference between the position of these two lines which \
> > happens/visible at higher ui scaling (difference in alignment between vertical \
> > lines of these two). The fix propose to use the same methods for metal L&F of \
> > JTable header border paint.  CI testing shows green.
> > 
> > ![image](https://github.com/openjdk/jdk/assets/94159358/f6d1d822-55ba-4ad3-9914-d3f68b67a6c5)
> > 
> 
> Tejesh R has updated the pull request incrementally with one additional commit \
> since the last revision: 
> Review fix

test/jdk/javax/swing/JTableHeader/TableHeaderBorderPositionTest.java line 60:

> 58: 
> 59:         String[] columnNames = {"Size", "Size"};
> 60:         JTable table = new JTable(data, columnNames);

Suggestion:

        String[][] data = {
                {"1", "1"}
        };
        String[] columnNames = {"Size", "Size"};

        JTable table = new JTable(data, columnNames);

Let's separate the data — `data` and `columnNames` from the table.

test/jdk/javax/swing/JTableHeader/TableHeaderBorderPositionTest.java line 68:

> 66: 
> 67:         BufferedImage bufferedImage = new BufferedImage(WIDTH, HEIGHT,
> 68:                 BufferedImage.TYPE_INT_RGB);

Suggestion:

        JTable table = new JTable(data, columnNames);
        Dimension tableSize = table.getPreferredSize();
        table.setSize(tableSize);

        final JTableHeader header = table.getTableHeader();
        Dimension headerSize = header.getPreferredSize();
        header.setSize(headerSize);

        Dimension size = new Dimension(Math.max(headerSize.width, tableSize.width),
                                       headerSize.height + tableSize.height);

        BufferedImage bufferedImage =
                new BufferedImage((int)Math.ceil(size.width * SCALE),
                                  (int)Math.ceil(size.height * SCALE),
                                  BufferedImage.TYPE_INT_RGB);


This takes into account both the header size and table size and sets the size of the \
image appropriately.

The constants `WIDTH` and `HEIGHT` have become redundant.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14766#discussion_r1279879383
PR Review Comment: https://git.openjdk.org/jdk/pull/14766#discussion_r1279880928


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic