|
|
@ -1,30 +1,21 @@ |
|
|
|
package com.fr.design.designer.beans.models; |
|
|
|
package com.fr.design.designer.beans.models; |
|
|
|
|
|
|
|
|
|
|
|
import java.awt.Component; |
|
|
|
|
|
|
|
import java.awt.Cursor; |
|
|
|
|
|
|
|
import java.awt.Graphics; |
|
|
|
|
|
|
|
import java.awt.Point; |
|
|
|
|
|
|
|
import java.awt.Rectangle; |
|
|
|
|
|
|
|
import java.awt.Toolkit; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.beans.location.Absorptionline; |
|
|
|
import com.fr.design.beans.location.Absorptionline; |
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
|
|
|
|
import com.fr.design.mainframe.FormSelectionUtils; |
|
|
|
|
|
|
|
import com.fr.design.designer.beans.AdapterBus; |
|
|
|
import com.fr.design.designer.beans.AdapterBus; |
|
|
|
import com.fr.design.designer.beans.HoverPainter; |
|
|
|
import com.fr.design.designer.beans.HoverPainter; |
|
|
|
import com.fr.design.designer.beans.LayoutAdapter; |
|
|
|
import com.fr.design.designer.beans.LayoutAdapter; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEvent; |
|
|
|
import com.fr.design.designer.beans.events.DesignerEvent; |
|
|
|
import com.fr.design.designer.beans.location.Direction; |
|
|
|
import com.fr.design.designer.beans.location.Direction; |
|
|
|
import com.fr.design.designer.beans.location.Location; |
|
|
|
import com.fr.design.designer.beans.location.Location; |
|
|
|
import com.fr.design.designer.creator.XConnector; |
|
|
|
import com.fr.design.designer.creator.*; |
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
import com.fr.design.mainframe.FormDesigner; |
|
|
|
import com.fr.design.designer.creator.XCreatorUtils; |
|
|
|
import com.fr.design.mainframe.FormSelectionUtils; |
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.XWAbsoluteLayout; |
|
|
|
|
|
|
|
import com.fr.design.utils.ComponentUtils; |
|
|
|
import com.fr.design.utils.ComponentUtils; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 普通模式下的状态model |
|
|
|
* 普通模式下的状态model |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -36,8 +27,11 @@ public class StateModel { |
|
|
|
private Direction driection; |
|
|
|
private Direction driection; |
|
|
|
|
|
|
|
|
|
|
|
// 当前拖拽的起始位置
|
|
|
|
// 当前拖拽的起始位置
|
|
|
|
private int current_x; |
|
|
|
private int currentX; |
|
|
|
private int current_y; |
|
|
|
private int currentY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//拖拽组件原始位置大小备份
|
|
|
|
|
|
|
|
private Rectangle selectedPositionBackup; |
|
|
|
|
|
|
|
|
|
|
|
private Point startPoint = new Point(); |
|
|
|
private Point startPoint = new Point(); |
|
|
|
private Point currentPoint = new Point(); |
|
|
|
private Point currentPoint = new Point(); |
|
|
@ -62,6 +56,7 @@ public class StateModel { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 返回direction |
|
|
|
* 返回direction |
|
|
|
|
|
|
|
* |
|
|
|
* @return direction方向 |
|
|
|
* @return direction方向 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Direction getDirection() { |
|
|
|
public Direction getDirection() { |
|
|
@ -78,7 +73,8 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*是否能拖拽 |
|
|
|
* 是否能拖拽 |
|
|
|
|
|
|
|
* |
|
|
|
* @return 非outer且选中为空 |
|
|
|
* @return 非outer且选中为空 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean dragable() { |
|
|
|
public boolean dragable() { |
|
|
@ -118,22 +114,35 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean addBean(XLayoutContainer container, int x, int y) { |
|
|
|
/** |
|
|
|
|
|
|
|
* @param container 容器 |
|
|
|
|
|
|
|
* @param mouseX 鼠标释放位置X |
|
|
|
|
|
|
|
* @param mouseY 鼠标释放位置Y |
|
|
|
|
|
|
|
* @return 是否成功 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private boolean addBean(XLayoutContainer container, int mouseX, int mouseY) { |
|
|
|
LayoutAdapter adapter = container.getLayoutAdapter(); |
|
|
|
LayoutAdapter adapter = container.getLayoutAdapter(); |
|
|
|
Rectangle r = ComponentUtils.getRelativeBounds(container); |
|
|
|
Rectangle rectangleContainer = ComponentUtils.getRelativeBounds(container); |
|
|
|
if (selectionModel.getSelection().size() == 1) { |
|
|
|
if (selectionModel.getSelection().size() == 1) { |
|
|
|
return adapter.addBean(selectionModel.getSelection().getSelectedCreator(), x |
|
|
|
return adapter.addBean(selectionModel.getSelection().getSelectedCreator(), |
|
|
|
+ designer.getArea().getHorizontalValue() - r.x, y + designer.getArea().getVerticalValue() - r.y); |
|
|
|
mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x, |
|
|
|
|
|
|
|
mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y); |
|
|
|
} |
|
|
|
} |
|
|
|
for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { |
|
|
|
for (XCreator creator : selectionModel.getSelection().getSelectedCreators()) { |
|
|
|
adapter.addBean(creator, x + designer.getArea().getHorizontalValue() - r.x, y + designer.getArea().getVerticalValue()- r.y); |
|
|
|
adapter.addBean(creator, |
|
|
|
|
|
|
|
mouseX + designer.getArea().getHorizontalValue() - rectangleContainer.x, |
|
|
|
|
|
|
|
mouseY + designer.getArea().getVerticalValue() - rectangleContainer.y); |
|
|
|
} |
|
|
|
} |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void adding(int x, int y) { |
|
|
|
/** |
|
|
|
|
|
|
|
* @param mouseReleasedX 鼠标释放位置X |
|
|
|
|
|
|
|
* @param mouseReleasedY 鼠标释放位置Y |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void adding(int mouseReleasedX, int mouseReleasedY) { |
|
|
|
// 当前鼠标所在的组件
|
|
|
|
// 当前鼠标所在的组件
|
|
|
|
XCreator hoveredComponent = designer.getComponentAt(x, y, selectionModel.getSelection().getSelectedCreators()); |
|
|
|
XCreator hoveredComponent = designer.getComponentAt(mouseReleasedX, mouseReleasedY, selectionModel.getSelection().getSelectedCreators()); |
|
|
|
|
|
|
|
|
|
|
|
// 获取该组件所在的焦点容器
|
|
|
|
// 获取该组件所在的焦点容器
|
|
|
|
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); |
|
|
|
XLayoutContainer container = XCreatorUtils.getHotspotContainer(hoveredComponent); |
|
|
@ -142,7 +151,7 @@ public class StateModel { |
|
|
|
|
|
|
|
|
|
|
|
if (container != null) { |
|
|
|
if (container != null) { |
|
|
|
// 如果是容器,则调用其acceptComponent接受组件
|
|
|
|
// 如果是容器,则调用其acceptComponent接受组件
|
|
|
|
success = addBean(container, x, y); |
|
|
|
success = addBean(container, mouseReleasedX, mouseReleasedY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (success) { |
|
|
|
if (success) { |
|
|
@ -150,15 +159,16 @@ public class StateModel { |
|
|
|
designer.getEditListenerTable().fireCreatorModified( |
|
|
|
designer.getEditListenerTable().fireCreatorModified( |
|
|
|
selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED); |
|
|
|
selectionModel.getSelection().getSelectedCreator(), DesignerEvent.CREATOR_ADDED); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
selectionModel.getSelection().setSelectionBounds(selectedPositionBackup, designer); |
|
|
|
Toolkit.getDefaultToolkit().beep(); |
|
|
|
Toolkit.getDefaultToolkit().beep(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 取消提示
|
|
|
|
// 取消提示
|
|
|
|
designer.setPainter(null); |
|
|
|
designer.setPainter(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*是否拖拽 |
|
|
|
* 是否拖拽 |
|
|
|
|
|
|
|
* |
|
|
|
* @return dragging状态 |
|
|
|
* @return dragging状态 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isDragging() { |
|
|
|
public boolean isDragging() { |
|
|
@ -166,7 +176,8 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*是否可以开始画线 |
|
|
|
* 是否可以开始画线 |
|
|
|
|
|
|
|
* |
|
|
|
* @return startPoint不为空返回true |
|
|
|
* @return startPoint不为空返回true |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean prepareForDrawLining() { |
|
|
|
public boolean prepareForDrawLining() { |
|
|
@ -174,7 +185,8 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*设置开始位置 |
|
|
|
* 设置开始位置 |
|
|
|
|
|
|
|
* |
|
|
|
* @param p point位置 |
|
|
|
* @param p point位置 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setStartPoint(Point p) { |
|
|
|
public void setStartPoint(Point p) { |
|
|
@ -182,7 +194,8 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*返回开始位置 |
|
|
|
* 返回开始位置 |
|
|
|
|
|
|
|
* |
|
|
|
* @return 点位置 |
|
|
|
* @return 点位置 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Point getStartPoint() { |
|
|
|
public Point getStartPoint() { |
|
|
@ -190,7 +203,8 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*返回当前点位置 |
|
|
|
* 返回当前点位置 |
|
|
|
|
|
|
|
* |
|
|
|
* @return 点位置 |
|
|
|
* @return 点位置 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public Point getEndPoint() { |
|
|
|
public Point getEndPoint() { |
|
|
@ -198,35 +212,38 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*当前选中组件 |
|
|
|
* 当前选中组件 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void startSelecting(MouseEvent e) { |
|
|
|
public void startSelecting(MouseEvent e) { |
|
|
|
selecting = true; |
|
|
|
selecting = true; |
|
|
|
selectionModel.setHotspotBounds(new Rectangle()); |
|
|
|
selectionModel.setHotspotBounds(new Rectangle()); |
|
|
|
current_x = getMouseXY(e).x; |
|
|
|
currentX = getMouseXY(e).x; |
|
|
|
current_y = getMouseXY(e).y; |
|
|
|
currentY = getMouseXY(e).y; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*当前鼠标的xy |
|
|
|
* 当前鼠标的xy |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void startResizing(MouseEvent e) { |
|
|
|
public void startResizing(MouseEvent e) { |
|
|
|
if (!selectionModel.getSelection().isEmpty()) { |
|
|
|
if (!selectionModel.getSelection().isEmpty()) { |
|
|
|
driection.backupBounds(designer); |
|
|
|
driection.backupBounds(designer); |
|
|
|
} |
|
|
|
} |
|
|
|
current_x = getMouseXY(e).x; |
|
|
|
currentX = getMouseXY(e).x; |
|
|
|
current_y = getMouseXY(e).y; |
|
|
|
currentY = getMouseXY(e).y; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*起始点开始DrawLine |
|
|
|
* 起始点开始DrawLine |
|
|
|
|
|
|
|
* |
|
|
|
* @param p 点位置 |
|
|
|
* @param p 点位置 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void startDrawLine(Point p) { |
|
|
|
public void startDrawLine(Point p) { |
|
|
|
this.startPoint = p; |
|
|
|
this.startPoint = p; |
|
|
|
if(p != null) { |
|
|
|
if (p != null) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
designer.setCursor(XConnector.connectorCursor); |
|
|
|
designer.setCursor(XConnector.connectorCursor); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -237,7 +254,8 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*鼠标释放时所在的区域及圈中的组件 |
|
|
|
* 鼠标释放时所在的区域及圈中的组件 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void selectCreators(MouseEvent e) { |
|
|
|
public void selectCreators(MouseEvent e) { |
|
|
@ -246,14 +264,15 @@ public class StateModel { |
|
|
|
|
|
|
|
|
|
|
|
Rectangle bounds = createCurrentBounds(x, y); |
|
|
|
Rectangle bounds = createCurrentBounds(x, y); |
|
|
|
|
|
|
|
|
|
|
|
if ((x != current_x) || (y != current_y)) { |
|
|
|
if ((x != currentX) || (y != currentY)) { |
|
|
|
selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent())); |
|
|
|
selectionModel.setSelectedCreators(getHotspotCreators(bounds, designer.getRootComponent())); |
|
|
|
} |
|
|
|
} |
|
|
|
selectionModel.setHotspotBounds(null); |
|
|
|
selectionModel.setHotspotBounds(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*画所在区域线 |
|
|
|
* 画所在区域线 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void drawLine(MouseEvent e) { |
|
|
|
public void drawLine(MouseEvent e) { |
|
|
@ -270,16 +289,16 @@ public class StateModel { |
|
|
|
private Rectangle createCurrentBounds(int x, int y) { |
|
|
|
private Rectangle createCurrentBounds(int x, int y) { |
|
|
|
Rectangle bounds = new Rectangle(); |
|
|
|
Rectangle bounds = new Rectangle(); |
|
|
|
|
|
|
|
|
|
|
|
bounds.x = Math.min(x, current_x); |
|
|
|
bounds.x = Math.min(x, currentX); |
|
|
|
bounds.y = Math.min(y, current_y); |
|
|
|
bounds.y = Math.min(y, currentY); |
|
|
|
bounds.width = Math.max(x, current_x) - bounds.x; |
|
|
|
bounds.width = Math.max(x, currentX) - bounds.x; |
|
|
|
bounds.height = Math.max(y, current_y) - bounds.y; |
|
|
|
bounds.height = Math.max(y, currentY) - bounds.y; |
|
|
|
|
|
|
|
|
|
|
|
return bounds; |
|
|
|
return bounds; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ArrayList<XCreator> getHotspotCreators(Rectangle selection, XCreator root) { |
|
|
|
private ArrayList<XCreator> getHotspotCreators(Rectangle selection, XCreator root) { |
|
|
|
ArrayList<XCreator> creators = new ArrayList<XCreator>(); |
|
|
|
ArrayList<XCreator> creators = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
if (!root.isVisible() && !designer.isRoot(root)) { |
|
|
|
if (!root.isVisible() && !designer.isRoot(root)) { |
|
|
|
return creators; |
|
|
|
return creators; |
|
|
@ -308,7 +327,7 @@ public class StateModel { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*重置model |
|
|
|
* 重置model |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void resetModel() { |
|
|
|
public void resetModel() { |
|
|
|
dragging = false; |
|
|
|
dragging = false; |
|
|
@ -316,7 +335,7 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*重置 |
|
|
|
* 重置 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void reset() { |
|
|
|
public void reset() { |
|
|
|
driection = Location.outer; |
|
|
|
driection = Location.outer; |
|
|
@ -325,7 +344,7 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*取消拖拽 |
|
|
|
* 取消拖拽 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void draggingCancel() { |
|
|
|
public void draggingCancel() { |
|
|
|
designer.repaint(); |
|
|
|
designer.repaint(); |
|
|
@ -333,18 +352,20 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*设置可拉伸方向 |
|
|
|
* 设置可拉伸方向 |
|
|
|
|
|
|
|
* |
|
|
|
* @param dir 拉伸方向 |
|
|
|
* @param dir 拉伸方向 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setDirection(Direction dir) { |
|
|
|
public void setDirection(Direction dir) { |
|
|
|
if(driection != dir) { |
|
|
|
if (driection != dir) { |
|
|
|
this.driection = dir; |
|
|
|
this.driection = dir; |
|
|
|
driection.updateCursor(designer); |
|
|
|
driection.updateCursor(designer); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*x吸附线赋值 |
|
|
|
* x吸附线赋值 |
|
|
|
|
|
|
|
* |
|
|
|
* @param line 线 |
|
|
|
* @param line 线 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setXAbsorptionline(Absorptionline line) { |
|
|
|
public void setXAbsorptionline(Absorptionline line) { |
|
|
@ -352,7 +373,8 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*y吸附线赋值 |
|
|
|
* y吸附线赋值 |
|
|
|
|
|
|
|
* |
|
|
|
* @param line 线 |
|
|
|
* @param line 线 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setYAbsorptionline(Absorptionline line) { |
|
|
|
public void setYAbsorptionline(Absorptionline line) { |
|
|
@ -361,41 +383,48 @@ public class StateModel { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 等距线赋值 |
|
|
|
* 等距线赋值 |
|
|
|
|
|
|
|
* |
|
|
|
* @param line 线 |
|
|
|
* @param line 线 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void setEquidistantLine(Absorptionline line){ |
|
|
|
public void setEquidistantLine(Absorptionline line) { |
|
|
|
this.lineEquidistant = line; |
|
|
|
this.lineEquidistant = line; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*画吸附线 |
|
|
|
* 画吸附线 |
|
|
|
|
|
|
|
* |
|
|
|
* @param g Graphics类 |
|
|
|
* @param g Graphics类 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void paintAbsorptionline(Graphics g) { |
|
|
|
public void paintAbsorptionline(Graphics g) { |
|
|
|
if(lineInX != null) { |
|
|
|
if (lineInX != null) { |
|
|
|
lineInX.paint(g,designer.getArea()); |
|
|
|
lineInX.paint(g, designer.getArea()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(lineInY != null) { |
|
|
|
if (lineInY != null) { |
|
|
|
lineInY.paint(g,designer.getArea()); |
|
|
|
lineInY.paint(g, designer.getArea()); |
|
|
|
} |
|
|
|
} |
|
|
|
if(lineEquidistant != null){ |
|
|
|
if (lineEquidistant != null) { |
|
|
|
lineEquidistant.paint(g,designer.getArea()); |
|
|
|
lineEquidistant.paint(g, designer.getArea()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*拖拽 |
|
|
|
* 拖拽 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void dragging(MouseEvent e) { |
|
|
|
public void dragging(MouseEvent e) { |
|
|
|
|
|
|
|
//进入dragging状态时备份组件大小和位置
|
|
|
|
|
|
|
|
if (!dragging) { |
|
|
|
|
|
|
|
selectedPositionBackup = selectionModel.getSelection().getRelativeBounds(); |
|
|
|
|
|
|
|
} |
|
|
|
checkAddable(e); |
|
|
|
checkAddable(e); |
|
|
|
setDependLinePainter(e); |
|
|
|
setDependLinePainter(e); |
|
|
|
driection.drag(getMouseXY(e).x-current_x, getMouseXY(e).y-current_y, designer); |
|
|
|
driection.drag(getMouseXY(e).x - currentX, getMouseXY(e).y - currentY, designer); |
|
|
|
this.dragging = true; |
|
|
|
this.dragging = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 拖拽时画依附线用到的painter
|
|
|
|
// 拖拽时画依附线用到的painter
|
|
|
|
private void setDependLinePainter(MouseEvent e){ |
|
|
|
private void setDependLinePainter(MouseEvent e) { |
|
|
|
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); |
|
|
|
XCreator comp = designer.getComponentAt(e.getX(), e.getY(), selectionModel.getSelection().getSelectedCreators()); |
|
|
|
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); |
|
|
|
XLayoutContainer container = XCreatorUtils.getHotspotContainer(comp); |
|
|
|
XCreator creator = selectionModel.getSelection().getSelectedCreator(); |
|
|
|
XCreator creator = selectionModel.getSelection().getSelectedCreator(); |
|
|
@ -408,7 +437,8 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*释放捕获 |
|
|
|
* 释放捕获 |
|
|
|
|
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void releaseDragging(MouseEvent e) { |
|
|
|
public void releaseDragging(MouseEvent e) { |
|
|
@ -422,7 +452,7 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*改变选择区域 |
|
|
|
* 改变选择区域 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -432,7 +462,7 @@ public class StateModel { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*返回鼠标所在的x、y 考虑滚动条的值 |
|
|
|
* 返回鼠标所在的x、y 考虑滚动条的值 |
|
|
|
* |
|
|
|
* |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @param e 鼠标事件 |
|
|
|
* @return xy值 |
|
|
|
* @return xy值 |
|
|
|