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