Browse Source

REPORT-62433 11.0设计器-单元格样式-有部分样式显示的字体内容不全

【问题原因】
问题颜色亮度计算错误

【改动思路】
同上
feature/x
Starryi 3 years ago
parent
commit
9d43ffdb5e
  1. 26
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java

26
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) { private void paintTransparentBackground(Graphics2D g2d, Style style) {
Color fontColor = style.getFRFont().getForeground(); float alpha = computeTransparentBackgroundAlpha(style);
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 scaleWidth = 1.0F * getWidth() / transparentBackgroundWidth; float scaleWidth = 1.0F * getWidth() / transparentBackgroundWidth;
float scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight; float scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight;
@ -76,6 +69,23 @@ public class CellStylePreviewPane extends JPanel {
g2d.setComposite(oldComposite); 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) { private void paintCellStyle(Graphics2D g2d, Style style) {
int resolution = ScreenResolution.getScreenResolution(); int resolution = ScreenResolution.getScreenResolution();

Loading…
Cancel
Save