From ed43a05a674c99165e460fee8b52178ffcd660b6 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 28 Dec 2021 11:54:03 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-65049=20=E3=80=90=E4=B8=BB=E9=A2=98?= =?UTF-8?q?=E8=BE=B9=E6=A1=86=E3=80=91=E6=82=AC=E6=B5=AE=E5=85=83=E7=B4=A0?= =?UTF-8?q?=E7=9A=84=E8=B7=9F=E9=9A=8F=E4=B8=BB=E9=A2=98=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=A0=BC=E6=A0=B7=E5=BC=8F=E6=98=BE=E7=A4=BA=EF=BC=8C=E5=87=BA?= =?UTF-8?q?=E7=8E=B0=E4=B8=A4=E7=A7=8D=E6=A0=B7=E5=BC=8F=E9=87=8D=E5=8F=A0?= =?UTF-8?q?=E7=9A=84=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 单独使用CellStylePreviewPane单元格样式预览面板时,需要CellStylePreviewPane在样式切换 时清理画布并重绘 2. 在CellRectangleStylePreviewPane使用CellStylePreviewPane时,也需要清理画布并重绘, 但此时的清理是CellRectangleStylePreviewPane完成。CellStylePreviewPane不清理画布,否则会 导致表示透明的马赛克图片不显示. 【改动思路】 CellStylePreviewPane增加一个是否自动清理画布的控制变量 --- .../com/fr/design/cell/CellRectangleStylePreviewPane.java | 2 +- .../java/com/fr/design/cell/CellStylePreviewPane.java | 8 +++++++- .../main/java/com/fr/design/report/ReportStylePane.java | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java b/designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java index 015fecee9d..d278d130f8 100644 --- a/designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java +++ b/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(); + CellStylePreviewPane pane = new CellStylePreviewPane(false); TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r); int flags = CellBorderSourceFlag.INVALID_BORDER_SOURCE; if (supportInnerBorder) { 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 b7e43c38cd..66a873d4d1 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 @@ -33,7 +33,10 @@ public class CellStylePreviewPane extends JPanel { private String paintText = "Report"; private Style style = Style.DEFAULT_STYLE; - public CellStylePreviewPane() { + private final boolean autoClearCanvas; + + public CellStylePreviewPane(boolean autoClearCanvas) { + this.autoClearCanvas = autoClearCanvas; setPreferredSize(new Dimension(0, 0)); } @@ -55,6 +58,9 @@ public class CellStylePreviewPane extends JPanel { @Override public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; + if (autoClearCanvas) { + g2d.clearRect(0, 0, getWidth(), getHeight()); + } g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON); diff --git a/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java b/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java index 250861dbef..a5295ad7ec 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java @@ -53,6 +53,7 @@ import java.awt.CardLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; +import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.ArrayList; @@ -78,7 +79,7 @@ public class ReportStylePane extends BasicPane { setLayout(FRGUIPaneFactory.createBorderLayout()); setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10)); - previewArea = new CellStylePreviewPane(); + previewArea = new CellStylePreviewPane(true); followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS); followingThemeButtonGroup.setAutoFireStateChanged(false); customStylePane = new CustomFloatStyleSettingPane();