Browse Source

REPORT-65060 【视觉验收】模板主题管理

【问题原因】
替换下表示透明的马赛克图片,之前给的图片里格子太大了

【改动思路】
同上
bugfix/11.0
Starryi 3 years ago
parent
commit
3712ef8a1a
  1. 2
      designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java
  2. 53
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  3. BIN
      designer-base/src/main/resources/com/fr/design/images/transparent_background.png
  4. 2
      designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

2
designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java

@ -46,7 +46,7 @@ public class CellRectangleStylePreviewPane extends JPanel {
for (int r = 0; r < ROW_COUNT; r++) {
for (int c = 0; c < COLUMN_COUNT; c++) {
CellStylePreviewPane pane = new CellStylePreviewPane(false);
CellStylePreviewPane pane = new CellStylePreviewPane(false, false);
TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r);
int flags = CellBorderSourceFlag.INVALID_BORDER_SOURCE;
if (supportInnerBorder) {

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

@ -30,13 +30,20 @@ import java.util.List;
public class CellStylePreviewPane extends JPanel {
public static final int MINIMUM_HEIGHT = 40;
private static final BufferedImage transparentBackgroundImage = IOUtils.readImage("/com/fr/design/images/transparent_background.png");
private final float transparentBackgroundWidth;
private final float transparentBackgroundHeight;
private String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
private final boolean autoClearCanvas;
private final boolean paintingMosaic;
public CellStylePreviewPane(boolean autoClearCanvas) {
public CellStylePreviewPane(boolean autoClearCanvas, boolean paintingMosaic) {
this.autoClearCanvas = autoClearCanvas;
this.paintingMosaic = paintingMosaic;
transparentBackgroundWidth = transparentBackgroundImage.getWidth(null);
transparentBackgroundHeight = transparentBackgroundImage.getHeight(null);
setPreferredSize(new Dimension(0, 0));
}
@ -64,12 +71,52 @@ public class CellStylePreviewPane extends JPanel {
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
if (paintingMosaic) {
paintTransparentBackground(g2d, style);
}
paintCellStyle(g2d, style);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
}
private void paintTransparentBackground(Graphics2D g2d, Style style) {
float alpha = computeTransparentBackgroundAlpha(style);
float scaleWidth = 1.0F * getWidth() / transparentBackgroundWidth;
float scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight;
float maxScale = Math.max(scaleWidth, scaleHeight);
if (maxScale <= 1) {
scaleWidth = scaleHeight = 1;
} 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 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();
@ -86,9 +133,7 @@ public class CellStylePreviewPane extends JPanel {
Style.paintContent(g2d, paintText, style, width, height, resolution);
Style.paintBorder(g2d, style,
width - GraphHelper.getLineStyleSize(style.getBorderRight()) / 2F,
height - GraphHelper.getLineStyleSize(style.getBorderBottom()) / 2F);
Style.paintBorder(g2d, style, width, height);
}
@Override

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 26 KiB

2
designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

@ -79,7 +79,7 @@ public class ReportStylePane extends BasicPane {
setLayout(FRGUIPaneFactory.createBorderLayout());
setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
previewArea = new CellStylePreviewPane(true);
previewArea = new CellStylePreviewPane(true, true);
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
customStylePane = new CustomFloatStyleSettingPane();

Loading…
Cancel
Save