forked from fanruan/design
yaoh.wu
8 years ago
11 changed files with 2380 additions and 2347 deletions
File diff suppressed because it is too large
Load Diff
@ -1,346 +1,354 @@ |
|||||||
package com.fr.design.designer.beans.adapters.layout; |
package com.fr.design.designer.beans.adapters.layout; |
||||||
|
|
||||||
import com.fr.design.beans.GroupModel; |
import java.awt.*; |
||||||
import com.fr.design.designer.beans.ConstraintsGroupModel; |
|
||||||
import com.fr.design.designer.beans.HoverPainter; |
import com.fr.design.beans.GroupModel; |
||||||
import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter; |
import com.fr.design.designer.beans.ConstraintsGroupModel; |
||||||
import com.fr.design.designer.creator.*; |
import com.fr.design.designer.beans.HoverPainter; |
||||||
import com.fr.design.designer.properties.BoundsGroupModel; |
import com.fr.design.designer.beans.painters.FRAbsoluteLayoutPainter; |
||||||
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; |
import com.fr.design.designer.creator.*; |
||||||
import com.fr.design.utils.ComponentUtils; |
import com.fr.design.designer.properties.BoundsGroupModel; |
||||||
import com.fr.design.utils.gui.LayoutUtils; |
import com.fr.design.designer.properties.FRAbsoluteLayoutPropertiesGroupModel; |
||||||
import com.fr.form.ui.container.WAbsoluteLayout; |
import com.fr.form.ui.container.WAbsoluteLayout; |
||||||
import com.fr.general.ComparatorUtils; |
import com.fr.design.utils.ComponentUtils; |
||||||
import com.fr.general.FRLogger; |
import com.fr.design.utils.gui.LayoutUtils; |
||||||
|
import com.fr.general.ComparatorUtils; |
||||||
import java.awt.*; |
import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget; |
||||||
|
import com.fr.general.FRLogger; |
||||||
public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { |
|
||||||
//是不是添加到父容器上
|
public class FRAbsoluteLayoutAdapter extends FRBodyLayoutAdapter { |
||||||
private boolean isAdd2ParentLayout = false; |
//是不是添加到父容器上
|
||||||
private HoverPainter painter; |
private boolean isAdd2ParentLayout = false; |
||||||
|
private HoverPainter painter; |
||||||
public FRAbsoluteLayoutAdapter(XLayoutContainer container) { |
|
||||||
super(container); |
public FRAbsoluteLayoutAdapter(XLayoutContainer container) { |
||||||
painter = new FRAbsoluteLayoutPainter(container); |
super(container); |
||||||
initMinSize(); |
painter = new FRAbsoluteLayoutPainter(container); |
||||||
} |
initMinSize(); |
||||||
|
} |
||||||
private void initMinSize() { |
|
||||||
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; |
private void initMinSize() { |
||||||
minWidth = layout.getActualMinWidth(); |
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; |
||||||
minHeight = layout.getActualMinHeight(); |
minWidth = layout.getActualMinWidth(); |
||||||
actualVal = layout.getAcualInterval(); |
minHeight = layout.getActualMinHeight(); |
||||||
margin = layout.toData().getMargin(); |
actualVal = layout.getAcualInterval(); |
||||||
} |
margin = layout.toData().getMargin(); |
||||||
|
} |
||||||
@Override |
|
||||||
public HoverPainter getPainter() { |
@Override |
||||||
return painter; |
public HoverPainter getPainter() { |
||||||
} |
return painter; |
||||||
|
} |
||||||
/** |
|
||||||
* 是否能在指定位置添加组件 |
/** |
||||||
* |
* 是否能在指定位置添加组件 |
||||||
* @param creator 组件 |
* @param creator 组件 |
||||||
* @param x 坐标x |
* @param x 坐标x |
||||||
* @param y 坐标y |
* @param y 坐标y |
||||||
* @return 能则返回true |
* @return 能则返回true |
||||||
*/ |
*/ |
||||||
//这个地方的逻辑非常复杂,
|
//这个地方的逻辑非常复杂,
|
||||||
// 1.当前绝对布局是不可编辑且是最外层,那么其他控件添加在它周围,
|
// 1.当前绝对布局是不可编辑且是最外层,那么其他控件添加在它周围,
|
||||||
// 2.当前绝对布局是不可编辑且不是最外层,那么控件不可添加,(嵌套)
|
// 2.当前绝对布局是不可编辑且不是最外层,那么控件不可添加,(嵌套)
|
||||||
// 3.当前绝对布局可编辑,那么控件添加
|
// 3.当前绝对布局可编辑,那么控件添加
|
||||||
@Override |
@Override |
||||||
public boolean accept(XCreator creator, int x, int y) { |
public boolean accept(XCreator creator, int x, int y) { |
||||||
Component comp = container.getComponentAt(x, y); |
Component comp = container.getComponentAt(x, y); |
||||||
//布局控件要先判断是不是可编辑
|
//布局控件要先判断是不是可编辑
|
||||||
//可以编辑,按原有逻辑判断
|
//可以编辑,按原有逻辑判断
|
||||||
//不可编辑,当成一整个控件处理
|
//不可编辑,当成一整个控件处理
|
||||||
if (comp == null) { |
if (comp == null){ |
||||||
return false; |
return false; |
||||||
} |
} |
||||||
//参数面板内的组件不允许拖往绝对布局中
|
//参数面板内的组件不允许拖往绝对布局中
|
||||||
if (creator.getParent() != null && ((XCreator) creator.getParent()).acceptType(XWParameterLayout.class)) { |
if (creator.getParent() != null && ((XCreator)creator.getParent()).acceptType(XWParameterLayout.class)){ |
||||||
Rectangle rec = creator.getBounds(); |
Rectangle rec = creator.getBounds(); |
||||||
rec.y = creator.getParent().getHeight() - rec.height; |
rec.y = creator.getParent().getHeight() - rec.height; |
||||||
creator.setBounds(rec); |
creator.setBounds(rec); |
||||||
return false; |
return false; |
||||||
} |
} |
||||||
//判断组件能不能拖入绝对布局
|
//判断下组件能不能拖入绝对布局
|
||||||
if (!creator.canEnterIntoAbsolutePane()) { |
if (!creator.canEnterIntoAbsolutePane()){ |
||||||
return false; |
return false; |
||||||
} |
} |
||||||
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout(); |
XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator)comp).getTopLayout(); |
||||||
if (topLayout != null) { |
if(topLayout != null){ |
||||||
if (topLayout.isEditable()) { |
if (topLayout.isEditable()){ |
||||||
return topLayoutAccept(creator, x, y); |
return topLayoutAccept(creator, x, y, topLayout); |
||||||
} |
} |
||||||
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
|
//绝对布局嵌套,处于内层,不可编辑,不添加,topLayout只能获取到最外层可编辑的布局
|
||||||
else if (((XLayoutContainer) topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) { |
else if (((XLayoutContainer)topLayout.getParent()).acceptType(XWAbsoluteLayout.class)) { |
||||||
return false; |
return false; |
||||||
} else { |
} |
||||||
return acceptWidget(x, y); |
else { |
||||||
} |
return acceptWidget(creator, x, y); |
||||||
} else { |
} |
||||||
FRLogger.getLogger().error("top layout is null!"); |
} |
||||||
} |
else{ |
||||||
|
FRLogger.getLogger().error("top layout is null!"); |
||||||
return false; |
} |
||||||
} |
|
||||||
|
return false; |
||||||
//topLayout假如可以编辑的话就往里面添加组件
|
} |
||||||
private boolean topLayoutAccept(XCreator creator, int x, int y) { |
|
||||||
//允许组件重叠,可以不判断有没有和当前控件重叠
|
//toplayout假如可以编辑的话就往里面添加组件
|
||||||
//先计算当前控件的位置
|
private boolean topLayoutAccept(XCreator creator, int x, int y, XLayoutContainer topLayout) { |
||||||
int creatorX, creatorY; |
//判断有没有和当前控件重叠
|
||||||
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { |
//先计算当前控件的位置
|
||||||
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); |
int creatorX, creatorY; |
||||||
creatorX = creatorRectangle.x; |
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { |
||||||
creatorY = creatorRectangle.y; |
|
||||||
} else { |
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); |
||||||
//这边计算得到的组件其实位置是正确的,
|
creatorX = creatorRectangle.x; |
||||||
//因为传入的x和y已经加上了宽度或者高度的一半,再减去相同的宽度和高度的一半是没区别的,
|
creatorY = creatorRectangle.y; |
||||||
// 例如高度为21,那么就是+10-10;
|
} else { |
||||||
// 高度为20,那么就是+10-10; 没区别
|
int w = creator.getWidth() / 2; |
||||||
int w = creator.getWidth() / 2; |
int h = creator.getHeight() / 2; |
||||||
int h = creator.getHeight() / 2; |
creatorX = x - w; |
||||||
creatorX = x - w; |
creatorY = y - h; |
||||||
creatorY = y - h; |
} |
||||||
} |
//再判断和布局中其他控件重叠
|
||||||
if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) { |
Rectangle curRec = new Rectangle(creatorX, creatorY, creator.getWidth(), creator.getHeight()); |
||||||
return false; |
WAbsoluteLayout wAbsoluteLayout = (WAbsoluteLayout)topLayout.toData(); |
||||||
} |
for (int i = 0, count = wAbsoluteLayout.getWidgetCount(); i < count; i++) { |
||||||
if (creatorY < 0 || creatorY + creator.getHeight() > container.getHeight()) { |
BoundsWidget temp = (BoundsWidget) wAbsoluteLayout.getWidget(i); |
||||||
return false; |
Rectangle rectangle = temp.getBounds(); |
||||||
} |
if (curRec.intersects(rectangle)){ |
||||||
return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() |
return false; |
||||||
&& creator.getWidth() <= container.getWidth(); |
} |
||||||
} |
} |
||||||
|
if (creatorX < 0 || creatorX + creator.getWidth() > container.getWidth()) { |
||||||
/** |
return false; |
||||||
* 判断是否鼠标在组件的三等分区域,如果组件在布局管理器中间,上下左右都可能会三等分 |
} |
||||||
* |
if (creatorY < 0 || creatorY + creator.getHeight() > container.getHeight()){ |
||||||
* @param parentComp 鼠标所在区域的组件 |
return false; |
||||||
* @param x 坐标x |
} |
||||||
* @param y 坐标y |
return x >= 0 && y >= 0 && creator.getHeight() <= container.getHeight() |
||||||
* @return 是则返回true |
&& creator.getWidth() <= container.getWidth(); |
||||||
*/ |
} |
||||||
public boolean isTrisectionArea(Component parentComp, int x, int y) { |
|
||||||
XCreator creator = (XCreator) parentComp; |
/** |
||||||
trisectAreaDirect = 0; |
* 判断是否鼠标在组件的三等分区域,如果组件在布局管理器中间,上下左右都可能会三等分 |
||||||
if (container.getComponentCount() <= 1) { |
* @param parentComp 鼠标所在区域的组件 |
||||||
return false; |
* @param x 坐标x |
||||||
} |
* @param y 坐标y |
||||||
int maxWidth = parentComp.getWidth(); |
* @return 是则返回true |
||||||
int maxHeight = parentComp.getHeight(); |
*/ |
||||||
int xL = parentComp.getX(); |
public boolean isTrisectionArea(Component parentComp, int x, int y) { |
||||||
int yL = parentComp.getY(); |
XCreator creator = (XCreator)parentComp; |
||||||
// 组件宽高的十分之一和默认值取大
|
trisectAreaDirect = 0; |
||||||
int minRangeWidth = Math.max(maxWidth / BORDER_PROPORTION, DEFAULT_AREA_LENGTH); |
if (container.getComponentCount()<=1) { |
||||||
int minRangeHeight = Math.max(maxHeight / BORDER_PROPORTION, DEFAULT_AREA_LENGTH); |
return false; |
||||||
if (y < yL + minRangeHeight) { |
} |
||||||
// 在组件上侧三等分
|
int maxWidth = parentComp.getWidth(); |
||||||
trisectAreaDirect = COMP_TOP; |
int maxHeight = parentComp.getHeight(); |
||||||
} else if (y > yL + maxHeight - minRangeHeight) { |
int xL = parentComp.getX(); |
||||||
// 在组件下侧三等分
|
int yL = parentComp.getY(); |
||||||
trisectAreaDirect = COMP_BOTTOM; |
// 组件宽高的十分之一和默认值取大
|
||||||
} else if (x < xL + minRangeWidth) { |
int minRangeWidth = Math.max(maxWidth/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); |
||||||
// 在组件左侧三等分
|
int minRangeHeight = Math.max(maxHeight/BORDER_PROPORTION, DEFAULT_AREA_LENGTH); |
||||||
trisectAreaDirect = COMP_LEFT; |
if(y<yL+minRangeHeight ) { |
||||||
} else if (x > xL + maxWidth - minRangeWidth) { |
// 在组件上侧三等分
|
||||||
// 在组件右侧三等分
|
trisectAreaDirect = COMP_TOP; |
||||||
trisectAreaDirect = COMP_RIGHT; |
} else if(y>yL+maxHeight-minRangeHeight) { |
||||||
} |
// 在组件下侧三等分
|
||||||
// tab布局的边界特殊处理,不进行三等分
|
trisectAreaDirect = COMP_BOTTOM; |
||||||
if (!creator.getTargetChildrenList().isEmpty()) { |
} else if (x<xL+minRangeWidth) { |
||||||
return false; |
// 在组件左侧三等分
|
||||||
} |
trisectAreaDirect = COMP_LEFT; |
||||||
|
} else if(x>xL+maxWidth-minRangeWidth) { |
||||||
return !ComparatorUtils.equals(trisectAreaDirect, 0); |
// 在组件右侧三等分
|
||||||
} |
trisectAreaDirect = COMP_RIGHT; |
||||||
|
} |
||||||
//当前绝对布局不可编辑,就当成一个控件,组件添加在周围
|
// tab布局的边界特殊处理,不进行三等分
|
||||||
private boolean acceptWidget(int x, int y) { |
if(!creator.getTargetChildrenList().isEmpty()){ |
||||||
isFindRelatedComps = false; |
return false; |
||||||
//拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
|
} |
||||||
Component comp = container.getComponentAt(x, y); |
|
||||||
//如果当前处于边缘地带, 那么就把他贴到父容器上
|
return !ComparatorUtils.equals(trisectAreaDirect, 0); |
||||||
XLayoutContainer parent = container.findNearestFit(); |
} |
||||||
container = parent != null ? parent : container; |
|
||||||
isAdd2ParentLayout = true; |
//当前绝对布局不可编辑,就当成一个控件,组件添加在周围
|
||||||
|
private boolean acceptWidget(XCreator creator, int x, int y){ |
||||||
int componentHeight = comp.getHeight(); |
isFindRelatedComps = false; |
||||||
int componentWidth = comp.getWidth(); |
//拖入组件判断时,先判断是否为交叉点区域,其次三等分区域,再次平分区域
|
||||||
//上半部分高度
|
Component comp = container.getComponentAt(x, y); |
||||||
int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); |
boolean isMatchEdge = false; |
||||||
//下半部分高度
|
//如果当前处于边缘地带, 那么就把他贴到父容器上
|
||||||
int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); |
XLayoutContainer parent = container.findNearestFit(); |
||||||
|
container = parent != null ? parent : container; |
||||||
if (isCrossPointArea(comp, x, y)) { |
isAdd2ParentLayout = true; |
||||||
return canAcceptWhileCrossPoint(comp, x, y); |
|
||||||
} |
int componentHeight = comp.getHeight(); |
||||||
|
int componentWidth = comp.getWidth(); |
||||||
if (isTrisectionArea(comp, x, y)) { |
//上半部分高度
|
||||||
return canAcceptWhileTrisection(comp, x, y); |
int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); |
||||||
} |
//下半部分高度
|
||||||
|
int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); |
||||||
boolean horizonValid = componentWidth >= minWidth * 2 + actualVal; |
|
||||||
boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; |
if (isCrossPointArea(comp, x, y)) { |
||||||
return y > upHeight && y < downHeight ? horizonValid : verticalValid; |
return canAcceptWhileCrossPoint(comp, x, y); |
||||||
} |
} |
||||||
|
|
||||||
/** |
if (isTrisectionArea(comp, x, y)) { |
||||||
* 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 |
return canAcceptWhileTrisection(comp, x, y); |
||||||
* addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 |
} |
||||||
* |
|
||||||
* @param creator 被添加的新组件 |
boolean horizonValid = componentWidth >= minWidth * 2 + actualVal; |
||||||
* @param x 添加的位置x,该位置是相对于container的 |
boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; |
||||||
* @param y 添加的位置y,该位置是相对于container的 |
return y > upHeight && y < downHeight ? horizonValid : verticalValid; |
||||||
* @return 是否添加成功,成功返回true,否则false |
} |
||||||
*/ |
|
||||||
@Override |
/** |
||||||
public boolean addBean(XCreator creator, int x, int y) { |
* 组件的ComponentAdapter在添加组件时,如果发现布局管理器不为空,会继而调用该布局管理器的 |
||||||
Rectangle rect = ComponentUtils.getRelativeBounds(container); |
* addComp方法来完成组件的具体添加。在该方法内,布局管理器可以提供额外的功能。 |
||||||
|
* |
||||||
int posX = x + rect.x; |
* @param creator 被添加的新组件 |
||||||
int posY = y + rect.y; |
* @param x 添加的位置x,该位置是相对于container的 |
||||||
if (!accept(creator, x, y)) { |
* @param y 添加的位置y,该位置是相对于container的 |
||||||
return false; |
* @return 是否添加成功,成功返回true,否则false |
||||||
} |
*/ |
||||||
addComp(creator, posX, posY); |
@Override |
||||||
((XWidgetCreator) creator).recalculateChildrenSize(); |
public boolean addBean(XCreator creator, int x, int y) { |
||||||
return true; |
Rectangle rect = ComponentUtils.getRelativeBounds(container); |
||||||
} |
|
||||||
|
int posX = x + rect.x; |
||||||
@Override |
int posY = y + rect.y; |
||||||
protected void addComp(XCreator creator, int x, int y) { |
if (!accept(creator, x, y)) { |
||||||
if (!isAdd2ParentLayout) { |
return false; |
||||||
Rectangle r = ComponentUtils.getRelativeBounds(container); |
} |
||||||
x = x - r.x; |
addComp(creator, posX, posY); |
||||||
y = y - r.y; |
((XWidgetCreator) creator).recalculateChildrenSize(); |
||||||
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { |
return true; |
||||||
|
} |
||||||
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); |
|
||||||
x = creatorRectangle.x - r.x; |
@Override |
||||||
y = creatorRectangle.y - r.y; |
protected void addComp(XCreator creator, int x, int y) { |
||||||
} else { |
if(!isAdd2ParentLayout) { |
||||||
int w = creator.getWidth() / 2; |
Rectangle r = ComponentUtils.getRelativeBounds(container); |
||||||
int h = creator.getHeight() / 2; |
x = x - r.x; |
||||||
x = x - w; |
y = y - r.y; |
||||||
y = y - h; |
if (XCreatorUtils.getParentXLayoutContainer(creator) != null) { |
||||||
} |
|
||||||
fix(creator, x, y); |
Rectangle creatorRectangle = ComponentUtils.getRelativeBounds(creator); |
||||||
|
x = creatorRectangle.x - r.x; |
||||||
if (creator.hasTitleStyle()) { |
y = creatorRectangle.y - r.y; |
||||||
addParentCreator(creator); |
} else { |
||||||
} else { |
int w = creator.getWidth() / 2; |
||||||
container.add(creator, creator.toData().getWidgetName()); |
int h = creator.getHeight() / 2; |
||||||
} |
x = x - w; |
||||||
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; |
y = y - h; |
||||||
layout.updateBoundsWidget(creator); |
} |
||||||
updateCreatorBackBound(); |
fix(creator, x, y); |
||||||
LayoutUtils.layoutRootContainer(container); |
|
||||||
} else { |
if (creator.hasTitleStyle()) { |
||||||
fixAbsolute(creator, x, y); |
addParentCreator(creator); |
||||||
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { |
} else { |
||||||
addParentCreator(creator); |
container.add(creator, creator.toData().getWidgetName()); |
||||||
} else { |
} |
||||||
container.add(creator, creator.toData().getWidgetName()); |
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; |
||||||
} |
layout.updateBoundsWidget(creator); |
||||||
XWFitLayout layout = (XWFitLayout) container; |
updateCreatorBackBound(); |
||||||
// 更新对应的BoundsWidget
|
LayoutUtils.layoutRootContainer(container); |
||||||
layout.updateBoundsWidget(); |
}else{ |
||||||
updateCreatorBackBound(); |
fixAbsolute(creator, x, y); |
||||||
} |
if (creator.shouldScaleCreator() || creator.hasTitleStyle()) { |
||||||
} |
addParentCreator(creator); |
||||||
|
} else { |
||||||
private void updateCreatorBackBound() { |
container.add(creator, creator.toData().getWidgetName()); |
||||||
for (int i = 0, size = container.getComponentCount(); i < size; i++) { |
} |
||||||
XCreator creator = (XCreator) container.getComponent(i); |
XWFitLayout layout = (XWFitLayout) container; |
||||||
creator.updateChildBound(minHeight); |
// 更新对应的BoundsWidget
|
||||||
creator.setBackupBound(creator.getBounds()); |
layout.updateBoundsWidget(); |
||||||
} |
updateCreatorBackBound(); |
||||||
} |
} |
||||||
|
} |
||||||
private void addParentCreator(XCreator child) { |
|
||||||
XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight()); |
private void updateCreatorBackBound() { |
||||||
container.add(parentPanel, child.toData().getWidgetName()); |
for (int i=0,size=container.getComponentCount(); i<size; i++) { |
||||||
} |
XCreator creator = (XCreator) container.getComponent(i); |
||||||
|
creator.updateChildBound(minHeight); |
||||||
/** |
creator.setBackupBound(creator.getBounds()); |
||||||
* 新拖入组件时,计算调整其他关联组件位置大小 |
} |
||||||
* |
} |
||||||
* @param child 新拖入的组件 |
|
||||||
* @param x 鼠标所在x坐标 |
private void addParentCreator(XCreator child) { |
||||||
* @param y 鼠标所在y坐标 |
XLayoutContainer parentPanel = child.initCreatorWrapper(child.getHeight()); |
||||||
*/ |
container.add(parentPanel, child.toData().getWidgetName()); |
||||||
private void fixAbsolute(XCreator child, int x, int y) { |
} |
||||||
Component parentComp = container.getComponentAt(x, y); |
|
||||||
if (container.getComponentCount() == 0) { |
/** |
||||||
child.setLocation(0, 0); |
* 新拖入组件时,计算调整其他关联组件位置大小 |
||||||
child.setSize(parentComp.getWidth(), parentComp.getHeight()); |
* @param child 新拖入的组件 |
||||||
} else if (isCrossPointArea(parentComp, x, y)) { |
* @param x 鼠标所在x坐标 |
||||||
//交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入
|
* @param y 鼠标所在y坐标 |
||||||
fixCrossPointArea(parentComp, child, x, y); |
*/ |
||||||
return; |
private void fixAbsolute(XCreator child, int x, int y) { |
||||||
} else if (isTrisectionArea(parentComp, x, y)) { |
Component parentComp = container.getComponentAt(x, y); |
||||||
// 在边界三等分区域,就不再和组件二等分了
|
if (container.getComponentCount()==0){ |
||||||
fixTrisect(parentComp, child, x, y); |
child.setLocation(0, 0); |
||||||
return; |
child.setSize(parentComp.getWidth(), parentComp.getHeight()); |
||||||
} else { |
} else if(isCrossPointArea(parentComp, x, y)){ |
||||||
fixHalve(parentComp, child, x, y); |
//交叉区域插入组件时,根据具体位置进行上下或者左右或者相邻三个组件的位置大小插入
|
||||||
} |
fixCrossPointArea(parentComp, child, x, y); |
||||||
} |
return; |
||||||
|
} else if (isTrisectionArea(parentComp, x, y)) { |
||||||
/** |
// 在边界三等分区域,就不再和组件二等分了
|
||||||
* 组件拖拽后调整大小 |
fixTrisect(parentComp, child, x, y); |
||||||
* |
return; |
||||||
* @param creator 组件 |
} else{ |
||||||
*/ |
fixHalve(parentComp, child, x, y); |
||||||
@Override |
} |
||||||
public void fix(XCreator creator) { |
} |
||||||
WAbsoluteLayout wabs = (WAbsoluteLayout) container.toData(); |
|
||||||
fix(creator, creator.getX(), creator.getY()); |
/** |
||||||
wabs.setBounds(creator.toData(), creator.getBounds()); |
* 组件拖拽后调整大小 |
||||||
|
* @param creator 组件 |
||||||
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; |
*/ |
||||||
layout.updateBoundsWidget(creator); |
@Override |
||||||
} |
public void fix(XCreator creator) { |
||||||
|
WAbsoluteLayout wabs = (WAbsoluteLayout)container.toData(); |
||||||
/** |
fix(creator,creator.getX(),creator.getY()); |
||||||
* 调整组件大小到合适尺寸位置 |
wabs.setBounds(creator.toData(),creator.getBounds()); |
||||||
* |
|
||||||
* @param creator 组件 |
XWAbsoluteLayout layout = (XWAbsoluteLayout) container; |
||||||
* @param x 坐标x |
layout.updateBoundsWidget(creator); |
||||||
* @param y 坐标y |
} |
||||||
*/ |
|
||||||
public void fix(XCreator creator, int x, int y) { |
/** |
||||||
int height = creator.getHeight(); |
* 调整组件大小到合适尺寸位置 |
||||||
int width = creator.getWidth(); |
* @param creator 组件 |
||||||
if (x < 0) { |
* @param x 坐标x |
||||||
x = container.getX(); |
* @param y 坐标y |
||||||
} else if (x + creator.getWidth() > container.getWidth()) { |
*/ |
||||||
x = container.getWidth() - width; |
public void fix(XCreator creator ,int x, int y) { |
||||||
} |
int height = creator.getHeight(); |
||||||
|
int width = creator.getWidth(); |
||||||
if (y < 0) { |
if (x < 0) { |
||||||
y = container.getY(); |
width += x; |
||||||
} else if (y + creator.getHeight() > container.getHeight()) { |
x = 0; |
||||||
y = container.getHeight() - height; |
} else if (x + creator.getWidth() > container.getWidth()) { |
||||||
} |
width = container.getWidth() - x; |
||||||
|
} |
||||||
creator.setBounds(x, y, width, height); |
|
||||||
} |
if (y < 0) { |
||||||
|
height += y; |
||||||
@Override |
y = 0; |
||||||
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { |
} else if (y + creator.getHeight() > container.getHeight()) { |
||||||
return new BoundsGroupModel((XWAbsoluteLayout) container, creator); |
height = container.getHeight() - y; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
creator.setBounds(x, y, width, height); |
||||||
public GroupModel getLayoutProperties() { |
} |
||||||
XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) container; |
|
||||||
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout); |
@Override |
||||||
} |
public ConstraintsGroupModel getLayoutConstraints(XCreator creator) { |
||||||
|
return new BoundsGroupModel((XWAbsoluteLayout)container, creator); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public GroupModel getLayoutProperties() { |
||||||
|
XWAbsoluteLayout xwAbsoluteLayout = (XWAbsoluteLayout) container; |
||||||
|
return new FRAbsoluteLayoutPropertiesGroupModel(xwAbsoluteLayout); |
||||||
|
} |
||||||
} |
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue