From e35d5ee8f7a04fd4a449af136bcbeaca286a2aac Mon Sep 17 00:00:00 2001 From: "yaoh.wu" Date: Wed, 19 Apr 2017 22:05:52 +0800 Subject: [PATCH] =?UTF-8?q?report-1945=20frm=E6=9C=AC=E5=9C=B0=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=E5=A4=8D=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/mainframe/FormSelectionUtils.java | 34 +++++++------------ 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java b/designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java index 1978e8432..b288ec202 100644 --- a/designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java +++ b/designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java @@ -25,6 +25,7 @@ public class FormSelectionUtils { //组件重命名后缀 private static final String POSTFIX = "_c"; + private FormSelectionUtils() { } @@ -132,29 +133,18 @@ public class FormSelectionUtils { XLayoutContainer container = layoutAdapter.getContainer(); boolean xOut = x < 0 || x + copiedCreator.getWidth() / 2 + xoffset > container.getWidth(); boolean yOut = y < 0 || y + copiedCreator.getHeight() / 2 + yoffset > container.getHeight(); - /* - * 组件原始位置位于布局的右下角, - * 和布局右下边界线紧挨, - * 粘贴时组件在原始位置向左错开20像素。 - * x,y同时越界 - */ - if (xOut && yOut) { - //向左偏移 - x = container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X_Y - xoffset; + + y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y; + boolean isEdge = (x - DELAY_X_Y == container.getWidth() - copiedCreator.getWidth() / 2 - xoffset); + if (xOut) { + if (isEdge) { + //向左偏移 + x = container.getWidth() - copiedCreator.getWidth() / 2 - DELAY_X_Y - xoffset; + } //紧贴下边界 - y = container.getHeight() - copiedCreator.getHeight() / 2 - yoffset; - return new Point(x, y); - } - /* - * 组件原始位置与布局边界距离小于20像素(下边界&右边界同时小于或者任意一个边界小于), - * 则粘贴时距离小于20像素一侧直接贴近布局边界, - * 距离大于20像素的一侧正常错开。 - * x,y中只有一个越界 - */ - if ((xOut || yOut)) { - x = xOut ? container.getWidth() - copiedCreator.getWidth() / 2 - xoffset : x; - y = yOut ? container.getHeight() - copiedCreator.getHeight() / 2 - yoffset : y; - return new Point(x, y); + else { + x = container.getWidth() - copiedCreator.getWidth() / 2 - xoffset; + } } } return new Point(x, y);