Browse Source

REPORT-57551 设计器显示,自适应布局下body背景设置以后,画布中没有实时显示背景

【问题原因】
Body Creator的swing Background遮挡了样式背景导致.
需要将swing背景的绘制放置到样式背景的下方, 避免遮挡样式背景

【改动思路】
同标题
research/11.0
Starryi 3 years ago
parent
commit
489fec327b
  1. 26
      designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java

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

@ -21,6 +21,8 @@ import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
import javax.swing.plaf.PanelUI;
import javax.swing.plaf.basic.BasicPanelUI;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
@ -42,6 +44,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) {
super(widget, initSize);
setUI(new NoBackgroundPaneUI());
setOpaque(false);
setBackupBound(null);
@ -51,6 +54,13 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
}
}
@Override
public void setUI(PanelUI ui) {
if (ui instanceof NoBackgroundPaneUI) {
super.setUI(ui);
}
}
public Background getBackground4Painting() {
return this.background4Painting;
}
@ -288,6 +298,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
// 设计器预览界面中绘制组件背景效果
public void paintBackground(Graphics2D g2d) {
if (isOpaque()) {
g2d.setColor(getBackground());
g2d.fillRect(0, 0, getWidth(), getHeight());
}
Background background4Painting = getBackground4Painting();
if (background4Painting != null) {
Composite oldComposite = g2d.getComposite();
@ -311,12 +326,12 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
}
public void paintForeground(Graphics2D g2d) {
super.paint(g2d);
super.paintComponent(g2d);
super.paintBorder(g2d);
}
@Override
public void paint(Graphics g) {
public void paintComponent(Graphics g) {
this.clipByRoundedBorder((Graphics2D) g);
this.paintBackground((Graphics2D) g);
this.paintBorderImage((Graphics2D) g);
@ -378,4 +393,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
}
}
public static class NoBackgroundPaneUI extends BasicPanelUI {
@Override
public void update(Graphics g, JComponent c) {
paint(g, c);
}
}
}
Loading…
Cancel
Save