Browse Source

REPORT-57722 看看绘制间距线判断的地方有没有优化的空间

persist/11.0
方磊 3 years ago
parent
commit
bfd07764cd
  1. 28
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  2. 13
      designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java
  3. 5
      designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java
  4. 53
      designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java

28
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -68,6 +68,9 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
protected Widget data;
protected JComponent editor;
protected CoverReportPane coverPanel;
protected boolean inAbsoluteBodyLayout;
// XCreator加入到某些XLayoutContainer中时,能调整宽度或者高度
private int[] directions;
private Rectangle backupBound;
@ -887,4 +890,29 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
}
return ((XCreator) this.getParent()).getLevel() + 1;
}
public boolean isAbleDrawSpacingLine() {
return !isBody() && !isParameter() && !isInPara() && isInAbsoluteBodyLayout();
}
public boolean isBody() {
return false;
}
public boolean isParameter() {
return false;
}
public boolean isInPara() {
XLayoutContainer container = XCreatorUtils.getHotspotContainer(this);
return container != null && container.acceptType(XWParameterLayout.class);
}
public boolean isInAbsoluteBodyLayout() {
return inAbsoluteBodyLayout;
}
public void setInAbsoluteBodyLayout(boolean inAbsoluteBodyLayout) {
this.inAbsoluteBodyLayout = inAbsoluteBodyLayout;
}
}

13
designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java

@ -12,6 +12,7 @@ import com.fr.stable.core.PropertyChangeAdapter;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ContainerEvent;
import java.beans.IntrospectionException;
/**
@ -135,4 +136,16 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout {
return false;
}
@Override
public void componentAdded(ContainerEvent e) {
super.componentAdded(e);
XWidgetCreator creator = (XWidgetCreator) e.getChild();
creator.setInAbsoluteBodyLayout(true);
}
@Override
public boolean isBody() {
return true;
}
}

5
designer-form/src/main/java/com/fr/design/designer/creator/XWParameterLayout.java

@ -260,4 +260,9 @@ public class XWParameterLayout extends XWAbsoluteLayout {
public boolean isTopable() {
return false;
}
@Override
public boolean isParameter() {
return true;
}
}

53
designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java

@ -5,9 +5,6 @@ import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XCreatorUtils;
import com.fr.design.designer.creator.XElementCase;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.form.parameter.FormParaDesigner;
import com.fr.design.form.util.FormDesignerUtils;
import com.fr.design.utils.ComponentUtils;
import com.fr.stable.Constants;
import com.fr.stable.GraphDrawHelper;
@ -48,6 +45,10 @@ public class FormSpacingLineDrawer {
}
public void draw(Graphics g) {
if (!isMouseMoveEvent) {
return;
}
if (!isDrawSpacingLine()) {
return;
}
@ -136,55 +137,13 @@ public class FormSpacingLineDrawer {
GraphDrawHelper.drawString(g2d, text, labelX, labelY);
}
private boolean isSelectedParaComponent() {
return designer.getParaComponent() == designer.getSelectionModel().getSelection().getSelectedCreator();
}
private boolean isSelectedRootComponent() {
return designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator());
}
private boolean isSelectedForm() {
return designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null;
}
private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) {
return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]);
}
private boolean isSelectedRootPane() {
// form、body、para这三个选中了,都不要画任何间距线
return isSelectedForm() || isSelectedRootComponent() || isSelectedParaComponent();
}
// 当前组件是否在参数面板里面
private boolean isCompInPara(XCreator creator) {
XLayoutContainer container = XCreatorUtils.getHotspotContainer(creator);
boolean xCreatorAccept = creator.acceptType(XWParameterLayout.class);
boolean containerAccept = container != null && container.acceptType(XWParameterLayout.class);
return xCreatorAccept || containerAccept;
}
private boolean isBodyAbsoluteLayout() {
return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer);
}
private boolean isSelectedCompInPara() {
return isCompInPara(designer.getSelectionModel().getSelection().getSelectedCreator());
}
private boolean isHoveredCompInPara() {
return isCompInPara(hoverCreator);
}
private boolean isSelectedCompOrHoveredCompInPara() {
return isSelectedCompInPara() || isHoveredCompInPara();
}
private boolean isDrawSpacingLine() {
return isBodyAbsoluteLayout() && !isSelectedRootPane() && hoverCreator != null && !isSelectedCompOrHoveredCompInPara() && isMouseMoveEvent;
XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator();
return hoverCreator != null && selectedCreator != null && hoverCreator.isAbleDrawSpacingLine() && selectedCreator.isAbleDrawSpacingLine();
}
private AbstractFormParallelLine[] getNearestHorizontalSide() {

Loading…
Cancel
Save