|
|
@ -15,6 +15,8 @@ import com.fr.design.mainframe.FormSelection; |
|
|
|
import com.fr.design.mainframe.FormSelectionUtils; |
|
|
|
import com.fr.design.mainframe.FormSelectionUtils; |
|
|
|
import com.fr.design.utils.ComponentUtils; |
|
|
|
import com.fr.design.utils.ComponentUtils; |
|
|
|
import com.fr.design.utils.gui.LayoutUtils; |
|
|
|
import com.fr.design.utils.gui.LayoutUtils; |
|
|
|
|
|
|
|
import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; |
|
|
|
|
|
|
|
import com.fr.form.ui.container.cardlayout.WTabFitLayout; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
import com.fr.stable.ArrayUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
@ -27,7 +29,7 @@ import java.util.ArrayList; |
|
|
|
public class SelectionModel { |
|
|
|
public class SelectionModel { |
|
|
|
//被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。
|
|
|
|
//被粘贴组件在所选组件位置处往下、往右各错开20像素。执行多次粘贴时,在上一次粘贴的位置处错开20像素。
|
|
|
|
private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
|
|
|
|
private static final int DELTA_X_Y = 20; //粘贴时候的偏移距离
|
|
|
|
private static final double OFFSET_RELATIVE = 0.80; |
|
|
|
private static final double OFFSET_RELATIVE = 0.78; |
|
|
|
private static FormSelection clipboard = new FormSelection(); |
|
|
|
private static FormSelection clipboard = new FormSelection(); |
|
|
|
private FormDesigner designer; |
|
|
|
private FormDesigner designer; |
|
|
|
private FormSelection selection; |
|
|
|
private FormSelection selection; |
|
|
@ -136,19 +138,20 @@ public class SelectionModel { |
|
|
|
if (designer.getClass().equals(FormDesigner.class)) { |
|
|
|
if (designer.getClass().equals(FormDesigner.class)) { |
|
|
|
if (selection.getSelectedCreator() instanceof XWFitLayout) { |
|
|
|
if (selection.getSelectedCreator() instanceof XWFitLayout) { |
|
|
|
if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) { |
|
|
|
if (selection.getSelectedCreator().getClass().equals(XWTabFitLayout.class)) { |
|
|
|
Rectangle rec = selection.getRelativeBounds(); |
|
|
|
XLayoutContainer container = (XLayoutContainer) selection.getSelectedCreator(); |
|
|
|
//Tab布局
|
|
|
|
//tab布局编辑器内部左上角第一个坐标点
|
|
|
|
FormSelectionUtils.paste2Container(designer, (XLayoutContainer) selection.getSelectedCreator(), |
|
|
|
int leftUpX = container.toData().getMargin().getLeft() + 1; |
|
|
|
clipboard, |
|
|
|
int leftUpY = container.toData().getMargin().getTop() + 1; |
|
|
|
rec.x + rec.width / 2, |
|
|
|
//选中第一个坐标点坐在的组件
|
|
|
|
rec.y + DELTA_X_Y); |
|
|
|
selection.setSelectedCreator((XCreator) container.getComponentAt(leftUpX, leftUpY)); |
|
|
|
|
|
|
|
pasteFromClipBoard(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Rectangle rec = selection.getRelativeBounds(); |
|
|
|
//自适应布局编辑器内部左上角第一个坐标点
|
|
|
|
//自适应布局
|
|
|
|
int leftUpX = designer.getRootComponent().toData().getMargin().getLeft() + 1; |
|
|
|
FormSelectionUtils.paste2Container(designer, designer.getRootComponent(), |
|
|
|
int leftUpY = designer.getRootComponent().toData().getMargin().getTop() + 1; |
|
|
|
clipboard, |
|
|
|
//选中第一个坐标点坐在的组件
|
|
|
|
rec.x + rec.width / 2, |
|
|
|
selection.setSelectedCreator((XCreator) designer.getRootComponent().getComponentAt(leftUpX, leftUpY)); |
|
|
|
rec.y + DELTA_X_Y); |
|
|
|
pasteFromClipBoard(); |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//绝对布局
|
|
|
|
//绝对布局
|
|
|
@ -178,12 +181,23 @@ public class SelectionModel { |
|
|
|
container = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); |
|
|
|
container = XCreatorUtils.getParentXLayoutContainer(selection.getSelectedCreator()); |
|
|
|
if (container != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) { |
|
|
|
if (container != null && selection.getSelectedCreator().getParent() instanceof XWFitLayout) { |
|
|
|
//自适应布局
|
|
|
|
//自适应布局
|
|
|
|
|
|
|
|
|
|
|
|
Rectangle selectionRec = selection.getRelativeBounds(); |
|
|
|
Rectangle selectionRec = selection.getRelativeBounds(); |
|
|
|
|
|
|
|
//获取父容器位置,补充因参数面板高度导致的位置坐标计算偏移
|
|
|
|
Rectangle containerRec = ComponentUtils.getRelativeBounds(container); |
|
|
|
Rectangle containerRec = ComponentUtils.getRelativeBounds(container); |
|
|
|
|
|
|
|
int positionX, positionY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (container.getClass().equals(XWTabFitLayout.class)) { |
|
|
|
|
|
|
|
//tab内部粘贴不补充高度偏移
|
|
|
|
|
|
|
|
//且不计算参数面板造成的影响,因为在
|
|
|
|
|
|
|
|
//@see com.fr.design.designer.beans.adapters.layout.FRTabFitLayoutAdapter#addBean中做了
|
|
|
|
|
|
|
|
positionX = selectionRec.x + selectionRec.width / 2; |
|
|
|
|
|
|
|
positionY = (int) (selectionRec.y + selectionRec.height * OFFSET_RELATIVE); |
|
|
|
|
|
|
|
} else { |
|
|
|
//计算自适应布局位置
|
|
|
|
//计算自适应布局位置
|
|
|
|
int positionX = selectionRec.x - containerRec.x + selectionRec.width / 2; |
|
|
|
positionX = selectionRec.x - containerRec.x + selectionRec.width / 2; |
|
|
|
int positionY = (int) (selectionRec.y - containerRec.y + selectionRec.height * OFFSET_RELATIVE); |
|
|
|
positionY = (int) (selectionRec.y - containerRec.y + selectionRec.height * OFFSET_RELATIVE); |
|
|
|
|
|
|
|
} |
|
|
|
FormSelectionUtils.paste2Container(designer, container, clipboard, positionX, positionY); |
|
|
|
FormSelectionUtils.paste2Container(designer, container, clipboard, positionX, positionY); |
|
|
|
} else if (container != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { |
|
|
|
} else if (container != null && selection.getSelectedCreator().getParent() instanceof XWAbsoluteLayout) { |
|
|
|
//绝对布局
|
|
|
|
//绝对布局
|
|
|
|