Browse Source

REPORT-59674 FR11新主题,单元格样式跟随主题时,样式选择中的字体看不清

【问题原因】
修改单元格样式阅览面板中透明图片的透明度规则,根据文字颜色
自动调整图片透明度

【改动思路】
同上
research/11.0
Starryi 3 years ago
parent
commit
5e8142342c
  1. 31
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  2. BIN
      designer-base/src/main/resources/com/fr/design/images/transparent_background.png

31
designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java

@ -6,6 +6,9 @@ import com.fr.base.Style;
import com.fr.general.IOUtils;
import javax.swing.JPanel;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Composite;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
@ -40,10 +43,21 @@ public class CellStylePreviewPane extends JPanel {
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int resolution = ScreenResolution.getScreenResolution();
int width = getWidth();
int height = getHeight();
paintTransparentBackground(g2d, style);
paintCellStyle(g2d, style);
}
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 scaleWidth = 1.0F * getWidth() / transparentBackgroundWidth;
float scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight;
@ -54,7 +68,18 @@ public class CellStylePreviewPane extends JPanel {
} else {
scaleHeight = scaleWidth = maxScale;
}
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
g2d.drawImage(transparentBackgroundImage, 0, 0, (int) (transparentBackgroundWidth * scaleWidth), (int) (transparentBackgroundHeight * scaleHeight), null);
g2d.setComposite(oldComposite);
}
private void paintCellStyle(Graphics2D g2d, Style style) {
int resolution = ScreenResolution.getScreenResolution();
int width = getWidth();
int height = getHeight();
if (style == Style.DEFAULT_STYLE) {
// 如果是默认的style,就只写"Report"上去

BIN
designer-base/src/main/resources/com/fr/design/images/transparent_background.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Loading…
Cancel
Save