|
|
|
@ -41,7 +41,6 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 是否能在指定位置添加组件 |
|
|
|
|
* |
|
|
|
|
* @param creator 组件 |
|
|
|
|
* @param x 坐标x |
|
|
|
|
* @param y 坐标y |
|
|
|
@ -57,27 +56,27 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
//布局控件要先判断是不是可编辑
|
|
|
|
|
//可以编辑,按原有逻辑判断
|
|
|
|
|
//不可编辑,当成一整个控件处理
|
|
|
|
|
if (comp == null) { |
|
|
|
|
if (comp == null){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
//参数面板内的组件不允许拖往绝对布局中
|
|
|
|
|
if (creator.getParent() != null && ((XCreator) creator.getParent()).acceptType(XWParameterLayout.class)) { |
|
|
|
|
if (creator.getParent() != null && ((XCreator)creator.getParent()).acceptType(XWParameterLayout.class)){ |
|
|
|
|
Rectangle rec = creator.getBounds(); |
|
|
|
|
rec.y = creator.getParent().getHeight() - rec.height; |
|
|
|
|
creator.setBounds(rec); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
//判断组件能不能拖入绝对布局
|
|
|
|
|
if (!creator.canEnterIntoAbsolutePane()) { |
|
|
|
|
//判断下组件能不能拖入绝对布局
|
|
|
|
|
if (!creator.canEnterIntoAbsolutePane()){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout(); |
|
|
|
|
if (topLayout != null) { |
|
|
|
|
if (topLayout.isEditable()) { |
|
|
|
|
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout(); |
|
|
|
|
if(topLayout != null){ |
|
|
|
|
if (topLayout.isEditable()){ |
|
|
|
|
return topLayoutAccept(creator, x, y); |
|
|
|
|
} |
|
|
|
|
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
|
|
|
|
|
else if (((XLayoutContainer) topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) { |
|
|
|
|
else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) { |
|
|
|
|
return false; |
|
|
|
|
} else { |
|
|
|
|
return acceptWidget(x, y); |
|
|
|
@ -111,7 +110,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (creatorY < 0 || creatorY + creator.getHeight() > container.getHeight()) { |
|
|
|
|
if (creatorY < 0 || creatorY + creator.getHeight() > container.getHeight()){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() |
|
|
|
@ -120,16 +119,15 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 判断是否鼠标在组件的三等分区域,如果组件在布局管理器中间,上下左右都可能会三等分 |
|
|
|
|
* |
|
|
|
|
* @param parentComp 鼠标所在区域的组件 |
|
|
|
|
* @param x 坐标x |
|
|
|
|
* @param y 坐标y |
|
|
|
|
* @return 是则返回true |
|
|
|
|
*/ |
|
|
|
|
public boolean isTrisectionArea(Component parentComp, int x, int y) { |
|
|
|
|
XCreator creator = (XCreator) parentComp; |
|
|
|
|
XCreator creator = (XCreator)parentComp; |
|
|
|
|
trisectAreaDirect = 0; |
|
|
|
|
if (container.getComponentCount() <= 1) { |
|
|
|
|
if (container.getComponentCount()<=1) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
int maxWidth = parentComp.getWidth(); |
|
|
|
@ -137,23 +135,23 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
int xL = parentComp.getX(); |
|
|
|
|
int yL = parentComp.getY(); |
|
|
|
|
// 组件宽高的十分之一和默认值取大
|
|
|
|
|
int minRangeWidth = Math.max(maxWidth / BORDER_PROPORTION, DEFAULT_AREA_LENGTH); |
|
|
|
|
int minRangeHeight = Math.max(maxHeight / BORDER_PROPORTION, DEFAULT_AREA_LENGTH); |
|
|
|
|
if (y < yL + minRangeHeight) { |
|
|
|
|
int minRangeWidth = Math.max(maxWidth/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); |
|
|
|
|
int minRangeHeight = Math.max(maxHeight/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); |
|
|
|
|
if(y<yL+minRangeHeight ) { |
|
|
|
|
// 在组件上侧三等分
|
|
|
|
|
trisectAreaDirect = COMP_TOP; |
|
|
|
|
} else if (y > yL + maxHeight - minRangeHeight) { |
|
|
|
|
} else if(y>yL+maxHeight-minRangeHeight) { |
|
|
|
|
// 在组件下侧三等分
|
|
|
|
|
trisectAreaDirect = COMP_BOTTOM; |
|
|
|
|
} else if (x < xL + minRangeWidth) { |
|
|
|
|
} else if (x<xL+minRangeWidth) { |
|
|
|
|
// 在组件左侧三等分
|
|
|
|
|
trisectAreaDirect = COMP_LEFT; |
|
|
|
|
} else if (x > xL + maxWidth - minRangeWidth) { |
|
|
|
|
} else if(x>xL+maxWidth-minRangeWidth) { |
|
|
|
|
// 在组件右侧三等分
|
|
|
|
|
trisectAreaDirect = COMP_RIGHT; |
|
|
|
|
} |
|
|
|
|
// tab布局的边界特殊处理,不进行三等分
|
|
|
|
|
if (!creator.getTargetChildrenList().isEmpty()) { |
|
|
|
|
if(!creator.getTargetChildrenList().isEmpty()){ |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -215,7 +213,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void addComp(XCreator creator, int x, int y) { |
|
|
|
|
if (!isAdd2ParentLayout) { |
|
|
|
|
if(!isAdd2ParentLayout) { |
|
|
|
|
Rectangle r = ComponentUtils.getRelativeBounds(container); |
|
|
|
|
x = x - r.x; |
|
|
|
|
y = y - r.y; |
|
|
|
@ -235,18 +233,18 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
if (creator.hasTitleStyle()) { |
|
|
|
|
addParentCreator(creator); |
|
|
|
|
} else { |
|
|
|
|
container.add(creator, creator.toData().getWidgetName(), 0); |
|
|
|
|
container.add(creator, creator.toData().getWidgetName(),0); |
|
|
|
|
} |
|
|
|
|
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; |
|
|
|
|
layout.updateBoundsWidget(creator); |
|
|
|
|
updateCreatorBackBound(); |
|
|
|
|
LayoutUtils.layoutRootContainer(container); |
|
|
|
|
} else { |
|
|
|
|
}else{ |
|
|
|
|
fixAbsolute(creator, x, y); |
|
|
|
|
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { |
|
|
|
|
addParentCreator(creator); |
|
|
|
|
} else { |
|
|
|
|
container.add(creator, creator.toData().getWidgetName(), 0); |
|
|
|
|
container.add(creator, creator.toData().getWidgetName(),0); |
|
|
|
|
} |
|
|
|
|
XWFitLayout layout = (XWFitLayout) container; |
|
|
|
|
// 更新对应的BoundsWidget
|
|
|
|
@ -256,7 +254,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void updateCreatorBackBound() { |
|
|
|
|
for (int i = 0, size = container.getComponentCount(); i < size; i++) { |
|
|
|
|
for (int i=0,size=container.getComponentCount(); i<size; i++) { |
|
|
|
|
XCreator creator = (XCreator) container.getComponent(i); |
|
|
|
|
creator.updateChildBound(minHeight); |
|
|
|
|
creator.setBackupBound(creator.getBounds()); |
|
|
|
@ -265,22 +263,21 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
|
|
|
|
|
private void addParentCreator(XCreator child) { |
|
|
|
|
XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight()); |
|
|
|
|
container.add(parentPanel, child.toData().getWidgetName(), 0); |
|
|
|
|
container.add(parentPanel, child.toData().getWidgetName(),0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 新拖入组件时,计算调整其他关联组件位置大小 |
|
|
|
|
* |
|
|
|
|
* @param child 新拖入的组件 |
|
|
|
|
* @param x 鼠标所在x坐标 |
|
|
|
|
* @param y 鼠标所在y坐标 |
|
|
|
|
*/ |
|
|
|
|
private void fixAbsolute(XCreator child, int x, int y) { |
|
|
|
|
Component parentComp = container.getComponentAt(x, y); |
|
|
|
|
if (container.getComponentCount() == 0) { |
|
|
|
|
if (container.getComponentCount()==0){ |
|
|
|
|
child.setLocation(0, 0); |
|
|
|
|
child.setSize(parentComp.getWidth(), parentComp.getHeight()); |
|
|
|
|
} else if (isCrossPointArea(parentComp, x, y)) { |
|
|
|
|
} else if(isCrossPointArea(parentComp, x, y)){ |
|
|
|
|
//交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入
|
|
|
|
|
fixCrossPointArea(parentComp, child, x, y); |
|
|
|
|
return; |
|
|
|
@ -288,21 +285,20 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
// 在边界三等分区域,就不再和组件二等分了
|
|
|
|
|
fixTrisect(parentComp, child, x, y); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
} else{ |
|
|
|
|
fixHalve(parentComp, child, x, y); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 组件拖拽后调整大小 |
|
|
|
|
* |
|
|
|
|
* @param creator 组件 |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public void fix(XCreator creator) { |
|
|
|
|
WAbsoluteLayout wabs = (WAbsoluteLayout) container.toData(); |
|
|
|
|
fix(creator, creator.getX(), creator.getY()); |
|
|
|
|
wabs.setBounds(creator.toData(), creator.getBounds()); |
|
|
|
|
WAbsoluteLayout wabs = (WAbsoluteLayout)container.toData(); |
|
|
|
|
fix(creator,creator.getX(),creator.getY()); |
|
|
|
|
wabs.setBounds(creator.toData(),creator.getBounds()); |
|
|
|
|
|
|
|
|
|
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; |
|
|
|
|
layout.updateBoundsWidget(creator); |
|
|
|
@ -310,12 +306,11 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 调整组件大小到合适尺寸位置 |
|
|
|
|
* |
|
|
|
|
* @param creator 组件 |
|
|
|
|
* @param x 坐标x |
|
|
|
|
* @param y 坐标y |
|
|
|
|
*/ |
|
|
|
|
public void fix(XCreator creator, int x, int y) { |
|
|
|
|
public void fix(XCreator creator ,int x, int y) { |
|
|
|
|
int height = creator.getHeight(); |
|
|
|
|
int width = creator.getWidth(); |
|
|
|
|
if (x < 0) { |
|
|
|
@ -335,7 +330,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { |
|
|
|
|
return new BoundsGroupModel((XWAbsoluteLayout) container, creator); |
|
|
|
|
return new BoundsGroupModel((XWAbsoluteLayout)container, creator); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|