|
|
|
@ -18,8 +18,6 @@ public class MoveUtils {
|
|
|
|
|
public static final int SORPTION_UNIT = 5; |
|
|
|
|
private static final int EQUIDISTANTLINE_UNIT = 4; |
|
|
|
|
|
|
|
|
|
public static WidgetForbidWindow widgetForbidWindow = new WidgetForbidWindow(); |
|
|
|
|
|
|
|
|
|
public static ArrayList<EquidistantLine> equidistantLines = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
private MoveUtils() { |
|
|
|
@ -32,9 +30,7 @@ public class MoveUtils {
|
|
|
|
|
* 获取块边界的迭代器 |
|
|
|
|
* |
|
|
|
|
* @return 块边界的迭代器 |
|
|
|
|
* |
|
|
|
|
* @date 2015-2-12-下午2:43:47 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
RectangleIterator createRectangleIterator(); |
|
|
|
|
|
|
|
|
@ -42,9 +38,7 @@ public class MoveUtils {
|
|
|
|
|
* 设置X轴的线 |
|
|
|
|
* |
|
|
|
|
* @param line 连接线 |
|
|
|
|
* |
|
|
|
|
* @date 2015-2-12-下午2:44:04 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
void setXAbsorptionline(Absorptionline line); |
|
|
|
|
|
|
|
|
@ -52,9 +46,7 @@ public class MoveUtils {
|
|
|
|
|
* 设置Y轴的线 |
|
|
|
|
* |
|
|
|
|
* @param line 连接线 |
|
|
|
|
* |
|
|
|
|
* @date 2015-2-12-下午2:44:04 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
void setYAbsorptionline(Absorptionline line); |
|
|
|
|
|
|
|
|
@ -62,7 +54,6 @@ public class MoveUtils {
|
|
|
|
|
* 获取当前选中块的垂直线数组 |
|
|
|
|
* |
|
|
|
|
* @return 块的垂直线数组 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
int[] getVerticalLine(); |
|
|
|
|
|
|
|
|
@ -70,42 +61,47 @@ public class MoveUtils {
|
|
|
|
|
* 获取当前选中块的水平线数组 |
|
|
|
|
* |
|
|
|
|
* @return 块的水平线数组 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
int[] getHorizontalLine(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置designer内部组件是否重叠的标志位 |
|
|
|
|
* |
|
|
|
|
* @param isIntersects 是否重叠 |
|
|
|
|
*/ |
|
|
|
|
void setWidgetsIntersected(boolean isIntersects); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取designer内部组件是否重叠的标志位 |
|
|
|
|
* |
|
|
|
|
* @return 重叠 |
|
|
|
|
*/ |
|
|
|
|
boolean isWidgetsIntersected(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取designer相对屏幕的位置 |
|
|
|
|
* |
|
|
|
|
* @return 位置 |
|
|
|
|
*/ |
|
|
|
|
Point getDesignerLocationOnScreen(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 设置等距线 |
|
|
|
|
* |
|
|
|
|
* @param line 吸附线 |
|
|
|
|
*/ |
|
|
|
|
void setEquidistantLine(Absorptionline line); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取设计器垂直滚动条的值 |
|
|
|
|
* |
|
|
|
|
* @return 滚动条的值 |
|
|
|
|
*/ |
|
|
|
|
int getDesignerScrollVerticalValue(); |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 获取设计器水平滚动条的值 |
|
|
|
|
* |
|
|
|
|
* @return 滚动条的值 |
|
|
|
|
*/ |
|
|
|
|
int getDesignerScrollHorizontalValue(); |
|
|
|
@ -117,9 +113,7 @@ public class MoveUtils {
|
|
|
|
|
* 是否存在下一个块 |
|
|
|
|
* |
|
|
|
|
* @return 是否存在下一个块 |
|
|
|
|
* |
|
|
|
|
* @date 2015-2-12-下午2:41:32 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
boolean hasNext(); |
|
|
|
|
|
|
|
|
@ -127,9 +121,7 @@ public class MoveUtils {
|
|
|
|
|
* 获取下一个块的bounds |
|
|
|
|
* |
|
|
|
|
* @return 下一个块的bounds |
|
|
|
|
* |
|
|
|
|
* @date 2015-2-12-下午2:41:55 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
Rectangle nextRectangle(); |
|
|
|
|
|
|
|
|
@ -137,9 +129,7 @@ public class MoveUtils {
|
|
|
|
|
* 获取块的垂直线数组 |
|
|
|
|
* |
|
|
|
|
* @return 块的垂直线数组 |
|
|
|
|
* |
|
|
|
|
* @date 2015-2-12-下午2:42:27 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
int[] getVerticalLine(); |
|
|
|
|
|
|
|
|
@ -147,9 +137,7 @@ public class MoveUtils {
|
|
|
|
|
* 获取块的水平线数组 |
|
|
|
|
* |
|
|
|
|
* @return 块的水平线数组 |
|
|
|
|
* |
|
|
|
|
* @date 2015-2-12-下午2:42:27 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
int[] getHorizontalLine(); |
|
|
|
|
} |
|
|
|
@ -259,8 +247,7 @@ public class MoveUtils {
|
|
|
|
|
equidistantLineInfo.setReference(bounds.y); |
|
|
|
|
equidistantLineInfo.setDirection(SwingConstants.BOTTOM); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else if ((leftMiddleY > bounds.getY()) && (leftMiddleY < (bounds.getY() + bounds.getHeight()))){ |
|
|
|
|
} else if ((leftMiddleY > bounds.getY()) && (leftMiddleY < (bounds.getY() + bounds.getHeight()))) { |
|
|
|
|
//当前操作rec在bounds的右侧
|
|
|
|
|
if (left > (bounds.getX() + bounds.getWidth())) { |
|
|
|
|
equidistantLineInfo.setDistance(left - (bounds.x + bounds.width)); |
|
|
|
@ -279,13 +266,6 @@ public class MoveUtils {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// public static void displayForbidWindow(int x, int y) {
|
|
|
|
|
// widgetForbidWindow.showWindow(x, y);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// public static void hideForbidWindow() {
|
|
|
|
|
// widgetForbidWindow.hideWindow();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 吸附 |
|
|
|
@ -295,11 +275,8 @@ public class MoveUtils {
|
|
|
|
|
* @param width 宽度 |
|
|
|
|
* @param height 高度 |
|
|
|
|
* @param designer 块设计器 |
|
|
|
|
* |
|
|
|
|
* @return 吸附后坐标 |
|
|
|
|
* |
|
|
|
|
* @date 2015-2-12-下午2:39:16 |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
public static Point sorption(int x, int y, int width, int height, RectangleDesigner designer, boolean isParameterLayout) { |
|
|
|
|
|
|
|
|
@ -318,25 +295,16 @@ public class MoveUtils {
|
|
|
|
|
RectangleIterator iterator = designer.createRectangleIterator(); |
|
|
|
|
|
|
|
|
|
java.util.List<Rectangle> cacheRecs = new ArrayList<Rectangle>(); |
|
|
|
|
//是否存在控件重叠
|
|
|
|
|
// boolean isWidgetsIntersects = false;
|
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
Rectangle bounds = iterator.nextRectangle(); |
|
|
|
|
cacheRecs.add(bounds); |
|
|
|
|
// boolean isIntersects = operatingRectangle.intersects(bounds);
|
|
|
|
|
findX(px, bounds, left, right, width); |
|
|
|
|
findY(py, bounds, top, bottom, height); |
|
|
|
|
|
|
|
|
|
if (!isParameterLayout) { |
|
|
|
|
// if(isIntersects) {
|
|
|
|
|
// isWidgetsIntersects = true;
|
|
|
|
|
// }
|
|
|
|
|
// else{
|
|
|
|
|
findEquidistantLine(bounds, left, top, height, width); |
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//showForbiddenWindow(designer, x, y, isWidgetsIntersects);
|
|
|
|
|
|
|
|
|
|
createXAbsorptionline(px, designer, width, cacheRecs); |
|
|
|
|
createYAbsorptionline(py, designer, height, cacheRecs); |
|
|
|
@ -353,18 +321,6 @@ public class MoveUtils {
|
|
|
|
|
return sorptionPoint; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// public static void showForbiddenWindow(RectangleDesigner designer, int x, int y, boolean isIntersects){
|
|
|
|
|
// if (isIntersects){
|
|
|
|
|
// if(designer.getDesignerLocationOnScreen() != null) {
|
|
|
|
|
// displayForbidWindow(x + designer.getDesignerLocationOnScreen().x, y + designer.getDesignerLocationOnScreen().y);
|
|
|
|
|
// }
|
|
|
|
|
// designer.setWidgetsIntersected(true);
|
|
|
|
|
// }
|
|
|
|
|
// else{
|
|
|
|
|
// designer.setWidgetsIntersected(false);
|
|
|
|
|
// hideForbidWindow();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
private static void createXAbsorptionline(PlacePointing px, RectangleDesigner designer, int width, java.util.List<Rectangle> cacheRecs) { |
|
|
|
|
Absorptionline line = null; |
|
|
|
|