Browse Source

REPORT-8947 调整水印代码

master
plough 7 years ago
parent
commit
d5a2c7b505
  1. 3
      designer-base/src/main/java/com/fr/design/report/WatermarkPreviewPane.java
  2. 33
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java
  3. 23
      designer-realize/src/main/java/com/fr/grid/GridUI.java
  4. 9
      designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java

3
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());
}
}

33
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的当前状态画出
* 具有所见即所得的设计界面以及当前设计界面的一些辅助状态比如选择标识拖动区域 以及当前正在添加的组件
@ -119,11 +117,8 @@ public class FormDesignerUI extends ComponentUI {
// 绘制水印
private void paintWatermark(Graphics2D g) {
WatermarkAttr watermark = ReportUtils.getWatermarkFromAttrMarkFile(designer.getTarget());
// 不要每次都 new 一个 WatermarkPainter
if (watermarkPainter == null || watermarkPainter.isOutDated(watermark, designer.getResolution())) {
watermarkPainter = new WatermarkPainter(watermark, designer.getResolution());
}
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) {

23
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;
@ -1104,12 +1115,8 @@ public class GridUI extends ComponentUI {
// 绘制水印
private void paintWatermark(Graphics2D g2d, FineBook book) {
WatermarkAttr watermark = ReportUtils.getWatermarkFromAttrMarkFile(book);
// 不要每次都 new 一个 WatermarkPainter
if (watermarkPainter == null || watermarkPainter.isOutDated(watermark, resolution)) {
watermarkPainter = new WatermarkPainter(watermark, resolution);
}
watermarkPainter.paint(g2d, gridSize.width, gridSize.height);
WatermarkPainter painter = WatermarkPainter.createPainter(watermark, resolution);
painter.paint(g2d, gridSize.width, gridSize.height);
}

9
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;
@ -112,12 +111,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 || watermarkPainter.isOutDated(watermark, resolution)) {
watermarkPainter = new WatermarkPainter(watermark, resolution);
}
watermarkPainter.paint(g2d, width, height);
WatermarkPainter painter = WatermarkPainter.createPainter(watermark, resolution);
painter.paint(g2d, width, height);
}
private void paintAddedData(Graphics g) {

Loading…
Cancel
Save