From a912c11d739be389d3512a9f6afa584ad35cf659 Mon Sep 17 00:00:00 2001 From: zhouping Date: Wed, 24 Aug 2016 21:37:10 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9D=E5=AF=B9=E5=B8=83=E5=B1=80=E5=86=85?= =?UTF-8?q?=E9=83=A8=E7=BB=84=E4=BB=B6=E5=A2=9E=E5=8A=A0=E8=BE=B9=E7=BC=98?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E7=9A=84=E5=AF=B9=E9=BD=90=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/beans/location/MoveUtils.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/designer_base/src/com/fr/design/beans/location/MoveUtils.java b/designer_base/src/com/fr/design/beans/location/MoveUtils.java index fe80b463a..50179e312 100644 --- a/designer_base/src/com/fr/design/beans/location/MoveUtils.java +++ b/designer_base/src/com/fr/design/beans/location/MoveUtils.java @@ -182,6 +182,14 @@ public class MoveUtils { px.palce = x2 - width; px.direction = SwingConstants.RIGHT; } + if (Math.abs(bounds.x + bounds.width / 2 - left) <= SORPTION_UNIT) { + px.palce = bounds.x + bounds.width / 2; + px.direction = SwingConstants.LEFT; + } + if (Math.abs(bounds.x + bounds.width / 2 - right) <= SORPTION_UNIT) { + px.palce = bounds.x + bounds.width / 2 - width; + px.direction = SwingConstants.RIGHT; + } } private static void findY(PlacePointing py, Rectangle bounds, int top, int bottom, int height) { @@ -211,6 +219,14 @@ public class MoveUtils { py.palce = y2 - height; py.direction = SwingConstants.BOTTOM; } + if (Math.abs(bounds.y + bounds.height / 2 - top) <= SORPTION_UNIT) { + py.palce = bounds.y + bounds.height / 2; + py.direction = SwingConstants.TOP; + } + if (Math.abs(bounds.y + bounds.height / 2 - bottom) <= SORPTION_UNIT) { + py.palce = bounds.y + bounds.height / 2 - height; + py.direction = SwingConstants.BOTTOM; + } } private static void findEquidistantLine(Rectangle bounds, int left, int top, int height, int width) {