From d3e9ff80abce6e60143c05ce76f64cc24445c99a Mon Sep 17 00:00:00 2001 From: zhouping Date: Thu, 8 Dec 2016 16:59:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-1092=20=E4=B8=A4=E4=B8=AA=E4=B8=80?= =?UTF-8?q?=E6=A0=B7=E7=9A=84=E8=A1=A8=E5=8D=95demo=EF=BC=8C=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E7=9A=84=E6=95=88=E6=9E=9C=E4=B8=8D=E4=B8=80=E6=A0=B7?= =?UTF-8?q?=20dev=E4=B8=8A=E6=B5=8B=E8=AF=95=E9=AA=8C=E6=94=B6=E8=BF=87?= =?UTF-8?q?=E4=BA=86=EF=BC=8C=E5=90=8C=E6=AD=A5=E5=88=B0master?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/FRAbsoluteLayoutAdapter.java | 1 + .../designer/creator/XWAbsoluteLayout.java | 31 +++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index 3ab61eb38b..1765a8ef00 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -235,6 +235,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { } XWAbsoluteLayout layout = (XWAbsoluteLayout) container; layout.updateBoundsWidget(creator); + updateCreatorBackBound(); LayoutUtils.layoutRootContainer(container); }else{ fixAbsolute(creator, x, y); diff --git a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java index df28759393..06ae6fa785 100644 --- a/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -96,7 +96,6 @@ public class XWAbsoluteLayout extends XLayoutContainer { if(screenValue != FormArea.DEFAULT_SLIDER){ this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); } - widget.setDesigningResolution(scrnsize); } /** @@ -208,7 +207,33 @@ 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 对齐线 @@ -418,7 +443,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { ); 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); } } From c371f4ca32f9b0af79d213b00d931baaf4821f00 Mon Sep 17 00:00:00 2001 From: zhouping Date: Thu, 8 Dec 2016 17:19:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-1092=20=E4=B8=A4=E4=B8=AA=E4=B8=80?= =?UTF-8?q?=E6=A0=B7=E7=9A=84=E8=A1=A8=E5=8D=95demo=EF=BC=8C=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E7=9A=84=E6=95=88=E6=9E=9C=E4=B8=8D=E4=B8=80=E6=A0=B7?= =?UTF-8?q?=20pmd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../layout/FRAbsoluteLayoutAdapter.java | 70 ++++++++++--------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java index 1765a8ef00..6e68cc2d71 100644 --- a/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java +++ b/designer_form/src/com/fr/design/designer/beans/adapters/layout/FRAbsoluteLayoutAdapter.java @@ -67,38 +67,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout(); if(topLayout != null){ if (topLayout.isEditable()){ - //判断有没有和当前控件重叠 - //先计算当前控件的位置 - int creatorX, creatorY; - if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { - - Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); - creatorX = creatorRectangle.x; - creatorY = creatorRectangle.y; - } else { - int w = creator.getWidth() / 2; - int h = creator.getHeight() / 2; - creatorX = x - w; - creatorY = y - h; - } - //再判断和布局中其他控件重叠 - Rectangle curRec = new Rectangle(creatorX, creatorY, creator.getWidth(), creator.getHeight()); - WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout)topLayout.toData(); - for (int i = 0, count = wAbsoluteLayout.getWidgetCount(); i < count; i++) { - WAbsoluteLayout.BoundsWidget temp = (WAbsoluteLayout.BoundsWidget) wAbsoluteLayout.getWidget(i); - Rectangle rectangle = temp.getBounds(); - if (curRec.intersects(rectangle)){ - return false; - } - } - if (creatorX < 0 - || creatorX + creator.getWidth() > container.getWidth() - || creatorY < 0 - || creatorY + creator.getHeight() > container.getHeight()) { - return false; - } - return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() - && creator.getWidth() <= container.getWidth(); + return topLayoutAccept(creator, x, y, topLayout); } //绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局 else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) { @@ -115,6 +84,42 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { return false; } + //toplayout假如可以编辑的话就往里面添加组件 + private boolean topLayoutAccept(XCreator creator, int x, int y, XLayoutContainer topLayout) { + //判断有没有和当前控件重叠 + //先计算当前控件的位置 + int creatorX, creatorY; + if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { + + Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); + creatorX = creatorRectangle.x; + creatorY = creatorRectangle.y; + } else { + int w = creator.getWidth() / 2; + int h = creator.getHeight() / 2; + creatorX = x - w; + creatorY = y - h; + } + //再判断和布局中其他控件重叠 + Rectangle curRec = new Rectangle(creatorX, creatorY, creator.getWidth(), creator.getHeight()); + WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout)topLayout.toData(); + for (int i = 0, count = wAbsoluteLayout.getWidgetCount(); i < count; i++) { + WAbsoluteLayout.BoundsWidget temp = (WAbsoluteLayout.BoundsWidget) wAbsoluteLayout.getWidget(i); + Rectangle rectangle = temp.getBounds(); + if (curRec.intersects(rectangle)){ + return false; + } + } + if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) { + return false; + } + if (creatorY < 0 || creatorY + creator.getHeight() > container.getHeight()){ + return false; + } + return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() + && creator.getWidth() <= container.getWidth(); + } + /** * 判断是否鼠标在组件的三等分区域,如果组件在布局管理器中间,上下左右都可能会三等分 * @param parentComp 鼠标所在区域的组件 @@ -156,6 +161,7 @@ public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { return !ComparatorUtils.equals(trisectAreaDirect, 0); } + //当前绝对布局不可编辑,就当成一个控件,组件添加在周围 private boolean acceptWidget(XCreator creator, int x, int y){ isFindRelatedComps = false; //拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域