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();