From 9d43ffdb5e70d057d70cd9a5b3fb9ffb896f9f3d Mon Sep 17 00:00:00 2001 From: Starryi Date: Thu, 11 Nov 2021 10:34:12 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-62433=2011.0=E8=AE=BE=E8=AE=A1=E5=99=A8-?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=B7=E5=BC=8F-=E6=9C=89?= =?UTF-8?q?=E9=83=A8=E5=88=86=E6=A0=B7=E5=BC=8F=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E5=AD=97=E4=BD=93=E5=86=85=E5=AE=B9=E4=B8=8D=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 问题颜色亮度计算错误 【改动思路】 同上 --- .../fr/design/cell/CellStylePreviewPane.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java b/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java index 355dca62d..12f5a5228 100644 --- a/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java @@ -51,14 +51,7 @@ public class CellStylePreviewPane extends JPanel { } private void paintTransparentBackground(Graphics2D g2d, Style style) { - Color fontColor = style.getFRFont().getForeground(); - float g = fontColor.getRed() * 0.299F + fontColor.getGreen() * 0.587F * fontColor.getBlue() * 0.114F; - float alpha = 1.0F; - if (g < 50) { - alpha = 0.2F; - } else if (g < 160){ - alpha = 0.5F; - } + float alpha = computeTransparentBackgroundAlpha(style); float scaleWidth = 1.0F * getWidth() / transparentBackgroundWidth; float scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight; @@ -76,6 +69,23 @@ public class CellStylePreviewPane extends JPanel { g2d.setComposite(oldComposite); } + private float computeTextColorBrightness(Style style) { + Color fontColor = style.getFRFont().getForeground(); + return fontColor.getRed() * 0.299F + fontColor.getGreen() * 0.587F + fontColor.getBlue() * 0.114F; + } + + private float computeTransparentBackgroundAlpha(Style style) { + float textBrightness = computeTextColorBrightness(style); + + float alpha = 1.0F; + if (textBrightness < 50) { + alpha = 0.2F; + } else if (textBrightness < 160){ + alpha = 0.5F; + } + return alpha; + } + private void paintCellStyle(Graphics2D g2d, Style style) { int resolution = ScreenResolution.getScreenResolution();