*/
for (ConnectionPoint cp : shape.connectionPoints) {
for (EndPoint ep : cp.gluedEndPoints) {
Connector conn = ep.connector;
if (conn.sections.size() > 1) {
Section secondFromShape = null;
int sectionLength;
boolean start = false;
if (conn.endEndPoint.equals(ep)) {
secondFromShape = conn.sections.get(conn.sections.size() - 2);
} else if (conn.startEndPoint.equals(ep)) {
start = true;
secondFromShape = conn.sections.get(1);
}
if (secondFromShape.isHorizontal()) {
sectionLength = secondFromShape.endPoint.getLeft() - secondFromShape.startPoint.getLeft();
} else {
sectionLength = secondFromShape.endPoint.getTop() - secondFromShape.startPoint.getTop();
}
if (start) {
sectionLength = -sectionLength;
}
if (Math.abs(sectionLength) < Shape.SECTION_TOLERANCE) {
if (secondFromShape.isHorizontal()) {
horSectionsMap.put(sectionLength, secondFromShape);
} else {
vertSectionsMap.put(sectionLength, secondFromShape);
}
}
}
}
}
Integer minHorizontal = Integer.MAX_VALUE;
Integer minVertical = Integer.MAX_VALUE;
Section lastHorizontalSection = null;
Section lastVerticalSection = null;
for (Integer length : horSectionsMap.keySet()) {
if (length < minHorizontal) {
minHorizontal = length;
lastHorizontalSection = horSectionsMap.get(length);