From 05b6fd9f8561e8b29dcdf0614fc1f1f9769e91e4 Mon Sep 17 00:00:00 2001 From: zhouping Date: Wed, 15 Feb 2017 12:46:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-1940=20=E8=A1=A8=E5=8D=95=E4=BB=8E?= =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80=E5=88=87=E6=8D=A2=E5=88=B0?= =?UTF-8?q?=E8=87=AA=E9=80=82=E5=BA=94=EF=BC=8C=E9=A2=84=E8=A7=88=E7=A9=BA?= =?UTF-8?q?=E7=99=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java index b290bcccf..f864a6dd5 100644 --- a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java +++ b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java @@ -182,7 +182,7 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr private void moveComponents2FitLayout(XWFitLayout xwFitLayout) { int eachRowCount = 4; Component[] components = xwFitLayout.getComponents(); - if (components.length <= 1){ + if (components.length == 0){ xwFitLayout.updateBoundsWidget(); return; } From 4f599cdfa6c618e88f51b18a73b6e8bcf0941a78 Mon Sep 17 00:00:00 2001 From: zhouping Date: Wed, 15 Feb 2017 12:54:24 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-1940=20=E8=A1=A8=E5=8D=95=E4=BB=8E?= =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80=E5=88=87=E6=8D=A2=E5=88=B0?= =?UTF-8?q?=E8=87=AA=E9=80=82=E5=BA=94=EF=BC=8C=E9=A2=84=E8=A7=88=E7=A9=BA?= =?UTF-8?q?=E7=99=BD=20pmd?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...AbsoluteBodyLayoutPropertiesGroupModel.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java index f864a6dd5..eb4b31154 100644 --- a/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java +++ b/designer_form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java @@ -26,8 +26,11 @@ import java.util.Comparator; public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPropertiesGroupModel { private LayoutTypeEditor layoutTypeEditor; private LayoutTypeRenderer layoutTypeRenderer; + //默认body是0,自适应布局;1,绝对布局. private WBodyLayoutType layoutType = WBodyLayoutType.ABSOLUTE; + private static final int EACH_ROW_COUNT = 4; + public FRAbsoluteBodyLayoutPropertiesGroupModel(XWAbsoluteBodyLayout xwAbsoluteBodyLayout) { super(xwAbsoluteBodyLayout); } @@ -180,7 +183,6 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr // 把绝对布局中的元素按规则移动到自适应布局中 // 规则:各元素按顺序放置,其中每行最多4个元素,超出则换行,各元素均分body的高度和宽度 private void moveComponents2FitLayout(XWFitLayout xwFitLayout) { - int eachRowCount = 4; Component[] components = xwFitLayout.getComponents(); if (components.length == 0){ xwFitLayout.updateBoundsWidget(); @@ -191,17 +193,17 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr int leftMargin = xwFitLayout.toData().getMargin().getLeft(); int topMargin = xwFitLayout.toData().getMargin().getTop(); xwFitLayout.toData().setCompInterval(0); - int row = (components.length / eachRowCount) + (components.length % eachRowCount == 0 ? 0 : 1); + int row = (components.length / EACH_ROW_COUNT) + (components.length % EACH_ROW_COUNT == 0 ? 0 : 1); //最后一行的列数不定 - int column = components.length % eachRowCount == 0 ? eachRowCount : components.length % eachRowCount; - int componentWidth = layoutWidth / eachRowCount; + int column = components.length % EACH_ROW_COUNT == 0 ? EACH_ROW_COUNT : components.length % EACH_ROW_COUNT; + int componentWidth = layoutWidth / EACH_ROW_COUNT; int componentHeight = layoutHeight / row; for(int i = 0;i < row - 1;i++){ - for(int j = 0;j < eachRowCount;j++){ - components[eachRowCount * i + j].setBounds( + for(int j = 0;j < EACH_ROW_COUNT;j++){ + components[EACH_ROW_COUNT * i + j].setBounds( leftMargin + componentWidth * j, topMargin + componentHeight * i, - j == eachRowCount - 1 ? layoutWidth - componentWidth * (eachRowCount - 1) : componentWidth, + j == EACH_ROW_COUNT - 1 ? layoutWidth - componentWidth * (EACH_ROW_COUNT - 1) : componentWidth, componentHeight ); } @@ -210,7 +212,7 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr int lastRowWidth = layoutWidth / column; int lastRowHeight = layoutHeight - componentHeight * (row - 1); for (int i = 0;i < column;i++) { - components[eachRowCount * (row - 1) + i].setBounds( + components[EACH_ROW_COUNT * (row - 1) + i].setBounds( leftMargin + lastRowWidth * i, topMargin + componentHeight * (row - 1), i == column - 1 ? layoutWidth - lastRowWidth * (column - 1) : lastRowWidth,