|
|
|
@ -39,14 +39,17 @@ import com.fr.report.elementcase.TemplateElementCase;
|
|
|
|
|
import com.fr.report.worksheet.FormElementCase; |
|
|
|
|
import com.fr.report.worksheet.WorkSheet; |
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO; |
|
|
|
|
import javax.swing.JComponent; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.JScrollBar; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Color; |
|
|
|
|
import java.awt.Dimension; |
|
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
import java.awt.Transparency; |
|
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 表单中的ElementCase编辑面板 |
|
|
|
@ -132,13 +135,22 @@ public class FormElementCaseDesigner
|
|
|
|
|
int width = size.width; |
|
|
|
|
int height = size.height; |
|
|
|
|
|
|
|
|
|
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); |
|
|
|
|
// 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image,
|
|
|
|
|
// 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0)
|
|
|
|
|
// 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图
|
|
|
|
|
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); |
|
|
|
|
Graphics2D g2d = image.createGraphics(); |
|
|
|
|
// 创建一个支持透明背景的buffer image
|
|
|
|
|
image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); |
|
|
|
|
g2d.dispose(); |
|
|
|
|
g2d = image.createGraphics(); |
|
|
|
|
|
|
|
|
|
// 使用TYPE_INT_RGB和new Color(255, 255, 255, 1)设置有透明背景buffer image,
|
|
|
|
|
// 使得创建出来的透明像素是(255, 255, 255, 1),而不是(0, 0, 0, 0)
|
|
|
|
|
// 这样不支持透明通道缩略图的旧设计器打开新设计器创建的模版时,就不会创建出拥有黑色背景的缩略图
|
|
|
|
|
g2d.setColor(new Color(255, 255, 255, 1)); |
|
|
|
|
g2d.fillRect(0, 0, (int) size.getWidth(), (int) size.getHeight()); |
|
|
|
|
|
|
|
|
|
Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; |
|
|
|
|
if (grid != null) { |
|
|
|
|
boolean oldTranslucent = grid.isTranslucent(); |
|
|
|
@ -148,6 +160,8 @@ public class FormElementCaseDesigner
|
|
|
|
|
grid.setTranslucent(oldTranslucent); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ImageIO.write(image, "png", new File("/Users/Starryi/test.png")); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|