From 1d7127adc8976e139c6f5808db609a62be2ce1cd Mon Sep 17 00:00:00 2001 From: weisj <31143295+weisJ@users.noreply.github.com> Date: Tue, 18 May 2021 18:02:06 +0200 Subject: [PATCH] Everywhere: Remove calls to internal API SwingUtilities2::drawHLine and SwingUtilities2::drawVLine. --- .../weisj/darklaf/graphics/PaintUtil.java | 18 ++++++++++++++++++ .../weisj/darklaf/ui/table/DarkTableUI.java | 8 ++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/github/weisj/darklaf/graphics/PaintUtil.java b/core/src/main/java/com/github/weisj/darklaf/graphics/PaintUtil.java index 83c914db..570cb1cc 100644 --- a/core/src/main/java/com/github/weisj/darklaf/graphics/PaintUtil.java +++ b/core/src/main/java/com/github/weisj/darklaf/graphics/PaintUtil.java @@ -275,4 +275,22 @@ public final class PaintUtil { public static void fillRect(final Graphics g, final int x, final int y, final int w, final int h) { g.fillRect(x, y, w, h); } + + public static void drawVLine(final Graphics g, int x, int y1, int y2) { + if (y2 < y1) { + final int temp = y2; + y2 = y1; + y1 = temp; + } + g.fillRect(x, y1, 1, y2 - y1 + 1); + } + + public static void drawHLine(final Graphics g, int x1, int x2, int y) { + if (x2 < x1) { + final int temp = x2; + x2 = x1; + x1 = temp; + } + g.fillRect(x1, y, x2 - x1 + 1, 1); + } } diff --git a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java index f05450d2..8618df91 100644 --- a/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java +++ b/core/src/main/java/com/github/weisj/darklaf/ui/table/DarkTableUI.java @@ -172,7 +172,7 @@ public class DarkTableUI extends DarkTableUIBridge implements TableConstants, Ha int y = damagedArea.y; for (int row = rMin; row <= rMax; row++) { y += table.getRowHeight(row); - SwingUtilities2.drawHLine(g, damagedArea.x, tableWidth - 1, y - 1); + PaintUtil.drawHLine(g, damagedArea.x, tableWidth - 1, y - 1); } } @@ -185,14 +185,14 @@ public class DarkTableUI extends DarkTableUIBridge implements TableConstants, Ha boolean ltr = table.getComponentOrientation().isLeftToRight(); x = damagedArea.x; if (scrollPaneRtl && scrollBarVisible()) { - SwingUtilities2.drawVLine(g, x, 0, tableHeight - 1); + PaintUtil.drawVLine(g, x, 0, tableHeight - 1); } if (ltr) { for (int column = cMin; column <= cMax; column++) { int w = cm.getColumn(column).getWidth(); x += w; if (showVerticalLine(true, scrollVisible, !scrollPaneRtl, column, draggedIndex, cMin, cMax)) { - SwingUtilities2.drawVLine(g, x - 1, 0, tableHeight - 1); + PaintUtil.drawVLine(g, x - 1, 0, tableHeight - 1); } } } else { @@ -200,7 +200,7 @@ public class DarkTableUI extends DarkTableUIBridge implements TableConstants, Ha int w = cm.getColumn(column).getWidth(); x += w; if (showVerticalLine(false, scrollVisible, !scrollPaneRtl, column, draggedIndex, cMin, cMax)) { - SwingUtilities2.drawVLine(g, x - 1, 0, tableHeight - 1); + PaintUtil.drawVLine(g, x - 1, 0, tableHeight - 1); } } }