Browse Source

Pull request #5072: REPORT-55491 & REPORT-55672

Merge in DESIGN/design from ~STARRYI/design:bug-final/10.0 to final/10.0

* commit '907cca3f83130780511bdb731c89592097a51a52':
  REPORT-55672 悬浮元素-新建模板第一次添加的悬浮元素不能移动位置
  REPORT-55491 【交互验收】【组件背景分离】在组件属性下的「主体背景」设置,在配置界面不生效,看不到效果
final/10.0
Kara 3 years ago
parent
commit
f82dd6f815
  1. 8
      designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java
  2. 26
      designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java
  3. 11
      designer-realize/src/main/java/com/fr/grid/Grid.java
  4. 18
      designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java
  5. 6
      designer-realize/src/main/java/com/fr/grid/GridUI.java

8
designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java

@ -41,7 +41,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
static {
try {
DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase.png");
DEFAULT_BACKGROUND = BaseUtils.readImageWithCache("com/fr/base/images/report/elementcase_translucent.png");
} catch (Throwable e) {
//IBM jdk 1.5.0_22 并发下读取图片有时会异常(EOFException), 这个图片反正只有设计器用到, 捕获住
DEFAULT_BACKGROUND = CoreGraphHelper.createBufferedImage(0, 0);
@ -183,7 +183,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
if (editor == null) {
setBorder(DEFALUTBORDER);
editor = new JPanel();
editor.setBackground(null);
editor.setOpaque(false);
editor.setBackground(new Color(0, 0, 0, 0));
editor.setLayout(null);
imageLable = initImageBackground();
@ -218,7 +219,8 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme
private void setLabelBackground(Image image, UILabel imageLable) {
ImageIcon icon = new ImageIcon(image);
imageLable.setIcon(icon);
imageLable.setOpaque(true);
imageLable.setOpaque(false);
imageLable.setBackground(new Color(0, 0, 0, 0));
imageLable.setLayout(null);
imageLable.setBounds(0, 0, icon.getIconWidth(), icon.getIconHeight());
}

26
designer-realize/src/main/java/com/fr/design/mainframe/form/FormElementCaseDesigner.java

@ -43,9 +43,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;
/**
@ -129,19 +129,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();
int width = size.width;
int height = size.height;
//填充白色背景, 不然有黑框
Color oldColor = g.getColor();
g.setColor(Color.WHITE);
g.fillRect(0, 0, size.width, size.height);
g.setColor(oldColor);
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) {

11
designer-realize/src/main/java/com/fr/grid/Grid.java

@ -134,6 +134,9 @@ public class Grid extends BaseGridComponent {
private boolean needRequestFocus = true;
// 截取缩略图时需透明(不能用默认白色填充),否则会遮挡组件样式的背景,其余情况的绘制可以用白色等默认颜色填充
private boolean isTranslucent = false;
public Grid(int resolution) {
this.resolution = resolution;
// 能触发processEvent,不管是否给component增加listener
@ -1458,4 +1461,12 @@ public class Grid extends BaseGridComponent {
this.paginateLineShowType = paginateLineShowType;
this.getElementCasePane().repaint();
}
public boolean isTranslucent() {
return isTranslucent;
}
public void setTranslucent(boolean translucent) {
isTranslucent = translucent;
}
}

18
designer-realize/src/main/java/com/fr/grid/GridMouseAdapter.java

@ -408,11 +408,11 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
int currentWidth = currentRight - currentLeft;
int currentHeight = currentBottom - currentTop;
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
if (cursorType == Cursor.NW_RESIZE_CURSOR || cursorType == Cursor.NE_RESIZE_CURSOR || cursorType == Cursor.SE_RESIZE_CURSOR || cursorType == Cursor.SW_RESIZE_CURSOR) {
if (aspectRatio) {
if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
double currentDiagonal = Math.pow(currentWidth, 2) + Math.pow(currentHeight, 2);
double backupDiagonal = Math.pow(backupWidth, 2) + Math.pow(backupHeight, 2);
@ -452,7 +452,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
floatElement.setTopDistance(topDistance);
floatElement.setHeight(FU.valueOfPix(currentBottom, resolution).subtract(floatY1_fu));
if (aspectRatio) {
if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
currentWidth = backupWidth * currentHeight / backupHeight;
currentRight = currentLeft + currentWidth;
FU floatX1_fu = FU.valueOfPix(currentLeft, resolution);
@ -465,7 +468,10 @@ public class GridMouseAdapter implements MouseListener, MouseWheelListener, Mous
floatElement.setLeftDistance(leftDistance);
floatElement.setWidth(FU.valueOfPix(currentRight, resolution).subtract(floatX1_fu));
if (aspectRatio) {
if (aspectRatio && resizingBackupBounds != null) {
int backupWidth= resizingBackupBounds[2];
int backupHeight= resizingBackupBounds[3];
currentHeight = backupHeight * currentWidth / backupWidth;
currentBottom = currentTop + currentHeight;
FU floatY1_fu = FU.valueOfPix(currentTop, resolution);

6
designer-realize/src/main/java/com/fr/grid/GridUI.java

@ -1128,8 +1128,10 @@ public class GridUI extends ComponentUI {
double realWidth = gridSize.getWidth();// 宽度
double realHeight = gridSize.getHeight();// 高度
// 画背景
this.paintBackground(g2d, grid, elementCase, resolution);
if (!grid.isTranslucent()) {
// 画背景
this.paintBackground(g2d, grid, elementCase, resolution);
}
// 画Grid Line
this.paintGridLine(g2d, grid, elementCase, realWidth, realHeight, resolution);

Loading…
Cancel
Save