Browse Source

REPORT-57326&EPORT-57324&REPORT-57330&REPORT-56895 布局推荐若干间距线的bug

feature/10.0
方磊 3 years ago
parent
commit
ea2a93476e
  1. 19
      designer-form/src/main/java/com/fr/design/mainframe/FormSpacingLineDrawer.java

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

@ -1,6 +1,7 @@
package com.fr.design.mainframe;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.utils.ComponentUtils;
import com.fr.stable.Constants;
import com.fr.stable.GraphDrawHelper;
@ -23,6 +24,7 @@ public class FormSpacingLineDrawer {
private FormDesigner designer;
private XCreator hoverCreator = null;
private Rectangle selectedRec;
private Rectangle hoveredRec;
private boolean isMouseMoveEvent = false;
public FormSpacingLineDrawer(FormDesigner designer) {
@ -38,7 +40,6 @@ public class FormSpacingLineDrawer {
}
public void draw(Graphics g) {
this.selectedRec = designer.getSelectionModel().getSelection().getSelctionBounds();
if (!isDrawSpacingLine()) {
return;
}
@ -47,6 +48,9 @@ public class FormSpacingLineDrawer {
return;
}
this.selectedRec = designer.getSelectionModel().getSelection().getRelativeBounds();
this.hoveredRec = ComponentUtils.getRelativeBounds(hoverCreator);
drawHorizontalSpacingLine(g);
drawVerticalSpacingLine(g);
}
@ -158,8 +162,8 @@ public class FormSpacingLineDrawer {
};
AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] {
new FormHorizontalParallelLine(hoverCreator.getY(), hoverCreator.getX(), hoverCreator.getX() + hoverCreator.getWidth()),
new FormHorizontalParallelLine(hoverCreator.getY() + hoverCreator.getHeight(), hoverCreator.getX(), hoverCreator.getX() + hoverCreator.getWidth())
new FormHorizontalParallelLine(hoveredRec.y, hoveredRec.x, hoveredRec.x + hoveredRec.width),
new FormHorizontalParallelLine(hoveredRec.y + hoveredRec.height, hoveredRec.x, hoveredRec.x + hoveredRec.width)
};
return getNearestSide(selectedRecSides, hoveredCreatorSides);
}
@ -171,19 +175,20 @@ public class FormSpacingLineDrawer {
};
AbstractFormParallelLine[] hoveredCreatorSides = new AbstractFormParallelLine[] {
new FormVerticalParallelLine(hoverCreator.getX(), hoverCreator.getY(), hoverCreator.getY() + hoverCreator.getHeight()),
new FormVerticalParallelLine(hoverCreator.getX() + hoverCreator.getWidth(), hoverCreator.getY(), hoverCreator.getY() + hoverCreator.getHeight())
new FormVerticalParallelLine(hoveredRec.x, hoveredRec.y, hoveredRec.y + hoveredRec.height),
new FormVerticalParallelLine(hoveredRec.x + hoveredRec.width, hoveredRec.y, hoveredRec.y + hoveredRec.height)
};
return getNearestSide(selectedRecSides, hoveredCreatorSides);
}
private AbstractFormParallelLine[] getNearestSide(AbstractFormParallelLine[] lines1, AbstractFormParallelLine[] lines2) {
AbstractFormParallelLine[] nearestSides = new AbstractFormParallelLine[2];
AbstractFormParallelLine[] nearestSides = new AbstractFormParallelLine[] {lines1[0], lines2[0]};
int minDistance = lines1[0].getDistanceWithLine(lines2[0]);
for (int i = 0; i < lines1.length; i++) {
for (int j = 0; j < lines2.length; j++) {
int distance = lines1[i].getDistanceWithLine(lines2[j]);
if (distance <= minDistance) {
if (distance < minDistance) {
minDistance = distance;
nearestSides[0] = lines1[i];
nearestSides[1] = lines2[j];
}

Loading…
Cancel
Save