diff --git a/designer-base/src/main/java/com/fr/design/report/WatermarkPreviewPane.java b/designer-base/src/main/java/com/fr/design/report/WatermarkPreviewPane.java index 3c2d207042..8e9eb853e7 100644 --- a/designer-base/src/main/java/com/fr/design/report/WatermarkPreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/report/WatermarkPreviewPane.java @@ -32,6 +32,7 @@ public class WatermarkPreviewPane extends JPanel { super.paint(g); Graphics2D g2d = (Graphics2D)g; g2d.drawImage(UIConstants.WATERMARK_BACKGROUND, 0, 0, this.getWidth(), this.getHeight(), null); - new WatermarkPainter(watermark).paint(g2d, this.getWidth(), this.getHeight()); + WatermarkPainter painter = WatermarkPainter.createPainter(watermark); + painter.paint(g2d, this.getWidth(), this.getHeight()); } } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index 959644ec82..5cc2ead917 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -1,18 +1,5 @@ package com.fr.design.mainframe; -import java.awt.AlphaComposite; -import java.awt.Component; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.Rectangle; -import java.awt.geom.Area; -import java.awt.geom.Rectangle2D; -import java.util.ArrayList; - -import javax.swing.JComponent; -import javax.swing.SwingUtilities; -import javax.swing.plaf.ComponentUI; - import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.base.ScreenResolution; @@ -30,12 +17,23 @@ import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.form.util.XCreatorConstants; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.utils.ComponentUtils; -import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.page.WatermarkPainter; import com.fr.report.core.ReportUtils; import com.fr.stable.ArrayUtils; +import javax.swing.JComponent; +import javax.swing.SwingUtilities; +import javax.swing.plaf.ComponentUI; +import java.awt.AlphaComposite; +import java.awt.Component; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.geom.Area; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; + /** * FormDesigner的UI类,是一个有状态的UI类,它根据FormDesigner的当前状态画出 * 具有所见即所得的设计界面,以及当前设计界面的一些辅助状态,比如选择标识、拖动区域 以及当前正在添加的组件 @@ -46,7 +44,6 @@ public class FormDesignerUI extends ComponentUI { private FormDesigner designer; private SelectionModel selectionModel; private Rectangle2D.Double back_or_selection_rect = new Rectangle2D.Double(0, 0, 0, 0); - private WatermarkPainter watermarkPainter; private float time; public FormDesignerUI() { @@ -119,11 +116,8 @@ public class FormDesignerUI extends ComponentUI { // 绘制水印 private void paintWatermark(Graphics2D g) { WatermarkAttr watermark = ReportUtils.getWatermarkFromAttrMarkFile(designer.getTarget()); - // 不要每次都 new 一个 WatermarkPainter - if (watermarkPainter == null || !ComparatorUtils.equals(watermarkPainter.getWatermark(), watermark)) { - watermarkPainter = new WatermarkPainter(watermark); - } - watermarkPainter.paint(g, 0, designer.getParaHeight(), designer.getArea().getBounds()); + WatermarkPainter painter = WatermarkPainter.createPainter(watermark, designer.getResolution()); + painter.paint(g, 0, designer.getParaHeight(), designer.getArea().getBounds()); } private int[] getActualLine(int i) { diff --git a/designer-realize/src/main/java/com/fr/grid/GridUI.java b/designer-realize/src/main/java/com/fr/grid/GridUI.java index 8577212dc8..45d8143c8d 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -48,9 +48,20 @@ import com.fr.stable.script.CalculatorUtils; import com.fr.stable.unit.FU; import com.fr.third.antlr.ANTLRException; -import javax.swing.*; +import javax.swing.JComponent; +import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; -import java.awt.*; +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.Stroke; import java.awt.geom.Area; import java.awt.geom.GeneralPath; import java.awt.geom.Line2D; @@ -98,7 +109,6 @@ public class GridUI extends ComponentUI { protected int resolution; private boolean isAuthority = false; - private WatermarkPainter watermarkPainter; public GridUI(int resolution) { super(); @@ -1104,12 +1114,8 @@ public class GridUI extends ComponentUI { // 绘制水印 private void paintWatermark(Graphics2D g2d, FineBook book) { WatermarkAttr watermark = ReportUtils.getWatermarkFromAttrMarkFile(book); - - // 不要每次都 new 一个 WatermarkPainter - if (watermarkPainter == null || !ComparatorUtils.equals(watermarkPainter.getWatermark(), watermark)) { - watermarkPainter = new WatermarkPainter(watermark); - } - watermarkPainter.paint(g2d, gridSize.width, gridSize.height); + WatermarkPainter painter = WatermarkPainter.createPainter(watermark, resolution); + painter.paint(g2d, gridSize.width, gridSize.height); } diff --git a/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java b/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java index 7b98269ea2..ba6f79e713 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java @@ -10,7 +10,6 @@ import com.fr.base.ScreenResolution; import com.fr.base.iofile.attr.WatermarkAttr; import com.fr.design.utils.ComponentUtils; import com.fr.general.Background; -import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.main.FineBook; import com.fr.page.PaperSettingProvider; @@ -56,7 +55,6 @@ public class PolyDesignUI extends ComponentUI { private PolyDesigner designer; private int resolution; private float time; - private WatermarkPainter watermarkPainter; public PolyDesignUI(int resolution) { if (resolution == 0){ @@ -112,12 +110,8 @@ public class PolyDesignUI extends ComponentUI { // 绘制水印 private void paintWatermark(Graphics2D g2d, FineBook book, int width, int height) { WatermarkAttr watermark = ReportUtils.getWatermarkFromAttrMarkFile(book); - - // 不要每次都 new 一个 WatermarkPainter - if (watermarkPainter == null || !ComparatorUtils.equals(watermarkPainter.getWatermark(), watermark)) { - watermarkPainter = new WatermarkPainter(watermark); - } - watermarkPainter.paint(g2d, width, height); + WatermarkPainter painter = WatermarkPainter.createPainter(watermark, resolution); + painter.paint(g2d, width, height); } private void paintAddedData(Graphics g) {