From ada963198322026d313a8ba21bfef5576b7ffd7d Mon Sep 17 00:00:00 2001 From: Starryi Date: Fri, 23 Jul 2021 01:50:34 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-55491=20=E3=80=90=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E9=AA=8C=E6=94=B6=E3=80=91=E3=80=90=E7=BB=84=E4=BB=B6=E8=83=8C?= =?UTF-8?q?=E6=99=AF=E5=88=86=E7=A6=BB=E3=80=91=E5=9C=A8=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=E4=B8=8B=E7=9A=84=E3=80=8C=E4=B8=BB=E4=BD=93?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E3=80=8D=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E7=95=8C=E9=9D=A2=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=EF=BC=8C=E7=9C=8B=E4=B8=8D=E5=88=B0=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 1. 绘制图表块时,填充了白色背景,导致组件样式背景被覆盖 2. 图表进入编辑模式下,ChartComponent被绘制两次,差 了一个像素,又因为ChartComponent支持半透明,导致出现了 重影 【改动思路】 1. 表单布局面板上预览报表块时,不使用白色背景填充,保持透明 2. DesignerEditor绘制Editor时,补充下差了的一个 像素(默认灰色边框) --- .../java/com/fr/design/chart/gui/ChartComponent.java | 12 +++++++----- .../design/designer/beans/events/DesignerEditor.java | 2 +- .../com/fr/design/designer/creator/XChartEditor.java | 3 +++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java index 1a5088a272..1ce2fbffd9 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java @@ -43,6 +43,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene public ChartComponent() { super(); + setOpaque(true); addMouseListener(this); addMouseMotionListener(this); } @@ -148,11 +149,12 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene chartCollection4Design.setPredefinedStyleName(getGlobalPredefinedStyleName(), false); Graphics2D g2d = (Graphics2D) g; - Paint oldPaint = g2d.getPaint(); - - g2d.setPaint(Color.WHITE); - g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height); - g2d.setPaint(oldPaint); + if (this.isOpaque()) { + Paint oldPaint = g2d.getPaint(); + g2d.setPaint(Color.WHITE); + g2d.fillRect(0, 0, this.getBounds().width, this.getBounds().height); + g2d.setPaint(oldPaint); + } g2d.translate(ChartConstants.PREGAP4BOUNDS/2, ChartConstants.PREGAP4BOUNDS/2); diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java b/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java index f53f66d313..58f58c0758 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/events/DesignerEditor.java @@ -93,7 +93,7 @@ public class DesignerEditor implements PropertyChangeListe comp.setSize(new Dimension(width, height)); LayoutUtils.layoutContainer(comp); - comp.setBounds(comp.getX() + x, comp.getY() + y, width, height); + comp.setBounds(comp.getX() + x - 1, comp.getY() + y - 1, width, height); Graphics clipg = g.create(x, y, width, height); this.comp.paint(clipg); } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java index 8633c0bd51..ad328b85e7 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java @@ -231,7 +231,9 @@ public class XChartEditor extends XBorderStyleWidgetCreator { public void paintForeground(Graphics2D g) { Dimension size = getSize(); PaddingMargin margin = toData().getMargin(); + designerEditor.paintEditor(g, size, margin); + if (coverPanel != null) { int horizonMargin = margin != null ? margin.getLeft() + margin.getRight() : 0; int verticalMargin = margin != null ? margin.getTop() + margin.getBottom() : 0; @@ -289,6 +291,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection()); if (chartComponent != null) { JComponent jChart = chartComponent; + chartComponent.setOpaque(false); jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray)); designerEditor = new DesignerEditor(jChart); chartComponent.addStopEditingListener(designerEditor);