int totalPixels = miniMe.getWidth() * alignmentHeight;
int lastRowUpdate = 0;
+ int lastUpdate = 0;
changeSupport.firePropertyChange(UPDATE, -1, 0);
for (int alignmentRow : rows)
}
}
- sendProgressUpdate((pixelCol + 1) * (endRow - pixelRow),
- totalPixels, lastRowUpdate);
+ // store last update value
+ lastUpdate = sendProgressUpdate(
+ (pixelCol + 1) * (endRow - pixelRow), totalPixels,
+ lastRowUpdate, lastUpdate);
pixelCol = endCol + 1;
}
colIndex++;
if (pixelRow != endRow + 1)
{
- lastRowUpdate = sendProgressUpdate(endRow + 1, alignmentHeight, 0);
+ // store row offset and last update value
+ lastRowUpdate = sendProgressUpdate(endRow + 1, alignmentHeight, 0,
+ lastUpdate);
+ lastUpdate = lastRowUpdate;
pixelRow = endRow + 1;
}
seqIndex++;
// final update to progress bar if present
if (redraw)
{
- sendProgressUpdate(pixelRow - 1, alignmentHeight, 0);
+ sendProgressUpdate(pixelRow - 1, alignmentHeight, 0, 0);
}
else
{
- sendProgressUpdate(alignmentHeight, miniMe.getHeight(), 0);
+ sendProgressUpdate(alignmentHeight, miniMe.getHeight(), 0, 0);
}
return miniMe;
}
/*
* Calculate progress update value and fire event
+ * @param rowOffset number of rows to offset calculation by
+ * @return new rowOffset - return value only to be used when at end of a row
*/
- private int sendProgressUpdate(int position, int maximum, int offset)
+ private int sendProgressUpdate(int position, int maximum, int rowOffset,
+ int lastUpdate)
{
- int newUpdate = offset
+ int newUpdate = rowOffset
+ Math.round(MAX_PROGRESS * ((float) position / maximum));
- if (newUpdate > offset)
+ if (newUpdate > lastUpdate)
{
- changeSupport.firePropertyChange(UPDATE, offset, newUpdate);
+ changeSupport.firePropertyChange(UPDATE, rowOffset, newUpdate);
return newUpdate;
}
- return offset;
+ return newUpdate;
}
/*