Browse Source

Merge pull request #575 in BA/design from ~ZHOUPING/design:master to master

* commit 'c371f4ca32f9b0af79d213b00d931baaf4821f00':
  REPORT-1092 两个一样的表单demo,预览的效果不一样 pmd
  REPORT-1092 两个一样的表单demo,预览的效果不一样 dev上测试验收过了,同步到master
master
superman 8 years ago
parent
commit
2b2175563a
  1. 43
      designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java
  2. 29
      designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

43
designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java

@ -67,6 +67,25 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout(); XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout();
if(topLayout != null){ if(topLayout != null){
if (topLayout.isEditable()){ if (topLayout.isEditable()){
return topLayoutAccept(creator, x, y, topLayout);
}
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) {
return false;
}
else {
return acceptWidget(creator, x, y);
}
}
else{
FRLogger.getLogger().error("top layout is null!");
}
return false;
}
//toplayout假如可以编辑的话就往里面添加组件
private boolean topLayoutAccept(XCreator creator, int x, int y, XLayoutContainer topLayout) {
//判断有没有和当前控件重叠 //判断有没有和当前控件重叠
//先计算当前控件的位置 //先计算当前控件的位置
int creatorX, creatorY; int creatorX, creatorY;
@ -91,28 +110,14 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
return false; return false;
} }
} }
if (creatorX < 0 if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) {
|| creatorX + creator.getWidth() > container.getWidth()
|| creatorY < 0
|| creatorY + creator.getHeight() > container.getHeight()) {
return false; return false;
} }
return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() if (creatorY < 0 || creatorY + creator.getHeight() > container.getHeight()){
&& creator.getWidth() <= container.getWidth();
}
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) {
return false; return false;
} }
else { return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight()
return acceptWidget(creator, x, y); && creator.getWidth() <= container.getWidth();
}
}
else{
FRLogger.getLogger().error("top layout is null!");
}
return false;
} }
/** /**
@ -156,6 +161,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
return !ComparatorUtils.equals(trisectAreaDirect, 0); return !ComparatorUtils.equals(trisectAreaDirect, 0);
} }
//当前绝对布局不可编辑,就当成一个控件,组件添加在周围
private boolean acceptWidget(XCreator creator, int x, int y){ private boolean acceptWidget(XCreator creator, int x, int y){
isFindRelatedComps = false; isFindRelatedComps = false;
//拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域 //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
@ -235,6 +241,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter {
} }
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; XWAbsoluteLayout layout = (XWAbsoluteLayout) container;
layout.updateBoundsWidget(creator); layout.updateBoundsWidget(creator);
updateCreatorBackBound();
LayoutUtils.layoutRootContainer(container); LayoutUtils.layoutRootContainer(container);
}else{ }else{
fixAbsolute(creator, x, y); fixAbsolute(creator, x, y);

29
designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java

@ -96,7 +96,6 @@ public class XWAbsoluteLayout extends XLayoutContainer {
if(screenValue != FormArea.DEFAULT_SLIDER){ if(screenValue != FormArea.DEFAULT_SLIDER){
this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER);
} }
widget.setDesigningResolution(scrnsize);
} }
/** /**
@ -209,6 +208,32 @@ public class XWAbsoluteLayout extends XLayoutContainer {
} }
} }
/**
* 更新子组件的Bound
* 这边主要用于绝对布局子组件在适应区域选项时
* 涉及到的不同分辨率下缩放
* @param minHeight 最小高度
*/
@Override
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++) {
XCreator creator = getXCreator(i);
Rectangle rec = new Rectangle(creator.getBounds());
rec.x = (int)(rec.x / prevContainerPercent * containerPercent);
rec.y = (int)(rec.y / prevContainerPercent * containerPercent);
rec.height = (int)(rec.height / prevContainerPercent * containerPercent);
rec.width = (int)(rec.width / prevContainerPercent * containerPercent);
BoundsWidget wgt = toData().getBoundsWidget(creator.toData());
wgt.setBounds(rec);
creator.setBounds(rec);
creator.updateChildBound(minHeight);
}
}
toData().setDesigningResolution(Toolkit.getDefaultToolkit().getScreenSize());
}
/** /**
* 增加对齐线 * 增加对齐线
* @param connector 对齐线 * @param connector 对齐线
@ -418,7 +443,7 @@ public class XWAbsoluteLayout extends XLayoutContainer {
); );
g2d.setColor(Color.BLACK); g2d.setColor(Color.BLACK);
//画编辑文字 //画编辑文字
g2d.drawString(Inter.getLocText("Edit"), x + w / 2 - 2, y + h / 2 + 5); g2d.drawString(Inter.getLocText("FR-Designer_Edit"), x + w / 2 - 2, y + h / 2 + 5);
} }
} }

Loading…
Cancel
Save