From 7038a70f760cfdafcdb6d9a5b2eece09f7a54ec5 Mon Sep 17 00:00:00 2001 From: Hiraoka Date: Fri, 3 Sep 2021 21:59:12 +0900 Subject: [PATCH 1/2] Show change of winrate bar --- .../java/featurecat/lizzie/gui/LizzieFrame.java | 14 ++++++++++++++ .../java/featurecat/lizzie/gui/WinratePane.java | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/main/java/featurecat/lizzie/gui/LizzieFrame.java b/src/main/java/featurecat/lizzie/gui/LizzieFrame.java index 434828245..e524d2531 100644 --- a/src/main/java/featurecat/lizzie/gui/LizzieFrame.java +++ b/src/main/java/featurecat/lizzie/gui/LizzieFrame.java @@ -1030,6 +1030,20 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int g.setColor(Color.BLACK); g.fillRect(barPosxB, barPosY, barWidthB, barHeight); + // Draw change of winrate bars + if (validWinrate && validLastWinrate) { + double gain = 100 - lastWR - curWR; + double blackLastWR = Lizzie.board.getData().blackToPlay ? 100 - lastWR : lastWR; + int lastPosxW = barPosxB + (int) (blackLastWR * maxBarwidth / 100); + int diffPosX = Math.min(barPosxW, lastPosxW); + int diffWidth = Math.abs(barPosxW - lastPosxW); + Stroke oldstroke = g.getStroke(); + g.setStroke(new BasicStroke(strokeRadius)); + g.setColor(gain >= 0 ? Color.GREEN : Color.RED); + g.drawRect(diffPosX, barPosY, diffWidth, barHeight); + g.setStroke(oldstroke); + } + // Show percentage above bars g.setColor(Color.WHITE); g.drawString( diff --git a/src/main/java/featurecat/lizzie/gui/WinratePane.java b/src/main/java/featurecat/lizzie/gui/WinratePane.java index 9b40e8571..638384595 100644 --- a/src/main/java/featurecat/lizzie/gui/WinratePane.java +++ b/src/main/java/featurecat/lizzie/gui/WinratePane.java @@ -251,6 +251,20 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int g.setColor(Color.BLACK); g.fillRect(barPosxB, barPosY, barWidthB, barHeight); + // Draw change of winrate bars + if (validWinrate && validLastWinrate) { + double gain = 100 - lastWR - curWR; + double blackLastWR = Lizzie.board.getData().blackToPlay ? 100 - lastWR : lastWR; + int lastPosxW = barPosxB + (int) (blackLastWR * maxBarwidth / 100); + int diffPosX = Math.min(barPosxW, lastPosxW); + int diffWidth = Math.abs(barPosxW - lastPosxW); + Stroke oldstroke = g.getStroke(); + g.setStroke(new BasicStroke(strokeRadius)); + g.setColor(gain >= 0 ? Color.GREEN : Color.RED); + g.drawRect(diffPosX, barPosY, diffWidth, barHeight); + g.setStroke(oldstroke); + } + // Show percentage above bars g.setColor(Color.WHITE); g.drawString( From 8ffda31791e9ca2cd7511ffaad39b02956ee993a Mon Sep 17 00:00:00 2001 From: Hiraoka Date: Wed, 8 Sep 2021 20:20:03 +0900 Subject: [PATCH 2/2] Simplify style of "change of winrate bar" --- src/main/java/featurecat/lizzie/gui/LizzieFrame.java | 7 ++----- src/main/java/featurecat/lizzie/gui/WinratePane.java | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/main/java/featurecat/lizzie/gui/LizzieFrame.java b/src/main/java/featurecat/lizzie/gui/LizzieFrame.java index e524d2531..1003f1c9c 100644 --- a/src/main/java/featurecat/lizzie/gui/LizzieFrame.java +++ b/src/main/java/featurecat/lizzie/gui/LizzieFrame.java @@ -1032,15 +1032,12 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int // Draw change of winrate bars if (validWinrate && validLastWinrate) { - double gain = 100 - lastWR - curWR; double blackLastWR = Lizzie.board.getData().blackToPlay ? 100 - lastWR : lastWR; int lastPosxW = barPosxB + (int) (blackLastWR * maxBarwidth / 100); - int diffPosX = Math.min(barPosxW, lastPosxW); - int diffWidth = Math.abs(barPosxW - lastPosxW); Stroke oldstroke = g.getStroke(); g.setStroke(new BasicStroke(strokeRadius)); - g.setColor(gain >= 0 ? Color.GREEN : Color.RED); - g.drawRect(diffPosX, barPosY, diffWidth, barHeight); + g.setColor(Color.GRAY); + g.drawLine(lastPosxW, barPosY, lastPosxW, barPosY + barHeight); g.setStroke(oldstroke); } diff --git a/src/main/java/featurecat/lizzie/gui/WinratePane.java b/src/main/java/featurecat/lizzie/gui/WinratePane.java index 638384595..42fda26fc 100644 --- a/src/main/java/featurecat/lizzie/gui/WinratePane.java +++ b/src/main/java/featurecat/lizzie/gui/WinratePane.java @@ -253,15 +253,12 @@ private void drawMoveStatistics(Graphics2D g, int posX, int posY, int width, int // Draw change of winrate bars if (validWinrate && validLastWinrate) { - double gain = 100 - lastWR - curWR; double blackLastWR = Lizzie.board.getData().blackToPlay ? 100 - lastWR : lastWR; int lastPosxW = barPosxB + (int) (blackLastWR * maxBarwidth / 100); - int diffPosX = Math.min(barPosxW, lastPosxW); - int diffWidth = Math.abs(barPosxW - lastPosxW); Stroke oldstroke = g.getStroke(); g.setStroke(new BasicStroke(strokeRadius)); - g.setColor(gain >= 0 ? Color.GREEN : Color.RED); - g.drawRect(diffPosX, barPosY, diffWidth, barHeight); + g.setColor(Color.GRAY); + g.drawLine(lastPosxW, barPosY, lastPosxW, barPosY + barHeight); g.setStroke(oldstroke); }