From 36abb23817fc9fb6538507203bd43ea6e98aaf01 Mon Sep 17 00:00:00 2001 From: kerry Date: Mon, 25 Jun 2018 09:17:09 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-8754=20=E6=A8=A1=E6=9D=BF=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=8F=8C=E5=90=91=E8=87=AA=E9=80=82=E5=BA=94=E5=90=8E?= =?UTF-8?q?frm=E9=87=8C=E7=9A=84=E7=BD=91=E9=A1=B5=E6=A1=86=E9=87=8C?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98(10.0?= =?UTF-8?q?=E4=BC=A0=E4=B8=80=E4=BB=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapters/layout/FRBodyLayoutAdapter.java | 12 +-- .../fr/design/designer/creator/XCreator.java | 6 +- .../design/designer/creator/XWFitLayout.java | 3 +- .../cardlayout/XWCardMainBorderLayout.java | 88 +++++++++++-------- ...bsoluteBodyLayoutPropertiesGroupModel.java | 4 +- .../FRAbsoluteBodyLayoutDefinePane.java | 4 +- 6 files changed, 68 insertions(+), 49 deletions(-) diff --git a/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java b/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java index 75190ba3b..05da6975c 100644 --- a/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java +++ b/designer-form/src/com/fr/design/designer/beans/adapters/layout/FRBodyLayoutAdapter.java @@ -620,8 +620,8 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter { } else { currentCreator.setLocation(finalX, finalY); currentCreator.setSize(finalW, finalH); - currentCreator.recalculateChildWidth(finalW); - currentCreator.recalculateChildHeight(finalH); + currentCreator.recalculateChildWidth(finalW, false); + currentCreator.recalculateChildHeight(finalH, false); child.setLocation(xL, yL); child.setSize(dim); } @@ -1078,7 +1078,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter { int offset = comp.getHeight() - length; comp.setSize(comp.getWidth(), offset); XCreator creator = (XCreator) comp; - creator.recalculateChildHeight(offset); + creator.recalculateChildHeight(offset, false); } } @@ -1100,7 +1100,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter { int offset = comp.getHeight() - length; comp.setSize(comp.getWidth(), offset); XCreator creator = (XCreator) comp; - creator.recalculateChildHeight(offset); + creator.recalculateChildHeight(offset, false); } } childY += actualVal; @@ -1134,7 +1134,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter { int offset = comp.getWidth() - length; comp.setSize(offset, comp.getHeight()); XCreator creator = (XCreator) comp; - creator.recalculateChildWidth(offset); + creator.recalculateChildWidth(offset, false); } } childX += actualVal; @@ -1155,7 +1155,7 @@ public class FRBodyLayoutAdapter extends AbstractLayoutAdapter { int offset = comp.getWidth() - length; comp.setSize(offset, comp.getHeight()); XCreator creator = (XCreator) comp; - creator.recalculateChildWidth(offset); + creator.recalculateChildWidth(offset, false); } } diff --git a/designer-form/src/com/fr/design/designer/creator/XCreator.java b/designer-form/src/com/fr/design/designer/creator/XCreator.java index 8aa2f215e..d71f81387 100644 --- a/designer-form/src/com/fr/design/designer/creator/XCreator.java +++ b/designer-form/src/com/fr/design/designer/creator/XCreator.java @@ -576,15 +576,17 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo /** * 重新调整子组件宽度 * @param width 宽度 + * @param actualSize 是否按照实际大小计算 */ - public void recalculateChildWidth(int width){ + public void recalculateChildWidth(int width, boolean actualSize){ return; } /** * 重新调整子组件高度 * @param height 高度 + * @param actualSize 是否按照实际大小计算 */ - public void recalculateChildHeight(int height){ + public void recalculateChildHeight(int height, boolean actualSize){ return; } diff --git a/designer-form/src/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/com/fr/design/designer/creator/XWFitLayout.java index 722e86676..a5d4537ef 100644 --- a/designer-form/src/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/XWFitLayout.java @@ -373,7 +373,7 @@ public class XWFitLayout extends XLayoutContainer { if (x == 0) { int width = notHasRightCreator(rec) ? this.getWidth() : rec.width+dw; creator.setBounds(0, rec.y, width, rec.height); - creator.recalculateChildWidth(width); + creator.recalculateChildWidth(width, true); } else { XCreator leftCreator = getCreatorAt(rec.x-1, rec.y); int posX = getPosX(leftCreator); @@ -502,6 +502,7 @@ public class XWFitLayout extends XLayoutContainer { if (y==0) { int height = notHasBottomCreator(rec) ? this.getHeight() : rec.height+dh; creator.setBounds(rec.x, 0, rec.width, height); + creator.recalculateChildHeight(height, true); } else { XCreator topCreator = getCreatorAt(rec.x, rec.y-1); int posY = getPosY(topCreator); diff --git a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 9a32c3987..fa43b57fe 100644 --- a/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -260,74 +260,90 @@ public class XWCardMainBorderLayout extends XWBorderLayout { return tabLayoutList; } - /** - * 重新调整子组件的宽度 - * @param width 宽度 - */ - @Override - public void recalculateChildWidth(int width){ + /** + * 重新调整子组件的宽度 + * @param width 宽度 + * @param actualSize 是否按照实际大小计算 + */ + @Override + public void recalculateChildWidth(int width, boolean actualSize){ ArrayList childrenList = this.getTargetChildrenList(); int size = childrenList.size(); if (size > 0) { for (int j = 0; j < size; j++) { XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList .get(j); - tabLayout.setBackupBound(tabLayout.getBounds()); - int refSize = tabLayout.getWidth(); + + + Dimension d = new Dimension(tabLayout.toData().getContainerWidth(), tabLayout.toData().getContainerHeight()); + Rectangle rec = actualSize? new Rectangle(d): tabLayout.getBounds(); + // 容器大小改变时,设下backupBound为其之前的实际大小 + tabLayout.setBackupBound(rec); + int refSize = rec.width; int offest = width - refSize; double percent = (double) offest / refSize; if (percent < 0 && !tabLayout.canReduce(percent)) { return; } - tabLayout.setSize(tabLayout.getWidth() + offest, - tabLayout.getHeight()); - for (int m = 0; m < tabLayout.getComponentCount(); m++) { - XCreator childCreator = tabLayout.getXCreator(m); - BoundsWidget wgt = (BoundsWidget) tabLayout.toData() - .getBoundsWidget(childCreator.toData()); - wgt.setBounds(tabLayout.getComponent(m).getBounds()); + tabLayout.setSize(rec.width + offest, rec.height); + if(!actualSize){ + updateChildWidgetBounds(tabLayout); } tabLayout.adjustCreatorsWidth(percent); } } - } + } - /** - * 重新调整子组件的高度 - * @param height 高度 - */ - @Override - public void recalculateChildHeight(int height){ + /** + * 重新调整子组件的高度 + * @param height 高度 + * @param actualSize 是否按照实际大小计算 + */ + @Override + public void recalculateChildHeight(int height, boolean actualSize){ ArrayList childrenList = this.getTargetChildrenList(); int size = childrenList.size(); if (size > 0) { for (int j = 0; j < size; j++) { XWTabFitLayout tabLayout = (XWTabFitLayout) childrenList .get(j); - tabLayout.setBackupBound(tabLayout.getBounds()); - int refSize = tabLayout.getHeight(); + Dimension d = new Dimension(tabLayout.toData().getContainerWidth(), tabLayout.toData().getContainerHeight()); + Rectangle rec = actualSize? new Rectangle(d): tabLayout.getBounds(); + // 容器大小改变时,设下backupBound为其之前的实际大小 + tabLayout.setBackupBound(rec); + int refSize = rec.height; int offset = height - refSize - WCardMainBorderLayout.TAB_HEIGHT; - if(offset < 0){ - // 缩放时需要备份原tab布局宽高 - tabLayout.setReferDim(new Dimension(tabLayout.getWidth(),tabLayout.getHeight())); - } + if(offset < 0){ + // 缩放时需要备份原tab布局宽高 + tabLayout.setReferDim(new Dimension(rec.width, rec.height)); + } double percent = (double) offset / refSize; if (percent < 0 && !tabLayout.canReduce(percent)) { return; } - tabLayout.setSize(tabLayout.getWidth(), - tabLayout.getHeight() + offset); - for (int m = 0; m < tabLayout.getComponentCount(); m++) { - XCreator childCreator = tabLayout.getXCreator(m); - BoundsWidget wgt = (BoundsWidget) tabLayout.toData() - .getBoundsWidget(childCreator.toData()); - wgt.setBounds(tabLayout.getComponent(m).getBounds()); + tabLayout.setSize(rec.width, rec.height + offset); + if(!actualSize){ + updateChildWidgetBounds(tabLayout); } tabLayout.adjustCreatorsHeight(percent); } } - } + } + + + /** + * 更新下子组件bounds + * @param tabLayout tabFit布局 + */ + private void updateChildWidgetBounds(XWTabFitLayout tabLayout){ + for (int m = 0; m < tabLayout.getComponentCount(); m++) { + XCreator childCreator = tabLayout.getXCreator(m); + BoundsWidget wgt = (BoundsWidget) tabLayout.toData() + .getBoundsWidget(childCreator.toData()); + wgt.setBounds(tabLayout.getComponent(m).getBounds()); + } + } @Override public void paint(Graphics g) { 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 b6f3a41a6..8e0b76bec 100644 --- a/designer-form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java +++ b/designer-form/src/com/fr/design/designer/properties/FRAbsoluteBodyLayoutPropertiesGroupModel.java @@ -222,8 +222,8 @@ public class FRAbsoluteBodyLayoutPropertiesGroupModel extends FRAbsoluteLayoutPr } for (int i = 0;i < components.length;i++){ if (components[i] instanceof XWCardMainBorderLayout){ - ((XWCardMainBorderLayout)components[i]).recalculateChildWidth(components[i].getWidth()); - ((XWCardMainBorderLayout)components[i]).recalculateChildHeight(components[i].getHeight()); + ((XWCardMainBorderLayout)components[i]).recalculateChildWidth(components[i].getWidth(), false); + ((XWCardMainBorderLayout)components[i]).recalculateChildHeight(components[i].getHeight(), false); } xwFitLayout.dealDirections((XCreator)components[i], false); } diff --git a/designer-form/src/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java b/designer-form/src/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java index f895118f1..53d6de6d9 100644 --- a/designer-form/src/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java +++ b/designer-form/src/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java @@ -232,8 +232,8 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { } for (int i = 0; i < components.length; i++) { if (components[i] instanceof XWCardMainBorderLayout) { - ((XWCardMainBorderLayout) components[i]).recalculateChildWidth(components[i].getWidth()); - ((XWCardMainBorderLayout) components[i]).recalculateChildHeight(components[i].getHeight()); + ((XWCardMainBorderLayout) components[i]).recalculateChildWidth(components[i].getWidth(), false); + ((XWCardMainBorderLayout) components[i]).recalculateChildHeight(components[i].getHeight(), false); } xwFitLayout.dealDirections((XCreator) components[i], false); }