Renumber function sometimes doesn't work as expected

This commit is contained in:
bancika
2011-09-03 19:19:07 +00:00
parent 0df3bc37a0
commit 84d0da6308
2 changed files with 40 additions and 25 deletions
@@ -1078,37 +1078,48 @@ public class Presenter implements IPlugInPort {
@Override @Override
public int compare(IDIYComponent<?> o1, IDIYComponent<?> o2) { public int compare(IDIYComponent<?> o1, IDIYComponent<?> o2) {
Area area1 = drawingManager.getComponentArea(o1); int sumX1 = 0;
Area area2 = drawingManager.getComponentArea(o2); int sumY1 = 0;
if (area1 != null && area2 != null) { int sumX2 = 0;
Point point1 = area1.getBounds().getLocation(); int sumY2 = 0;
Point point2 = area2.getBounds().getLocation(); for (int i = 0; i < o1.getControlPointCount(); i++) {
sumX1 += o1.getControlPoint(i).getX();
sumY1 += o1.getControlPoint(i).getY();
}
for (int i = 0; i < o2.getControlPointCount(); i++) {
sumX2 += o2.getControlPoint(i).getX();
sumY2 += o2.getControlPoint(i).getY();
}
sumX1 /= o1.getControlPointCount();
sumY1 /= o1.getControlPointCount();
sumX2 /= o2.getControlPointCount();
sumY2 /= o2.getControlPointCount();
if (xAxisFirst) { if (xAxisFirst) {
if (point1.y < point2.y) { if (sumY1 < sumY2) {
return -1; return -1;
} else if (point1.y > point2.y) { } else if (sumY1 > sumY2) {
return 1; return 1;
} else { } else {
if (point1.x < point1.x) { if (sumX1 < sumX2) {
return -1; return -1;
} else if (point1.x > point1.x) { } else if (sumX1 > sumX2) {
return 1; return 1;
} }
} }
} else { } else {
if (point1.x < point2.x) { if (sumX1 < sumX2) {
return -1; return -1;
} else if (point1.x > point2.x) { } else if (sumX1 > sumX2) {
return 1; return 1;
} else { } else {
if (point1.y < point1.y) { if (sumY1 < sumY2) {
return -1; return -1;
} else if (point1.y > point1.y) { } else if (sumY1 > sumY2) {
return 1; return 1;
} }
} }
} }
}
return 0; return 0;
} }
}); });
@@ -378,6 +378,10 @@
<releaseDate>2011-08-28 20:00:00.000 CET</releaseDate> <releaseDate>2011-08-28 20:00:00.000 CET</releaseDate>
<name></name> <name></name>
<changes> <changes>
<com.diyfever.gui.update.Change>
<changeType>BUG_FIX</changeType>
<description>Renumber function sometimes doesn't work as expected</description>
</com.diyfever.gui.update.Change>
<com.diyfever.gui.update.Change> <com.diyfever.gui.update.Change>
<changeType>IMPROVEMENT</changeType> <changeType>IMPROVEMENT</changeType>
<description>Increased PNG export resolution to 300dpi</description> <description>Increased PNG export resolution to 300dpi</description>