shouldMergeBands method
Determines whether two bands should be merged based on their horizontal proximity.
Calculates the horizontal distance between bands and compares it against an estimated space width derived from the average band height. Bands are considered mergeable if they are close enough horizontally.
bandWest The band positioned to the left or west.
bandEast The band positioned to the right or east.
Returns true if the bands should be merged, false otherwise.
Implementation
bool shouldMergeBands(Band bandWest, Band bandEast) {
final int horizontalDistance =
bandEast.rectangleAdjusted.left - bandWest.rectangleAdjusted.right;
final int avgHeightOfBothBands =
(bandEast.rectangleAdjusted.height +
bandWest.rectangleAdjusted.height) ~/
2;
final estimatedSpaceWidth = avgHeightOfBothBands * 1.2;
return horizontalDistance > 0 && horizontalDistance <= estimatedSpaceWidth;
}