|
|
|
@ -12,13 +12,20 @@ import java.awt.Component;
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { |
|
|
|
|
private int minHeight; |
|
|
|
|
private FRBodyLayoutAdapter parentLayoutAdapter; |
|
|
|
|
private static final double TOP_HALF = 0.25; |
|
|
|
|
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); |
|
|
|
|
this.parentLayoutAdapter = parentLayoutAdapter; |
|
|
|
|
this.minWidth = minWidth; |
|
|
|
|
this.minHeight = minHeight; |
|
|
|
|
this.actualVal = actualVal; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -100,7 +107,33 @@ public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
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 |
|
|
|
|