|
|
|
@ -1,6 +1,13 @@
|
|
|
|
|
package com.fr.design.mainframe; |
|
|
|
|
|
|
|
|
|
import com.fr.design.designer.creator.XChartEditor; |
|
|
|
|
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; |
|
|
|
@ -35,7 +42,7 @@ public class FormSpacingLineDrawer {
|
|
|
|
|
public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { |
|
|
|
|
XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
|
|
|
|
if (creator != null) { |
|
|
|
|
this.hoverCreator = designer.getComponentAt(e.getX(), e.getY(), creator.getLevel()); |
|
|
|
|
this.hoverCreator = getHoverComponentAt(e.getX(), e.getY()); |
|
|
|
|
} |
|
|
|
|
this.isMouseMoveEvent = isMouseMoveEvent; |
|
|
|
|
} |
|
|
|
@ -129,14 +136,16 @@ public class FormSpacingLineDrawer {
|
|
|
|
|
GraphDrawHelper.drawString(g2d, text, labelX, labelY); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isSelectedParaComponent() { |
|
|
|
|
return designer.getParaComponent() == designer.getSelectionModel().getSelection().getSelectedCreator(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isSelectedRootComponent() { |
|
|
|
|
return designer.getSelectionModel().getSelection().size() == 1 && |
|
|
|
|
designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator()); |
|
|
|
|
return designer.isRoot(designer.getSelectionModel().getSelection().getSelectedCreator()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isSelectedForm() { |
|
|
|
|
return designer.getSelectionModel().getSelection().size() == 1 && |
|
|
|
|
designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; |
|
|
|
|
return designer.getSelectionModel().getSelection().getSelectedCreator().getParent() == null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { |
|
|
|
@ -144,16 +153,38 @@ public class FormSpacingLineDrawer {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isSelectedRootPane() { |
|
|
|
|
return isSelectedForm() || isSelectedRootComponent(); |
|
|
|
|
// 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 isSelectedCreatorSameParentWithHoveredCreator() { |
|
|
|
|
XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
|
|
|
|
return selectedCreator != null && hoverCreator != null && selectedCreator.getParent() == hoverCreator.getParent(); |
|
|
|
|
private boolean isHoveredCompInPara() { |
|
|
|
|
return isCompInPara(hoverCreator); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isSelectedCompOrHoveredCompInPara() { |
|
|
|
|
return isSelectedCompInPara() || isHoveredCompInPara(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isDrawSpacingLine() { |
|
|
|
|
return !isSelectedRootPane() && isSelectedCreatorSameParentWithHoveredCreator() && isMouseMoveEvent; |
|
|
|
|
return isBodyAbsoluteLayout() && !isSelectedRootPane() && hoverCreator != null && !isSelectedCompOrHoveredCompInPara() && isMouseMoveEvent; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private AbstractFormParallelLine[] getNearestHorizontalSide() { |
|
|
|
@ -197,4 +228,25 @@ public class FormSpacingLineDrawer {
|
|
|
|
|
} |
|
|
|
|
return nearestSides; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private XCreator getHoverComponentAt(int x, int y) { |
|
|
|
|
XCreator component = designer.getComponentAt(x, y); |
|
|
|
|
XLayoutContainer parent = XCreatorUtils.getHotspotContainer(component).getTopLayout(); |
|
|
|
|
if (parent != null) { |
|
|
|
|
if (!parent.isEditable()) { |
|
|
|
|
return parent; |
|
|
|
|
} else { |
|
|
|
|
if (parent == component) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (component instanceof XChartEditor || component instanceof XElementCase) { |
|
|
|
|
return (XCreator) component.getParent(); |
|
|
|
|
} |
|
|
|
|
return component; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
return component; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|