mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-11 01:32:08 +10:00
Renumber function sometimes doesn't work as expected
This commit is contained in:
+36
-25
@@ -1078,34 +1078,45 @@ 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++) {
|
||||||
if (xAxisFirst) {
|
sumX1 += o1.getControlPoint(i).getX();
|
||||||
if (point1.y < point2.y) {
|
sumY1 += o1.getControlPoint(i).getY();
|
||||||
return -1;
|
}
|
||||||
} else if (point1.y > point2.y) {
|
for (int i = 0; i < o2.getControlPointCount(); i++) {
|
||||||
return 1;
|
sumX2 += o2.getControlPoint(i).getX();
|
||||||
} else {
|
sumY2 += o2.getControlPoint(i).getY();
|
||||||
if (point1.x < point1.x) {
|
}
|
||||||
return -1;
|
sumX1 /= o1.getControlPointCount();
|
||||||
} else if (point1.x > point1.x) {
|
sumY1 /= o1.getControlPointCount();
|
||||||
return 1;
|
sumX2 /= o2.getControlPointCount();
|
||||||
}
|
sumY2 /= o2.getControlPointCount();
|
||||||
}
|
|
||||||
|
if (xAxisFirst) {
|
||||||
|
if (sumY1 < sumY2) {
|
||||||
|
return -1;
|
||||||
|
} else if (sumY1 > sumY2) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (sumX1 < sumX2) {
|
||||||
|
return -1;
|
||||||
|
} else if (sumX1 > sumX2) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
if (sumY1 < sumY2) {
|
||||||
|
return -1;
|
||||||
|
} else if (sumY1 > sumY2) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
|
||||||
if (point1.y < point1.y) {
|
|
||||||
return -1;
|
|
||||||
} else if (point1.y > point1.y) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user