|
|
@ -12,13 +12,20 @@ import java.awt.Component; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
|
|
public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { |
|
|
|
public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { |
|
|
|
private int minHeight; |
|
|
|
private static final double TOP_HALF = 0.25; |
|
|
|
private FRBodyLayoutAdapter parentLayoutAdapter; |
|
|
|
private static final double BOTTOM_HALF = 0.75; |
|
|
|
|
|
|
|
private final int minWidth; |
|
|
|
|
|
|
|
private final int minHeight; |
|
|
|
|
|
|
|
private final int actualVal; |
|
|
|
|
|
|
|
private final FRBodyLayoutAdapter parentLayoutAdapter; |
|
|
|
|
|
|
|
|
|
|
|
public FRNoFixLayoutAdapter(FRBodyLayoutAdapter parentLayoutAdapter, XLayoutContainer container, int minHeight) { |
|
|
|
|
|
|
|
|
|
|
|
public FRNoFixLayoutAdapter(FRBodyLayoutAdapter parentLayoutAdapter, XLayoutContainer container, int minWidth, int minHeight, int actualVal) { |
|
|
|
super(container); |
|
|
|
super(container); |
|
|
|
this.parentLayoutAdapter = parentLayoutAdapter; |
|
|
|
this.parentLayoutAdapter = parentLayoutAdapter; |
|
|
|
|
|
|
|
this.minWidth = minWidth; |
|
|
|
this.minHeight = minHeight; |
|
|
|
this.minHeight = minHeight; |
|
|
|
|
|
|
|
this.actualVal = actualVal; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -79,7 +86,7 @@ public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { |
|
|
|
public void delete(XCreator creator, int creatorWidth, int creatorHeight) { |
|
|
|
public void delete(XCreator creator, int creatorWidth, int creatorHeight) { |
|
|
|
int x = creator.getX(); |
|
|
|
int x = creator.getX(); |
|
|
|
int y = creator.getY(); |
|
|
|
int y = creator.getY(); |
|
|
|
((FRFitLayoutAdapter)parentLayoutAdapter).recalculateChildrenSize(x, y, creatorWidth, creatorHeight, true); |
|
|
|
((FRFitLayoutAdapter) parentLayoutAdapter).recalculateChildrenSize(x, y, creatorWidth, creatorHeight, true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -100,7 +107,33 @@ public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean accept(XCreator creator, int x, int y) { |
|
|
|
public boolean accept(XCreator creator, int x, int y) { |
|
|
|
return true; |
|
|
|
Component comp = container.getComponentAt(x, y); |
|
|
|
|
|
|
|
if (comp == null || checkInterval(comp)) { |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int componentHeight = comp.getHeight(); |
|
|
|
|
|
|
|
int componentWidth = comp.getWidth(); |
|
|
|
|
|
|
|
//上半部分高度
|
|
|
|
|
|
|
|
int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); |
|
|
|
|
|
|
|
//下半部分高度
|
|
|
|
|
|
|
|
int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (parentLayoutAdapter.isCrossPointArea(comp, x, y)) { |
|
|
|
|
|
|
|
return parentLayoutAdapter.canAcceptWhileCrossPoint(comp, x, y); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (parentLayoutAdapter.isTrisectionArea(comp, x, y)) { |
|
|
|
|
|
|
|
return parentLayoutAdapter.canAcceptWhileTrisection(comp, x, y); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
boolean horizonValid = componentWidth >= minWidth * 2 + actualVal; |
|
|
|
|
|
|
|
boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; |
|
|
|
|
|
|
|
return y > upHeight && y < downHeight ? horizonValid : verticalValid; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 间隔区域
|
|
|
|
|
|
|
|
private boolean checkInterval(Component comp) { |
|
|
|
|
|
|
|
return container.getComponentCount() > 0 && comp == container; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|