|
|
@ -5,6 +5,9 @@ import com.fr.design.designer.creator.XCreator; |
|
|
|
import com.fr.design.designer.creator.XCreatorUtils; |
|
|
|
import com.fr.design.designer.creator.XCreatorUtils; |
|
|
|
import com.fr.design.designer.creator.XElementCase; |
|
|
|
import com.fr.design.designer.creator.XElementCase; |
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
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.design.utils.ComponentUtils; |
|
|
|
import com.fr.stable.Constants; |
|
|
|
import com.fr.stable.Constants; |
|
|
|
import com.fr.stable.GraphDrawHelper; |
|
|
|
import com.fr.stable.GraphDrawHelper; |
|
|
@ -28,6 +31,7 @@ public class FormSpacingLineDrawer { |
|
|
|
|
|
|
|
|
|
|
|
private FormDesigner designer; |
|
|
|
private FormDesigner designer; |
|
|
|
private XCreator hoverCreator = null; |
|
|
|
private XCreator hoverCreator = null; |
|
|
|
|
|
|
|
private XCreator selectedCreator = null; |
|
|
|
private Rectangle selectedRec; |
|
|
|
private Rectangle selectedRec; |
|
|
|
private Rectangle hoveredRec; |
|
|
|
private Rectangle hoveredRec; |
|
|
|
private boolean isMouseMoveEvent = false; |
|
|
|
private boolean isMouseMoveEvent = false; |
|
|
@ -37,15 +41,15 @@ public class FormSpacingLineDrawer { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { |
|
|
|
public void updateMouseEvent(MouseEvent e, boolean isMouseMoveEvent) { |
|
|
|
XCreator creator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
|
|
|
selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
|
|
|
if (creator != null) { |
|
|
|
if (selectedCreator != null) { |
|
|
|
this.hoverCreator = getHoverComponentAt(e.getX(), e.getY()); |
|
|
|
this.hoverCreator = getHoverComponentAt(e.getX(), e.getY()); |
|
|
|
} |
|
|
|
} |
|
|
|
this.isMouseMoveEvent = isMouseMoveEvent; |
|
|
|
this.isMouseMoveEvent = isMouseMoveEvent; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void draw(Graphics g) { |
|
|
|
public void draw(Graphics g) { |
|
|
|
if (!isMouseMoveEvent) { |
|
|
|
if (!isMouseMoveEvent || selectedCreator == null || hoverCreator == null) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -53,10 +57,6 @@ public class FormSpacingLineDrawer { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!hoverCreator.isParentAbsolute()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.selectedRec = designer.getSelectionModel().getSelection().getRelativeBounds(); |
|
|
|
this.selectedRec = designer.getSelectionModel().getSelection().getRelativeBounds(); |
|
|
|
this.hoveredRec = ComponentUtils.getRelativeBounds(hoverCreator); |
|
|
|
this.hoveredRec = ComponentUtils.getRelativeBounds(hoverCreator); |
|
|
|
|
|
|
|
|
|
|
@ -137,13 +137,55 @@ public class FormSpacingLineDrawer { |
|
|
|
GraphDrawHelper.drawString(g2d, text, labelX, labelY); |
|
|
|
GraphDrawHelper.drawString(g2d, text, labelX, labelY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isSelectedParaComponent() { |
|
|
|
|
|
|
|
return designer.getParaComponent() == selectedCreator; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isSelectedRootComponent() { |
|
|
|
|
|
|
|
return designer.isRoot(selectedCreator); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isSelectedForm() { |
|
|
|
|
|
|
|
return selectedCreator.getParent() == null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { |
|
|
|
private boolean isNeedExtendedLine(AbstractFormParallelLine[] nearestSides) { |
|
|
|
return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]); |
|
|
|
return nearestSides[0].isVerticalCenterLineBeforeTheParallelLine(nearestSides[1]) || nearestSides[0].isVerticalCenterLineBehindTheParallelLine(nearestSides[1]); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isSelectedRootPane() { |
|
|
|
|
|
|
|
// form、body、para这三个选中了,都不要画任何间距线
|
|
|
|
|
|
|
|
return isSelectedForm() || isSelectedRootComponent() || isSelectedParaComponent(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 当前组件是否在参数面板里面
|
|
|
|
|
|
|
|
private boolean isCompInBody(XCreator creator) { |
|
|
|
|
|
|
|
XLayoutContainer container = XCreatorUtils.getHotspotContainer(creator); |
|
|
|
|
|
|
|
return container != null && !container.acceptType(XWParameterLayout.class); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isSelectedCompInBody() { |
|
|
|
|
|
|
|
return isCompInBody(selectedCreator); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isHoveredCompInBody() { |
|
|
|
|
|
|
|
return isCompInBody(hoverCreator); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isCompInBody() { |
|
|
|
|
|
|
|
return isSelectedCompInBody() && isHoveredCompInBody(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isBodyAbsoluteLayout() { |
|
|
|
|
|
|
|
return !(designer instanceof FormParaDesigner) && FormDesignerUtils.isBodyAbsolute(designer); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isInAbsoluteLayout() { |
|
|
|
|
|
|
|
return isBodyAbsoluteLayout() && hoverCreator.isParentAbsolute() && selectedCreator.isParentAbsolute(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean isDrawSpacingLine() { |
|
|
|
private boolean isDrawSpacingLine() { |
|
|
|
XCreator selectedCreator = designer.getSelectionModel().getSelection().getSelectedCreator(); |
|
|
|
return isInAbsoluteLayout() && !isSelectedRootPane() && isCompInBody(); |
|
|
|
return hoverCreator != null && selectedCreator != null && hoverCreator.isAbleDrawSpacingLine() && selectedCreator.isAbleDrawSpacingLine(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private AbstractFormParallelLine[] getNearestHorizontalSide() { |
|
|
|
private AbstractFormParallelLine[] getNearestHorizontalSide() { |
|
|
|