I need to order an ArrayList of Points in the page line order. Assume these points as minX and minY of Rectangle of text.
Say like I have points like below
Point(100,10), Point(110, 20), Point(125, 5), Point(130, 10)
The Sorted order should be aligned as page line items
i.e Point(125, 5), Point(100,10), Point(130, 10), Point(110, 20)
I was trying to sort the Points by Y coordinate first and then by X coordinate
public int compare(final Point a, final Point b) {
if (a.y() < b.y()) {
return -1;
}else if (a.y() > b.y()) {
return 1;
}else {
return 0;
}
}
public int compare(final Point a, final Point b) {
if (a.x() < b.x()) {
return -1;
}else if (a.x() > b.x()) {
return 1;
}else {
return 0;
}
}
Below is the order I am getting now
Line = 0.00 2450 00 SewiceTax @14 on are, Sub Total Two Thousand Four Hundred Fifty Only INR
Line = Swachh Bharat Cass @ O 50 42':
Line = Knshu Kaiyan Cass @ 0‘50 “5
Line = Less Advance Paid
Line = 2450 GD Balance Payable
Expected was
Line = Sub Total Two Thousand Four Hundred Fifty Only 0.00 2450 00INR SewiceTax @14 on are,