diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java index a933f3948..63d75449d 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/ECReportPreviewPane.java @@ -49,7 +49,7 @@ public class ECReportPreviewPane extends UINoOpaquePanel implements ThemePreview public PreviewPane() { this.setPreferredSize(new Dimension(517, 270)); - this.setBorder(BorderFactory.createEmptyBorder(7, 10, 5, 10)); + this.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10)); this.setLayout(FRGUIPaneFactory.createBorderLayout()); JPanel northPane = createNorthPane(); diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java index 84013aadf..d17e9689e 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRFitLayoutAdapter.java @@ -68,7 +68,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { public FRFitLayoutAdapter(XLayoutContainer container) { super(container); initMinSize(); - this.frLayoutState = new FRNoFixLayoutAdapter(this, container, minHeight); + this.frLayoutState = new FRNoFixLayoutAdapter(this, container, minWidth, minHeight, actualVal); painter = this.frLayoutState.getPainter(); } @@ -151,13 +151,6 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { //如果当前处于边缘地带, 那么就把他贴到父容器上 boolean isMatchEdge = matchEdge(x, y); - int componentHeight = comp.getHeight(); - int componentWidth = comp.getWidth(); - //上半部分高度 - int upHeight = (int) (componentHeight * TOP_HALF) + comp.getY(); - //下半部分高度 - int downHeight = (int) (componentHeight * BOTTOM_HALF) + comp.getY(); - //布局控件要先判断是不是可编辑 XLayoutContainer topLayout = XCreatorUtils.getHotspotContainer((XCreator) comp).getTopLayout(); boolean access = topLayout != null && !isMatchEdge && !topLayout.acceptType(XWAbsoluteLayout.class) && !isExtraContainer(comp) && !topLayout.isDragInAble(); @@ -167,17 +160,7 @@ public class FRFitLayoutAdapter extends FRBodyLayoutAdapter { return false; } - if (isCrossPointArea(comp, x, y)) { - return canAcceptWhileCrossPoint(comp, x, y); - } - - if (isTrisectionArea(comp, x, y)) { - return canAcceptWhileTrisection(comp, x, y); - } - - boolean horizonValid = componentWidth >= minWidth * 2 + actualVal; - boolean verticalValid = componentHeight >= minHeight * 2 + actualVal; - return y > upHeight && y < downHeight ? horizonValid : verticalValid; + return this.frLayoutState.accept(creator, x, y); } private boolean isExtraContainer(Component comp) { diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java index bdf67e00e..aaeedfc8d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/adapters/layout/FRNoFixLayoutAdapter.java @@ -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 @@ -79,7 +86,7 @@ public class FRNoFixLayoutAdapter extends AbstractLayoutAdapter { public void delete(XCreator creator, int creatorWidth, int creatorHeight) { int x = creator.getX(); 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 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 diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/painters/FRFixLayoutPainter.java b/designer-form/src/main/java/com/fr/design/designer/beans/painters/FRFixLayoutPainter.java index f450a437a..0f0aa2a6d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/painters/FRFixLayoutPainter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/painters/FRFixLayoutPainter.java @@ -1,6 +1,5 @@ package com.fr.design.designer.beans.painters; -import com.fr.design.designer.beans.painters.AbstractPainter; import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XOccupiedLayout; @@ -36,8 +35,8 @@ public class FRFixLayoutPainter extends AbstractPainter { @Override public void paint(Graphics g, int startX, int startY) { super.paint(g, startX, startY); - int x = hotspot.x - hotspot_bounds.x; - int y = hotspot.y - hotspot_bounds.y; + int x = hotspot.x - hotspot_bounds.x ; + int y = hotspot.y - hotspot_bounds.y ; Component currentComp = container.getComponentAt(x, y); if (currentComp == null) { return; @@ -50,7 +49,8 @@ public class FRFixLayoutPainter extends AbstractPainter { } else if (!((XCreator) currentComp).acceptType(XOccupiedLayout.class)) { state = OperateState.COMPONENT_REPLACE; } - state.paint(g, creator.getBackupRectangle(), currentComp.getBounds(), new Rectangle(x, y, creator.initEditorSize().width, ((XCreator) currentComp).initEditorSize().height)); + Rectangle currentCompRec = new Rectangle(currentComp.getX() - startX, currentComp.getY() - startY, currentComp.getWidth(), currentComp.getHeight()); + state.paint(g, creator.getBackupRectangle(), currentCompRec, new Rectangle(x, y, creator.initEditorSize().width, ((XCreator) currentComp).initEditorSize().height)); } else { Color bColor = XCreatorConstants.LAYOUT_FORBIDDEN_COLOR; int[] hot_rec = new int[]{x, y, 0, 0}; diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/painters/FROccupiedLayoutPainter.java b/designer-form/src/main/java/com/fr/design/designer/beans/painters/FROccupiedLayoutPainter.java index 33a809a89..3a973b116 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/painters/FROccupiedLayoutPainter.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/painters/FROccupiedLayoutPainter.java @@ -40,11 +40,11 @@ public class FROccupiedLayoutPainter extends AbstractPainter { Composite backupComposite = g2d.getComposite(); g2d.setColor(XCreatorConstants.DRAG_IN_OCCUPIED_LAYOUT_COLOR); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.05f)); - g2d.fillRect(container.getX(), container.getY(), container.getWidth(), container.getHeight()); + g2d.fillRect(container.getX() - startX, container.getY() - startY, container.getWidth(), container.getHeight()); g2d.setStroke(XCreatorConstants.DASH_STROKE); g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f)); - g2d.drawRect(container.getX() + 1, container.getY() + 1, container.getWidth() - 2, container.getHeight() - 2); + g2d.drawRect(container.getX() - startX + 1, container.getY() - startY + 1, container.getWidth() - 2, container.getHeight() - 2); g2d.setStroke(backupStroke); g2d.setComposite(backupComposite); g2d.setColor(backupColor); @@ -53,4 +53,4 @@ public class FROccupiedLayoutPainter extends AbstractPainter { } -} \ No newline at end of file +} diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 71aa6f990..da4d235f0 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -886,6 +886,7 @@ public class XWFitLayout extends XLayoutContainer { isRefreshing = true; this.remove(oldCreator); this.add(newCreator); + dealDirections(newCreator, false); //对于新增的绝对布局的组件,需要更新下内部组件的大小 if (newCreator.acceptType(XWAbsoluteLayout.class)){ ((XWAbsoluteLayout) newCreator).updateBoundsWidget(); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java index db5367ee9..9284554dc 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesignerUI.java @@ -25,7 +25,6 @@ import com.fr.stable.Constants; import javax.swing.JComponent; import javax.swing.SwingUtilities; -import javax.swing.SwingWorker; import javax.swing.plaf.ComponentUI; import java.awt.AlphaComposite; import java.awt.Color; @@ -114,14 +113,8 @@ public class FormDesignerUI extends ComponentUI { if (designer.getPainter() != null) { // ComponentAdapter和LayoutAdapter提供的额外的Painter,该Painter一般用于提示作用, // 相当于一个浮动层, 要考虑参数面板的高度 - new SwingWorker() { - @Override - protected Void doInBackground() throws Exception { - designer.getPainter().paint(g, designer.getArea().getHorizontalValue(), - designer.getArea().getVerticalValue() + designer.getParaHeight()); - return null; - } - }.execute(); + designer.getPainter().paint(g, designer.getArea().getHorizontalValue(), + designer.getArea().getVerticalValue() + designer.getParaHeight()); } AddingModel addingModel = designer.getAddingModel();