Browse Source

Pull request #5085: REPORT-55719 & REPORT-5573 & REPORT-55669

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

* commit '1141caecc2024ad931054833c66e48291661162a':
  REPORT-55669 【组件背景分离】组件复用-线型边框在设计画布里可以看到,标题和组件内容之间是有显示边框线的,但是预览时这里没有显示边框线,不符合所见即所得,这个看下预期是什么样
  REPORT-55719 【组件背景分离】组件复用-报表块在画布内显示问题 REPORT-55737 【组件背景分离】组件复用-主体背景遮挡边框
final/10.0
Kara 3 years ago
parent
commit
eaa96a435b
  1. 90
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java

90
designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java

@ -35,6 +35,9 @@ import java.awt.geom.RoundRectangle2D;
public class XBorderStyleWidgetCreator extends XWidgetCreator{ public class XBorderStyleWidgetCreator extends XWidgetCreator{
protected static final Dimension BORDER_PREFERRED_SIZE = new Dimension(250, 150); protected static final Dimension BORDER_PREFERRED_SIZE = new Dimension(250, 150);
protected Background background4Painting; // 设计器预览界面中绘制组件背景图 protected Background background4Painting; // 设计器预览界面中绘制组件背景图
protected double backgroundOpacity4Painting; // 设计器预览界面中绘制组件背景图
protected Background borderImage4Painting; // 设计器预览界面中绘制边框图片
protected double borderImageOpacity4Painting;
public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) { public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) {
super(widget, initSize); super(widget, initSize);
@ -54,6 +57,30 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
this.repaint(); this.repaint();
} }
public double getBackgroundOpacity4Painting() {
return backgroundOpacity4Painting;
}
public void setBackgroundOpacity4Painting(double backgroundOpacity4Painting) {
this.backgroundOpacity4Painting = backgroundOpacity4Painting;
}
public Background getBorderImage4Painting() {
return borderImage4Painting;
}
public void setBorderImage4Painting(Background borderImage4Painting) {
this.borderImage4Painting = borderImage4Painting;
}
public double getBorderImageOpacity4Painting() {
return borderImageOpacity4Painting;
}
public void setBorderImageOpacity4Painting(double borderImageOpacity4Painting) {
this.borderImageOpacity4Painting = borderImageOpacity4Painting;
}
/** /**
* 返回容器对应的widget * 返回容器对应的widget
* @return 同上 * @return 同上
@ -102,8 +129,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
} }
this.setBorder(border); this.setBorder(border);
this.setBorderImage4Painting(style != null ? style.getBorderImage() : null);
this.setBorderImageOpacity4Painting(style != null ? style.getBorderImageOpacity() : 0.0);
this.setBackground4Painting(style != null ? style.getBackground() : null); this.setBackground4Painting(style != null ? style.getBackground() : null);
this.setBackgroundOpacity4Painting(style != null ? style.getAlpha() : 0.0);
} }
private void clearTitleWidget() { private void clearTitleWidget() {
@ -194,14 +224,27 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
titleCreator.setBorder(new BottomLineBorder(color, thickness)); titleCreator.setBorder(new BottomLineBorder(color, thickness));
} }
// 主体背景的生效范围暂时保持原样,不作用于包含标题区域的整体范围内 if (bodyXCreator instanceof XBorderStyleWidgetCreator) {
// if (bodyXCreator instanceof XBorderStyleWidgetCreator) { XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator;
// XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator; Background borderImage4Painting = styledBodyXCreator.getBorderImage4Painting();
// Background background4Painting = styledBodyXCreator.getBackground4Painting(); double opacity = styledBodyXCreator.getBorderImageOpacity4Painting();
//
// styledBodyXCreator.setBackground4Painting(null); // body不绘制背景 styledBodyXCreator.setBorderImage4Painting(null); // body不绘制图片边框
// titleParent.setBackground4Painting(background4Painting); // 容器绘制完整背景 styledBodyXCreator.setBorderImageOpacity4Painting(0.0);
// } titleParent.setBorderImage4Painting(borderImage4Painting); // 容器绘制完整图片边框
titleParent.setBorderImageOpacity4Painting(opacity);
}
if (bodyXCreator instanceof XBorderStyleWidgetCreator) {
XBorderStyleWidgetCreator styledBodyXCreator = (XBorderStyleWidgetCreator) bodyXCreator;
Background background4Painting = styledBodyXCreator.getBackground4Painting();
double opacity = styledBodyXCreator.getBackgroundOpacity4Painting();
styledBodyXCreator.setBackground4Painting(null); // body不绘制背景
styledBodyXCreator.setBackgroundOpacity4Painting(0.0);
titleParent.setBackground4Painting(background4Painting); // 容器绘制完整背景
titleParent.setBackgroundOpacity4Painting(opacity);
}
} }
} }
} }
@ -226,10 +269,32 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public void paintBackground(Graphics2D g2d) { public void paintBackground(Graphics2D g2d) {
Background background4Painting = getBackground4Painting(); Background background4Painting = getBackground4Painting();
if (background4Painting != null) { if (background4Painting != null) {
BorderPacker style = toData().getBorderStyle();
Composite oldComposite = g2d.getComposite(); Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, style.getAlpha())); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) backgroundOpacity4Painting));
background4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
Shape shape = new Rectangle2D.Double(0, 0, getWidth(), getHeight());
if (this instanceof XWTitleLayout) {
// 兼容性考虑,组件样式背景不作用在标题范围内,只作用在控件整体,但同时不能遮挡作用于整体的边框图片
// 所以考虑样式背景与边框图片都由XWTitleLayout绘制,但样式背景要向下偏移标题栏的高度
XWTitleLayout titleParent = (XWTitleLayout) this;
if (getComponentCount() > 1) {
XCreator titleCreator = titleParent.getTitleCreator();
int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0;
shape = new Rectangle2D.Double(0, titleHeight, getWidth(), getHeight() - titleHeight);
}
}
background4Painting.paint(g2d, shape);
g2d.setComposite(oldComposite);
}
}
public void paintBorderImage(Graphics2D g2d) {
Background borderImage4Painting = getBorderImage4Painting();
if (borderImage4Painting != null) {
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) borderImageOpacity4Painting));
borderImage4Painting.paint(g2d, new Rectangle2D.Double(0, 0, getWidth(), getHeight()));
g2d.setComposite(oldComposite); g2d.setComposite(oldComposite);
} }
} }
@ -243,6 +308,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public void paint(Graphics g) { public void paint(Graphics g) {
this.clipByRoundedBorder((Graphics2D) g); this.clipByRoundedBorder((Graphics2D) g);
this.paintBackground((Graphics2D) g); this.paintBackground((Graphics2D) g);
this.paintBorderImage((Graphics2D) g);
this.paintForeground((Graphics2D) g); this.paintForeground((Graphics2D) g);
} }
@ -293,7 +359,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(getLineColor()); g2d.setColor(getLineColor());
g2d.setStroke(new BasicStroke(getThickness())); g2d.setStroke(new BasicStroke(getThickness() * 2));
g2d.drawLine(0, height, width, height); g2d.drawLine(0, height, width, height);
g2d.setStroke(oldStroke); g2d.setStroke(oldStroke);

Loading…
Cancel
Save