|
|
|
@ -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,12 +44,23 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
|
|
|
|
|
public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) { |
|
|
|
|
super(widget, initSize); |
|
|
|
|
|
|
|
|
|
setUI(new NoBackgroundPaneUI()); |
|
|
|
|
setOpaque(false); |
|
|
|
|
setBackupBound(null); |
|
|
|
|
|
|
|
|
|
ExtendSharableAttrMark sharableAttrMark = this.toData().getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG); |
|
|
|
|
if (sharableAttrMark != null) { |
|
|
|
|
this.setShareId(sharableAttrMark.getShareId()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setUI(PanelUI ui) { |
|
|
|
|
if (ui instanceof NoBackgroundPaneUI) { |
|
|
|
|
super.setUI(ui); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public Background getBackground4Painting() { |
|
|
|
|
return this.background4Painting; |
|
|
|
|
} |
|
|
|
@ -263,6 +276,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setBackground(Color bg) { |
|
|
|
|
super.setBackground(bg); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 根据当前组件边框裁剪内容,如果当前组件存在圆角,则应当按圆角裁剪内容
|
|
|
|
|
private void clipByRoundedBorder(Graphics2D g2d) { |
|
|
|
|
Border currentBorder = getBorder(); |
|
|
|
@ -280,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(); |
|
|
|
@ -303,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); |
|
|
|
@ -370,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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |