updateStatistics method
void
updateStatistics()
Calculates the average Kerning between adjacent artifacts and their average width.
This method computes the mean horizontal distance between the right edge of one artifact and the left edge of the next artifact in the list. It also calculates the average width of all artifacts. The artifacts are assumed to be sorted from left to right.
If there are fewer than 2 artifacts, both averages are set to -1.
Implementation
void updateStatistics() {
if (artifacts.length < 2) {
_averageKerning = -1;
_averageWidth = rectangleAdjusted.width;
return;
}
double totalWidth = 0;
double totalKerning = 0;
int count = artifacts.length;
for (int i = 1; i < artifacts.length; i++) {
final artifact = artifacts[i];
totalWidth += artifact.rectAdjusted.width;
final int kerning =
artifact.rectAdjusted.left - artifacts[i - 1].rectAdjusted.right;
totalKerning += kerning;
}
_averageWidth = (totalWidth / count).round();
_averageKerning = (totalKerning / count).round();
}