|
|
@ -34,322 +34,335 @@ import com.fr.general.Inter; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class XWAbsoluteLayout extends XLayoutContainer { |
|
|
|
public class XWAbsoluteLayout extends XLayoutContainer { |
|
|
|
|
|
|
|
|
|
|
|
private static final int EDIT_BTN_WIDTH = 60; |
|
|
|
private static final int EDIT_BTN_WIDTH = 60; |
|
|
|
private static final int EDIT_BTN_HEIGHT = 24; |
|
|
|
private static final int EDIT_BTN_HEIGHT = 24; |
|
|
|
private int minWidth = WLayout.MIN_WIDTH; |
|
|
|
private int minWidth = WLayout.MIN_WIDTH; |
|
|
|
private int minHeight = WLayout.MIN_HEIGHT; |
|
|
|
private int minHeight = WLayout.MIN_HEIGHT; |
|
|
|
|
|
|
|
|
|
|
|
//由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算
|
|
|
|
//由于屏幕分辨率不同,界面上的容器大小可能不是默认的100%,此时拖入组件时,保存的大小按照100%时的计算
|
|
|
|
protected double containerPercent = 1.0; |
|
|
|
protected double containerPercent = 1.0; |
|
|
|
|
|
|
|
|
|
|
|
private HashMap<Connector,XConnector> xConnectorMap; |
|
|
|
private HashMap<Connector, XConnector> xConnectorMap; |
|
|
|
|
|
|
|
|
|
|
|
public XWAbsoluteLayout() { |
|
|
|
public XWAbsoluteLayout() { |
|
|
|
this(new WAbsoluteLayout(),new Dimension()); |
|
|
|
this(new WAbsoluteLayout(), new Dimension()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public XWAbsoluteLayout(WAbsoluteLayout widget) { |
|
|
|
public XWAbsoluteLayout(WAbsoluteLayout widget) { |
|
|
|
this(widget,new Dimension()); |
|
|
|
this(widget, new Dimension()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public XWAbsoluteLayout(WAbsoluteLayout widget, Dimension initSize) { |
|
|
|
public XWAbsoluteLayout(WAbsoluteLayout widget, Dimension initSize) { |
|
|
|
super(widget, initSize); |
|
|
|
super(widget, initSize); |
|
|
|
this.xConnectorMap = new HashMap<Connector,XConnector>(); |
|
|
|
this.xConnectorMap = new HashMap<Connector, XConnector>(); |
|
|
|
Connector connector; |
|
|
|
Connector connector; |
|
|
|
for (int i = 0; i < widget.connectorCount(); i++) { |
|
|
|
for (int i = 0; i < widget.connectorCount(); i++) { |
|
|
|
connector = widget.getConnectorIndex(i); |
|
|
|
connector = widget.getConnectorIndex(i); |
|
|
|
xConnectorMap.put(connector, new XConnector(connector, this)); |
|
|
|
xConnectorMap.put(connector, new XConnector(connector, this)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
initPercent(widget); |
|
|
|
initPercent(widget); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 初始化时默认的组件大小 |
|
|
|
* 初始化时默认的组件大小 |
|
|
|
* |
|
|
|
* |
|
|
|
* @return 默认Dimension |
|
|
|
* @return 默认Dimension |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Dimension initEditorSize() { |
|
|
|
public Dimension initEditorSize() { |
|
|
|
return new Dimension(500, 300); |
|
|
|
return new Dimension(500, 300); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90%
|
|
|
|
//根据屏幕大小来确定显示的百分比, 1440*900默认100%, 1366*768缩放90%
|
|
|
|
private void initPercent(WAbsoluteLayout widget){ |
|
|
|
private void initPercent(WAbsoluteLayout widget) { |
|
|
|
Toolkit toolkit = Toolkit.getDefaultToolkit(); |
|
|
|
Toolkit toolkit = Toolkit.getDefaultToolkit(); |
|
|
|
Dimension scrnsize = toolkit.getScreenSize(); |
|
|
|
Dimension scrnsize = toolkit.getScreenSize(); |
|
|
|
double screenValue = FRScreen.getByDimension(scrnsize).getValue(); |
|
|
|
double screenValue = FRScreen.getByDimension(scrnsize).getValue(); |
|
|
|
if(screenValue != FormArea.DEFAULT_SLIDER){ |
|
|
|
if (screenValue != FormArea.DEFAULT_SLIDER) { |
|
|
|
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); |
|
|
|
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 返回容器大小的百分比 |
|
|
|
* 返回容器大小的百分比 |
|
|
|
* @return the containerPercent |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @return the containerPercent |
|
|
|
public double getContainerPercent() { |
|
|
|
*/ |
|
|
|
return containerPercent; |
|
|
|
public double getContainerPercent() { |
|
|
|
} |
|
|
|
return containerPercent; |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
|
|
|
|
* 设置容器大小的百分比 |
|
|
|
/** |
|
|
|
* @param containerPercent the containerPercent to set |
|
|
|
* 设置容器大小的百分比 |
|
|
|
*/ |
|
|
|
* |
|
|
|
public void setContainerPercent(double containerPercent) { |
|
|
|
* @param containerPercent the containerPercent to set |
|
|
|
this.containerPercent = containerPercent; |
|
|
|
*/ |
|
|
|
minWidth = (int) (XWAbsoluteLayout.MIN_WIDTH*containerPercent); |
|
|
|
public void setContainerPercent(double containerPercent) { |
|
|
|
minHeight = (int) (XWAbsoluteLayout.MIN_HEIGHT*containerPercent); |
|
|
|
this.containerPercent = containerPercent; |
|
|
|
} |
|
|
|
minWidth = (int) (XWAbsoluteLayout.MIN_WIDTH * containerPercent); |
|
|
|
|
|
|
|
minHeight = (int) (XWAbsoluteLayout.MIN_HEIGHT * containerPercent); |
|
|
|
/** |
|
|
|
} |
|
|
|
* 返回界面处根据百分比调整后的最小宽度 |
|
|
|
|
|
|
|
* @return 最小宽度 |
|
|
|
/** |
|
|
|
*/ |
|
|
|
* 返回界面处根据百分比调整后的最小宽度 |
|
|
|
public int getActualMinWidth() { |
|
|
|
* |
|
|
|
return this.minWidth; |
|
|
|
* @return 最小宽度 |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
public int getActualMinWidth() { |
|
|
|
/** |
|
|
|
return this.minWidth; |
|
|
|
* 返回界面处根据百分比调整后的最小高度 |
|
|
|
} |
|
|
|
* @return 最小高度 |
|
|
|
|
|
|
|
*/ |
|
|
|
/** |
|
|
|
public int getActualMinHeight() { |
|
|
|
* 返回界面处根据百分比调整后的最小高度 |
|
|
|
return this.minHeight; |
|
|
|
* |
|
|
|
} |
|
|
|
* @return 最小高度 |
|
|
|
|
|
|
|
*/ |
|
|
|
/** |
|
|
|
public int getActualMinHeight() { |
|
|
|
* 返回界面处根据百分比调整后的间隔大小(且为偶数) |
|
|
|
return this.minHeight; |
|
|
|
* @return 间隔 |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
public int getAcualInterval() { |
|
|
|
/** |
|
|
|
// adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数
|
|
|
|
* 返回界面处根据百分比调整后的间隔大小(且为偶数) |
|
|
|
int interval = (int) (toData().getCompInterval()*containerPercent); |
|
|
|
* |
|
|
|
int val = interval/2; |
|
|
|
* @return 间隔 |
|
|
|
return val*2; |
|
|
|
*/ |
|
|
|
} |
|
|
|
public int getAcualInterval() { |
|
|
|
|
|
|
|
// adapter那边交叉三等分、删除都要判断是否对齐,所以间隔转为偶数
|
|
|
|
/** |
|
|
|
int interval = (int) (toData().getCompInterval() * containerPercent); |
|
|
|
* 界面容器大小不是默认的时,处理控件的BoundsWidget,且避免出现空隙 |
|
|
|
int val = interval / 2; |
|
|
|
*/ |
|
|
|
return val * 2; |
|
|
|
private Rectangle dealWidgetBound(Rectangle rec) { |
|
|
|
} |
|
|
|
if (containerPercent == 1.0) { |
|
|
|
|
|
|
|
return rec; |
|
|
|
/** |
|
|
|
} |
|
|
|
* 界面容器大小不是默认的时,处理控件的BoundsWidget,且避免出现空隙 |
|
|
|
rec.x = (int) (rec.x/containerPercent); |
|
|
|
*/ |
|
|
|
rec.y = (int) (rec.y/containerPercent); |
|
|
|
private Rectangle dealWidgetBound(Rectangle rec) { |
|
|
|
rec.width = (int) (rec.width/containerPercent); |
|
|
|
if (containerPercent == 1.0) { |
|
|
|
rec.height = (int) (rec.height/containerPercent); |
|
|
|
return rec; |
|
|
|
return rec; |
|
|
|
} |
|
|
|
} |
|
|
|
rec.x = (int) (rec.x / containerPercent); |
|
|
|
|
|
|
|
rec.y = (int) (rec.y / containerPercent); |
|
|
|
/** |
|
|
|
rec.width = (int) (rec.width / containerPercent); |
|
|
|
* 新增删除拉伸后单个组件的BoundsWidget |
|
|
|
rec.height = (int) (rec.height / containerPercent); |
|
|
|
*/ |
|
|
|
return rec; |
|
|
|
public void updateBoundsWidget(XCreator xCreator) { |
|
|
|
} |
|
|
|
WAbsoluteLayout layout = this.toData(); |
|
|
|
|
|
|
|
if (xCreator.hasTitleStyle()) { |
|
|
|
/** |
|
|
|
xCreator = (XLayoutContainer)xCreator.getParent(); |
|
|
|
* 新增删除拉伸后单个组件的BoundsWidget |
|
|
|
} |
|
|
|
*/ |
|
|
|
if (xCreator.acceptType(XWAbsoluteLayout.class)){ |
|
|
|
public void updateBoundsWidget(XCreator xCreator) { |
|
|
|
((XWAbsoluteLayout) xCreator).updateBoundsWidget(); |
|
|
|
WAbsoluteLayout layout = this.toData(); |
|
|
|
} |
|
|
|
if (xCreator.hasTitleStyle()) { |
|
|
|
BoundsWidget boundsWidget = layout.getBoundsWidget(xCreator.toData()); |
|
|
|
xCreator = (XLayoutContainer) xCreator.getParent(); |
|
|
|
Rectangle rectangle = dealWidgetBound(xCreator.getBounds()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (xCreator.acceptType(XWAbsoluteLayout.class)) { |
|
|
|
|
|
|
|
((XWAbsoluteLayout) xCreator).updateBoundsWidget(); |
|
|
|
private Rectangle calculateBound(Rectangle rec, double pw, double ph){ |
|
|
|
} |
|
|
|
Rectangle calRec = new Rectangle(0,0,0,0); |
|
|
|
BoundsWidget boundsWidget = layout.getBoundsWidget(xCreator.toData()); |
|
|
|
calRec.x = (int)(rec.x / pw); |
|
|
|
Rectangle rectangle = dealWidgetBound(xCreator.getBounds()); |
|
|
|
calRec.y = (int)(rec.y / ph); |
|
|
|
} |
|
|
|
calRec.width = (int)(rec.width / pw); |
|
|
|
|
|
|
|
calRec.height = (int)(rec.height / ph); |
|
|
|
private Rectangle calculateBound(Rectangle rec, double pw, double ph) { |
|
|
|
return calRec; |
|
|
|
Rectangle calRec = new Rectangle(0, 0, 0, 0); |
|
|
|
} |
|
|
|
calRec.x = (int) (rec.x / pw); |
|
|
|
|
|
|
|
calRec.y = (int) (rec.y / ph); |
|
|
|
/** |
|
|
|
calRec.width = (int) (rec.width / pw); |
|
|
|
* 新增删除拉伸后每个组件的BoundsWidget |
|
|
|
calRec.height = (int) (rec.height / ph); |
|
|
|
*/ |
|
|
|
return calRec; |
|
|
|
public void updateBoundsWidget() { |
|
|
|
} |
|
|
|
WAbsoluteLayout layout = this.toData(); |
|
|
|
|
|
|
|
Rectangle backupBound = this.getBackupBound(); |
|
|
|
/** |
|
|
|
Rectangle currentBound = this.getBounds(); |
|
|
|
* 新增删除拉伸后每个组件的BoundsWidget |
|
|
|
if (backupBound != null && layout.getCompState() == WAbsoluteLayout.STATE_FIT) { |
|
|
|
*/ |
|
|
|
double percentW = ((double) backupBound.width / (double) currentBound.width); |
|
|
|
public void updateBoundsWidget() { |
|
|
|
double percentH = ((double) backupBound.height / (double) currentBound.height); |
|
|
|
WAbsoluteLayout layout = this.toData(); |
|
|
|
for (int index = 0, n = this.getComponentCount(); index < n; index++){ |
|
|
|
Rectangle backupBound = this.getBackupBound(); |
|
|
|
XCreator creator = (XCreator) this.getComponent(index); |
|
|
|
Rectangle currentBound = this.getBounds(); |
|
|
|
BoundsWidget wgt = layout.getBoundsWidget(creator.toData()); |
|
|
|
if (backupBound != null && layout.getCompState() == WAbsoluteLayout.STATE_FIT) { |
|
|
|
// 用当前的显示大小计算后调正具体位置
|
|
|
|
double percentW = ((double) backupBound.width / (double) currentBound.width); |
|
|
|
Rectangle wgtBound = creator.getBounds(); |
|
|
|
double percentH = ((double) backupBound.height / (double) currentBound.height); |
|
|
|
Rectangle rec = calculateBound(wgtBound, percentW, percentH); |
|
|
|
for (int index = 0, n = this.getComponentCount(); index < n; index++) { |
|
|
|
wgt.setBounds(rec); |
|
|
|
XCreator creator = (XCreator) this.getComponent(index); |
|
|
|
creator.setBounds(rec); |
|
|
|
BoundsWidget wgt = layout.getBoundsWidget(creator.toData()); |
|
|
|
//绝对布局嵌套,要更新内部的绝对布局
|
|
|
|
// 用当前的显示大小计算后调正具体位置
|
|
|
|
if (creator.acceptType(XWAbsoluteLayout.class)){ |
|
|
|
Rectangle wgtBound = creator.getBounds(); |
|
|
|
creator.setBackupBound(wgtBound); |
|
|
|
Rectangle rec = calculateBound(wgtBound, percentW, percentH); |
|
|
|
((XWAbsoluteLayout) creator).updateBoundsWidget(); |
|
|
|
wgt.setBounds(rec); |
|
|
|
} |
|
|
|
creator.setBounds(rec); |
|
|
|
} |
|
|
|
//绝对布局嵌套,要更新内部的绝对布局
|
|
|
|
} |
|
|
|
if (creator.acceptType(XWAbsoluteLayout.class)) { |
|
|
|
} |
|
|
|
creator.setBackupBound(wgtBound); |
|
|
|
|
|
|
|
((XWAbsoluteLayout) creator).updateBoundsWidget(); |
|
|
|
/** |
|
|
|
} |
|
|
|
* 更新子组件的Bound |
|
|
|
} |
|
|
|
* 这边主要用于绝对布局子组件在适应区域选项时 |
|
|
|
} |
|
|
|
* 涉及到的不同分辨率下缩放 |
|
|
|
} |
|
|
|
* @param minHeight 最小高度 |
|
|
|
|
|
|
|
*/ |
|
|
|
/** |
|
|
|
@Override |
|
|
|
* 更新子组件的Bound |
|
|
|
public void updateChildBound(int minHeight) { |
|
|
|
* 这边主要用于绝对布局子组件在适应区域选项时 |
|
|
|
double prevContainerPercent = FRScreen.getByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; |
|
|
|
* 涉及到的不同分辨率下缩放 |
|
|
|
if (toData().getCompState() == 0 && prevContainerPercent != containerPercent) { |
|
|
|
* |
|
|
|
for (int i = 0; i < this.getComponentCount(); i++) { |
|
|
|
* @param minHeight 最小高度 |
|
|
|
XCreator creator = getXCreator(i); |
|
|
|
*/ |
|
|
|
Rectangle rec = new Rectangle(creator.getBounds()); |
|
|
|
@Override |
|
|
|
rec.x = (int)(rec.x / prevContainerPercent * containerPercent); |
|
|
|
public void updateChildBound(int minHeight) { |
|
|
|
rec.y = (int)(rec.y / prevContainerPercent * containerPercent); |
|
|
|
double prevContainerPercent = FRScreen.getByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; |
|
|
|
rec.height = (int)(rec.height / prevContainerPercent * containerPercent); |
|
|
|
if (toData().getCompState() == 0 && prevContainerPercent != containerPercent) { |
|
|
|
rec.width = (int)(rec.width / prevContainerPercent * containerPercent); |
|
|
|
for (int i = 0; i < this.getComponentCount(); i++) { |
|
|
|
BoundsWidget wgt = toData().getBoundsWidget(creator.toData()); |
|
|
|
XCreator creator = getXCreator(i); |
|
|
|
wgt.setBounds(rec); |
|
|
|
Rectangle rec = new Rectangle(creator.getBounds()); |
|
|
|
creator.setBounds(rec); |
|
|
|
rec.x = (int) (rec.x / prevContainerPercent * containerPercent); |
|
|
|
creator.updateChildBound(minHeight); |
|
|
|
rec.y = (int) (rec.y / prevContainerPercent * containerPercent); |
|
|
|
} |
|
|
|
rec.height = (int) (rec.height / prevContainerPercent * containerPercent); |
|
|
|
} |
|
|
|
rec.width = (int) (rec.width / prevContainerPercent * containerPercent); |
|
|
|
toData().setDesigningResolution(Toolkit.getDefaultToolkit().getScreenSize()); |
|
|
|
BoundsWidget wgt = toData().getBoundsWidget(creator.toData()); |
|
|
|
} |
|
|
|
wgt.setBounds(rec); |
|
|
|
|
|
|
|
creator.setBounds(rec); |
|
|
|
/** |
|
|
|
creator.updateChildBound(minHeight); |
|
|
|
* 增加对齐线 |
|
|
|
} |
|
|
|
* @param connector 对齐线 |
|
|
|
} |
|
|
|
*/ |
|
|
|
toData().setDesigningResolution(Toolkit.getDefaultToolkit().getScreenSize()); |
|
|
|
public void addConnector(Connector connector) { |
|
|
|
} |
|
|
|
xConnectorMap.put(connector, new XConnector(connector, this)); |
|
|
|
|
|
|
|
((WAbsoluteLayout) data).addConnector(connector); |
|
|
|
/** |
|
|
|
} |
|
|
|
* 增加对齐线 |
|
|
|
|
|
|
|
* |
|
|
|
public XConnector getXConnector(Connector connector) { |
|
|
|
* @param connector 对齐线 |
|
|
|
return xConnectorMap.get(connector); |
|
|
|
*/ |
|
|
|
} |
|
|
|
public void addConnector(Connector connector) { |
|
|
|
|
|
|
|
xConnectorMap.put(connector, new XConnector(connector, this)); |
|
|
|
/** |
|
|
|
((WAbsoluteLayout) data).addConnector(connector); |
|
|
|
* 去除对齐线 |
|
|
|
} |
|
|
|
* @param connector 对齐线 |
|
|
|
|
|
|
|
*/ |
|
|
|
public XConnector getXConnector(Connector connector) { |
|
|
|
public void removeConnector(Connector connector) { |
|
|
|
return xConnectorMap.get(connector); |
|
|
|
((WAbsoluteLayout) data).removeConnector(connector); |
|
|
|
} |
|
|
|
xConnectorMap.remove(connector); |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
|
|
|
|
* 去除对齐线 |
|
|
|
/** |
|
|
|
* |
|
|
|
* 返回对应的widget容器 |
|
|
|
* @param connector 对齐线 |
|
|
|
* @return 返回WAbsoluteLayout |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void removeConnector(Connector connector) { |
|
|
|
@Override |
|
|
|
((WAbsoluteLayout) data).removeConnector(connector); |
|
|
|
public WAbsoluteLayout toData() { |
|
|
|
xConnectorMap.remove(connector); |
|
|
|
return (WAbsoluteLayout) data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@Override |
|
|
|
* 返回对应的widget容器 |
|
|
|
protected String getIconName() { |
|
|
|
* |
|
|
|
return "layout_absolute_new.png"; |
|
|
|
* @return 返回WAbsoluteLayout |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
/** |
|
|
|
public WAbsoluteLayout toData() { |
|
|
|
* 返回默认的容器name |
|
|
|
return (WAbsoluteLayout) data; |
|
|
|
* @return 返回绝对布局容器名 |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String createDefaultName() { |
|
|
|
protected String getIconName() { |
|
|
|
return "absolute"; |
|
|
|
return "layout_absolute_new.png"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
/** |
|
|
|
protected void initLayoutManager() { |
|
|
|
* 返回默认的容器name |
|
|
|
this.setLayout(new FRAbsoluteLayout()); |
|
|
|
* |
|
|
|
} |
|
|
|
* @return 返回绝对布局容器名 |
|
|
|
|
|
|
|
*/ |
|
|
|
/** |
|
|
|
@Override |
|
|
|
* 是否支持标题样式 |
|
|
|
public String createDefaultName() { |
|
|
|
* |
|
|
|
return "absolute"; |
|
|
|
* @return 默认false |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean hasTitleStyle() { |
|
|
|
protected void initLayoutManager() { |
|
|
|
return false; |
|
|
|
this.setLayout(new FRAbsoluteLayout()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
/** |
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
* 是否支持标题样式 |
|
|
|
super.paintComponent(g); |
|
|
|
* |
|
|
|
WAbsoluteLayout layout = (WAbsoluteLayout) data; |
|
|
|
* @return 默认false |
|
|
|
Connector[] connector = layout.getConnector(); |
|
|
|
*/ |
|
|
|
for (int i = 0, size = connector.length; i < size; i++) { |
|
|
|
@Override |
|
|
|
connector[i].draw(g); |
|
|
|
public boolean hasTitleStyle() { |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@Override |
|
|
|
* 转换保存组件信息的wlayout为对应的container |
|
|
|
public void paintComponent(Graphics g) { |
|
|
|
*/ |
|
|
|
super.paintComponent(g); |
|
|
|
@Override |
|
|
|
WAbsoluteLayout layout = (WAbsoluteLayout) data; |
|
|
|
public void convert() { |
|
|
|
Connector[] connector = layout.getConnector(); |
|
|
|
isRefreshing = true; |
|
|
|
for (int i = 0, size = connector.length; i < size; i++) { |
|
|
|
WAbsoluteLayout abs = toData(); |
|
|
|
connector[i].draw(g); |
|
|
|
this.removeAll(); |
|
|
|
} |
|
|
|
for (int i = 0, count = abs.getWidgetCount(); i < count; i++) { |
|
|
|
} |
|
|
|
BoundsWidget bw = (BoundsWidget)abs.getWidget(i); |
|
|
|
|
|
|
|
if (bw != null) { |
|
|
|
/** |
|
|
|
Rectangle bounds = bw.getBounds(); |
|
|
|
* 转换保存组件信息的wlayout为对应的container |
|
|
|
XWidgetCreator comp = (XWidgetCreator)XCreatorUtils.createXCreator(bw.getWidget()); |
|
|
|
*/ |
|
|
|
if (!comp.acceptType(XWParameterLayout.class)) { |
|
|
|
@Override |
|
|
|
comp.setDirections(Direction.ALL); |
|
|
|
public void convert() { |
|
|
|
} |
|
|
|
isRefreshing = true; |
|
|
|
add(comp); |
|
|
|
WAbsoluteLayout abs = toData(); |
|
|
|
comp.setBounds(bounds); |
|
|
|
this.removeAll(); |
|
|
|
} |
|
|
|
for (int i = 0, count = abs.getWidgetCount(); i < count; i++) { |
|
|
|
} |
|
|
|
BoundsWidget bw = (BoundsWidget) abs.getWidget(i); |
|
|
|
isRefreshing = false; |
|
|
|
if (bw != null) { |
|
|
|
} |
|
|
|
Rectangle bounds = bw.getBounds(); |
|
|
|
|
|
|
|
XWidgetCreator comp = (XWidgetCreator) XCreatorUtils.createXCreator(bw.getWidget()); |
|
|
|
/** |
|
|
|
if (!comp.acceptType(XWParameterLayout.class)) { |
|
|
|
* 当前组件zorder位置替换新的控件 |
|
|
|
comp.setDirections(Direction.ALL); |
|
|
|
* @param widget 控件 |
|
|
|
} |
|
|
|
* @param oldcreator 旧组件 |
|
|
|
add(comp); |
|
|
|
* @return 组件 |
|
|
|
comp.setBounds(bounds); |
|
|
|
*/ |
|
|
|
} |
|
|
|
@Override |
|
|
|
} |
|
|
|
public XCreator replace(Widget widget, XCreator oldcreator) { |
|
|
|
isRefreshing = false; |
|
|
|
int i = this.getComponentZOrder(oldcreator); |
|
|
|
} |
|
|
|
if (i != -1) { |
|
|
|
|
|
|
|
this.toData().replace(new BoundsWidget(widget, oldcreator.getBounds()), |
|
|
|
/** |
|
|
|
new BoundsWidget(oldcreator.toData(), oldcreator.getBounds())); |
|
|
|
* 当前组件zorder位置替换新的控件 |
|
|
|
this.convert(); |
|
|
|
* |
|
|
|
return (XCreator) this.getComponent(i); |
|
|
|
* @param widget 控件 |
|
|
|
} |
|
|
|
* @param oldcreator 旧组件 |
|
|
|
return null; |
|
|
|
* @return 组件 |
|
|
|
} |
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
/** |
|
|
|
public XCreator replace(Widget widget, XCreator oldcreator) { |
|
|
|
|
|
|
|
int i = this.getComponentZOrder(oldcreator); |
|
|
|
|
|
|
|
if (i != -1) { |
|
|
|
|
|
|
|
this.toData().replace(new BoundsWidget(widget, oldcreator.getBounds()), |
|
|
|
|
|
|
|
new BoundsWidget(oldcreator.toData(), oldcreator.getBounds())); |
|
|
|
|
|
|
|
this.convert(); |
|
|
|
|
|
|
|
return (XCreator) this.getComponent(i); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 组件增加 |
|
|
|
* 组件增加 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 容器事件 |
|
|
|
* @param e 容器事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void componentAdded(ContainerEvent e) { |
|
|
|
public void componentAdded(ContainerEvent e) { |
|
|
|
if (isRefreshing) { |
|
|
|
if (isRefreshing) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
XWidgetCreator creator = (XWidgetCreator) e.getChild(); |
|
|
|
XWidgetCreator creator = (XWidgetCreator) e.getChild(); |
|
|
|
WAbsoluteLayout wabs = this.toData(); |
|
|
|
WAbsoluteLayout wabs = this.toData(); |
|
|
|
if (!creator.acceptType(XWFitLayout.class)) { |
|
|
|
if (!creator.acceptType(XWFitLayout.class)) { |
|
|
|
creator.setDirections(Direction.ALL); |
|
|
|
creator.setDirections(Direction.ALL); |
|
|
|
} |
|
|
|
} |
|
|
|
wabs.addWidget(new BoundsWidget(creator.toData(), creator.getBounds())); |
|
|
|
wabs.addWidget(new BoundsWidget(creator.toData(), creator.getBounds())); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 在设计界面中有组件移除的时候,需要通知WLayout容器重新paint |
|
|
|
* 在设计界面中有组件移除的时候,需要通知WLayout容器重新paint |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 容器事件 |
|
|
|
* @param e 容器事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -364,127 +377,129 @@ public class XWAbsoluteLayout extends XLayoutContainer { |
|
|
|
wlayout.removeWidget(bw); |
|
|
|
wlayout.removeWidget(bw); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Dimension getMinimumSize() { |
|
|
|
public Dimension getMinimumSize() { |
|
|
|
return toData().getMinDesignSize(); |
|
|
|
return toData().getMinDesignSize(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public LayoutAdapter getLayoutAdapter() { |
|
|
|
public LayoutAdapter getLayoutAdapter() { |
|
|
|
return new FRAbsoluteLayoutAdapter(this); |
|
|
|
return new FRAbsoluteLayoutAdapter(this); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public XLayoutContainer getTopLayout() { |
|
|
|
public XLayoutContainer getTopLayout() { |
|
|
|
XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout(); |
|
|
|
XLayoutContainer xTopLayout = XCreatorUtils.getParentXLayoutContainer(this).getTopLayout(); |
|
|
|
if (xTopLayout != null && !xTopLayout.isEditable()){ |
|
|
|
if (xTopLayout != null && !xTopLayout.isEditable()) { |
|
|
|
return xTopLayout; |
|
|
|
return xTopLayout; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else{ |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 得到属性名 |
|
|
|
* 得到属性名 |
|
|
|
* |
|
|
|
* @return 属性名 |
|
|
|
* @return 属性名 |
|
|
|
* @throws java.beans.IntrospectionException |
|
|
|
* @throws java.beans.IntrospectionException |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
|
|
|
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { |
|
|
|
return new CRPropertyDescriptor[] { |
|
|
|
return new CRPropertyDescriptor[]{ |
|
|
|
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName( |
|
|
|
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName( |
|
|
|
Inter.getLocText("FR-Designer_Form-Widget_Name")) |
|
|
|
Inter.getLocText("FR-Designer_Form-Widget_Name")) |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void paint(Graphics g) { |
|
|
|
public void paint(Graphics g) { |
|
|
|
super.paint(g); |
|
|
|
super.paint(g); |
|
|
|
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
|
|
|
|
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
|
|
|
|
if (isMouseEnter && !this.editable) { |
|
|
|
if (isMouseEnter && !this.editable) { |
|
|
|
int x = 0; |
|
|
|
int x = 0; |
|
|
|
int y = 0; |
|
|
|
int y = 0; |
|
|
|
int w = getWidth(); |
|
|
|
int w = getWidth(); |
|
|
|
int h = getHeight(); |
|
|
|
int h = getHeight(); |
|
|
|
|
|
|
|
|
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
Composite oldComposite = g2d.getComposite(); |
|
|
|
Composite oldComposite = g2d.getComposite(); |
|
|
|
//画白色的编辑层
|
|
|
|
//画白色的编辑层
|
|
|
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F)); |
|
|
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 60 / 100.0F)); |
|
|
|
g2d.setColor(Color.WHITE); |
|
|
|
g2d.setColor(Color.WHITE); |
|
|
|
g2d.fillRect(x, y, w, h); |
|
|
|
g2d.fillRect(x, y, w, h); |
|
|
|
//画编辑按钮所在框
|
|
|
|
//画编辑按钮所在框
|
|
|
|
g2d.setComposite(oldComposite); |
|
|
|
g2d.setComposite(oldComposite); |
|
|
|
g2d.setColor(new Color(176, 196, 222)); |
|
|
|
g2d.setColor(new Color(176, 196, 222)); |
|
|
|
g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT); |
|
|
|
g2d.fillRect((x + w / 2 - EDIT_BTN_WIDTH / 2), (y + h / 2 - EDIT_BTN_HEIGHT / 2), EDIT_BTN_WIDTH, EDIT_BTN_HEIGHT); |
|
|
|
//画编辑按钮图标
|
|
|
|
//画编辑按钮图标
|
|
|
|
BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH); |
|
|
|
BufferedImage image = IOUtils.readImage(IconPathConstants.TD_EDIT_ICON_PATH); |
|
|
|
g2d.drawImage( |
|
|
|
g2d.drawImage( |
|
|
|
image, |
|
|
|
image, |
|
|
|
(x + w / 2 - 23), |
|
|
|
(x + w / 2 - 23), |
|
|
|
(y + h / 2 - image.getHeight() / 2), |
|
|
|
(y + h / 2 - image.getHeight() / 2), |
|
|
|
image.getWidth(), |
|
|
|
image.getWidth(), |
|
|
|
image.getHeight(), |
|
|
|
image.getHeight(), |
|
|
|
null, |
|
|
|
null, |
|
|
|
this |
|
|
|
this |
|
|
|
); |
|
|
|
); |
|
|
|
g2d.setColor(Color.BLACK); |
|
|
|
g2d.setColor(Color.BLACK); |
|
|
|
//画编辑文字
|
|
|
|
//画编辑文字
|
|
|
|
g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5); |
|
|
|
g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 响应点击事件 |
|
|
|
* 响应点击事件 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param editingMouseListener 鼠标点击,位置处理器 |
|
|
|
* @param editingMouseListener 鼠标点击,位置处理器 |
|
|
|
* @param e 鼠标点击事件 |
|
|
|
* @param e 鼠标点击事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ |
|
|
|
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) { |
|
|
|
FormDesigner designer = editingMouseListener.getDesigner(); |
|
|
|
FormDesigner designer = editingMouseListener.getDesigner(); |
|
|
|
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); |
|
|
|
SelectionModel selectionModel = editingMouseListener.getSelectionModel(); |
|
|
|
boolean isEditing = isEditable() || designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2; |
|
|
|
boolean isEditing = isEditable() || designer.getCursor().getType() == Cursor.HAND_CURSOR || e.getClickCount() == 2; |
|
|
|
setEditable(isEditing); |
|
|
|
setEditable(isEditing); |
|
|
|
|
|
|
|
|
|
|
|
selectionModel.selectACreatorAtMouseEvent(e); |
|
|
|
selectionModel.selectACreatorAtMouseEvent(e); |
|
|
|
designer.repaint(); |
|
|
|
designer.repaint(); |
|
|
|
|
|
|
|
|
|
|
|
if (editingMouseListener.stopEditing()) { |
|
|
|
if (editingMouseListener.stopEditing()) { |
|
|
|
if (this != designer.getRootComponent()) { |
|
|
|
if (this != designer.getRootComponent()) { |
|
|
|
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); |
|
|
|
ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); |
|
|
|
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter); |
|
|
|
editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* body大小手动调整的时候 |
|
|
|
* body大小手动调整的时候 |
|
|
|
* 按照比例调整组件的宽度 |
|
|
|
* 按照比例调整组件的宽度 |
|
|
|
* @param percent 比例 |
|
|
|
* |
|
|
|
*/ |
|
|
|
* @param percent 比例 |
|
|
|
@Override |
|
|
|
*/ |
|
|
|
public void adjustCompWidth(double percent) { |
|
|
|
@Override |
|
|
|
for (int i = 0; i < getComponentCount(); i++) { |
|
|
|
public void adjustCompWidth(double percent) { |
|
|
|
XCreator xCreator = (XCreator) getComponent(i); |
|
|
|
for (int i = 0; i < getComponentCount(); i++) { |
|
|
|
Rectangle rectangle = xCreator.getBounds(); |
|
|
|
XCreator xCreator = (XCreator) getComponent(i); |
|
|
|
xCreator.setBounds((int) (rectangle.x * percent), rectangle.y, (int) (rectangle.width * percent), rectangle.height); |
|
|
|
Rectangle rectangle = xCreator.getBounds(); |
|
|
|
BoundsWidget widget = toData().getBoundsWidget(xCreator.toData()); |
|
|
|
xCreator.setBounds((int) (rectangle.x * percent), rectangle.y, (int) (rectangle.width * percent), rectangle.height); |
|
|
|
widget.setBounds(xCreator.getBounds()); |
|
|
|
BoundsWidget widget = toData().getBoundsWidget(xCreator.toData()); |
|
|
|
} |
|
|
|
widget.setBounds(xCreator.getBounds()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
|
|
|
|
* body大小手动调整的时候 |
|
|
|
/** |
|
|
|
* 按照比例调整组件的高度 |
|
|
|
* body大小手动调整的时候 |
|
|
|
* @param percent 比例 |
|
|
|
* 按照比例调整组件的高度 |
|
|
|
*/ |
|
|
|
* |
|
|
|
@Override |
|
|
|
* @param percent 比例 |
|
|
|
public void adjustCompHeight(double percent) { |
|
|
|
*/ |
|
|
|
for (int i = 0; i < getComponentCount(); i++) { |
|
|
|
@Override |
|
|
|
XCreator xCreator = (XCreator) getComponent(i); |
|
|
|
public void adjustCompHeight(double percent) { |
|
|
|
Rectangle rectangle = xCreator.getBounds(); |
|
|
|
for (int i = 0; i < getComponentCount(); i++) { |
|
|
|
xCreator.setBounds(rectangle.x, (int) (rectangle.y * percent), rectangle.width, (int) (rectangle.height * percent)); |
|
|
|
XCreator xCreator = (XCreator) getComponent(i); |
|
|
|
BoundsWidget widget = toData().getBoundsWidget(xCreator.toData()); |
|
|
|
Rectangle rectangle = xCreator.getBounds(); |
|
|
|
widget.setBounds(xCreator.getBounds()); |
|
|
|
xCreator.setBounds(rectangle.x, (int) (rectangle.y * percent), rectangle.width, (int) (rectangle.height * percent)); |
|
|
|
} |
|
|
|
BoundsWidget widget = toData().getBoundsWidget(xCreator.toData()); |
|
|
|
} |
|
|
|
widget.setBounds(xCreator.getBounds()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |