Browse Source

组件复用边界复制

master
yaoh.wu 8 years ago
parent
commit
c86cfd1c1b
  1. 33
      designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java

33
designer_form/src/com/fr/design/mainframe/FormSelectionUtils.java

@ -132,29 +132,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);

Loading…
Cancel
Save