Skip to content
Snippets Groups Projects
Commit e677d81c authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Solving ticket 416: overlay between connection between blocks in certain cases had been removed

parent cfdb1b7a
No related branches found
No related tags found
No related merge requests found
......@@ -249,9 +249,9 @@ public class AvatarPanelDrawer {
}
if (p1 == null)
p1 = b1.closerFreeTGConnectingPoint(b2.getX(), b2.getY(), false, true);
p1 = b1.closerFreeTGConnectingPointNoOverlay(b2.getX(), b2.getY(), false, true);
if (p2 == null)
p2 = b2.closerFreeTGConnectingPoint(b1.getX(), b1.getY(), true, false);
p2 = b2.closerFreeTGConnectingPointNoOverlay(b1.getX(), b1.getY(), true, false);
if (p1 != null && p2 != null) {
p1.setFree(false);
p2.setFree(false);
......
......@@ -2383,6 +2383,53 @@ public abstract class TGComponent extends AbstractCDElement implements /*CDEleme
return currentCloser;
}
public TGConnectingPoint closerFreeTGConnectingPointNoOverlay(int x, int y, boolean mustBeIn, boolean mustBeOut) {
TGConnectingPoint currentCloser = null;
TGConnectingPoint currentp;
double d1, d2;
int i;
int ref = 0;
//compare current closer to my points.
for (i = 0; i < nbConnectingPoint; i++) {
if (connectingPoint[i] instanceof TGConnectingPointComment) {
continue;
}
currentp = connectingPoint[i];
if ((currentp != null) && (currentp.isFree()) && ( (currentp.isIn() && mustBeIn) || (currentp.isOut() && mustBeOut))) {
// Check overlay
if (!(hasOverlayWhichIsNonFree(currentp))) {
if (currentCloser == null) {
currentCloser = currentp;
ref = i;
} else {
d1 = Point2D.distanceSq(currentp.getX(), currentp.getY(), x, y);
d2 = Point2D.distanceSq(currentCloser.getX(), currentCloser.getY(), x, y);
if (d1 < d2) {
currentCloser = currentp;
ref = i;
}
}
}
}
}
if (currentCloser != null) {
connectingPoint[ref].setFree(false);
return connectingPoint[ref];
}
return currentCloser;
}
public boolean hasOverlayWhichIsNonFree(TGConnectingPoint p) {
for (int i = 0; i < nbConnectingPoint; i++) {
TGConnectingPoint pCurrent = connectingPoint[i];
if ((pCurrent != p) && (!pCurrent.isFree()) && (p.getX() == pCurrent.getX()) && (p.getY() == pCurrent.getY())) {
return true;
}
}
return false;
}
public TGConnectingPoint closerFreeTGConnectingPointCompatibility(int x, int y, boolean out, boolean in, int compatibility) {
TGConnectingPoint currentCloser = null;
TGConnectingPoint currentp;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment