|
|
@ -43,9 +43,9 @@ import javax.swing.JComponent; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JScrollBar; |
|
|
|
import javax.swing.JScrollBar; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.Color; |
|
|
|
|
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Graphics; |
|
|
|
import java.awt.Graphics2D; |
|
|
|
|
|
|
|
import java.awt.Transparency; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
import java.awt.image.BufferedImage; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -129,19 +129,23 @@ public class FormElementCaseDesigner |
|
|
|
public BufferedImage getElementCaseImage(Dimension size) { |
|
|
|
public BufferedImage getElementCaseImage(Dimension size) { |
|
|
|
BufferedImage image = null; |
|
|
|
BufferedImage image = null; |
|
|
|
try { |
|
|
|
try { |
|
|
|
image = new java.awt.image.BufferedImage(size.width, size.height, |
|
|
|
int width = size.width; |
|
|
|
java.awt.image.BufferedImage.TYPE_INT_RGB); |
|
|
|
int height = size.height; |
|
|
|
Graphics g = image.getGraphics(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//填充白色背景, 不然有黑框
|
|
|
|
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); |
|
|
|
Color oldColor = g.getColor(); |
|
|
|
Graphics2D g2d = image.createGraphics(); |
|
|
|
g.setColor(Color.WHITE); |
|
|
|
// 创建一个支持透明背景的buffer image
|
|
|
|
g.fillRect(0, 0, size.width, size.height); |
|
|
|
image = g2d.getDeviceConfiguration().createCompatibleImage(width, height, Transparency.TRANSLUCENT); |
|
|
|
g.setColor(oldColor); |
|
|
|
g2d.dispose(); |
|
|
|
|
|
|
|
g2d = image.createGraphics(); |
|
|
|
|
|
|
|
|
|
|
|
Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; |
|
|
|
Grid grid = this.elementCasePane != null ? this.elementCasePane.getGrid() : null; |
|
|
|
if (grid != null) { |
|
|
|
if (grid != null) { |
|
|
|
grid.paintAll(g); |
|
|
|
boolean oldTranslucent = grid.isTranslucent(); |
|
|
|
|
|
|
|
// 截缩图图时grid需支持半透明,不能用默认白色填充画布,否则会遮挡组件样式背景
|
|
|
|
|
|
|
|
grid.setTranslucent(true); |
|
|
|
|
|
|
|
grid.paint(g2d); |
|
|
|
|
|
|
|
grid.setTranslucent(oldTranslucent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|