{
public static final String UPDATE = "OverviewUpdate";
- protected PropertyChangeSupport changeSupport = new PropertyChangeSupport(
+ private static final int MAX_PROGRESS = 100;
+
+ private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
this);
private FeatureColourFinder finder;
int seqIndex = 0;
int pixelRow = 0;
int alignmentHeight = miniMe.getHeight() - graphHeight;
+ int totalPixels = miniMe.getWidth() * alignmentHeight;
+ int lastRowUpdate = 0;
changeSupport.firePropertyChange(UPDATE, -1, 0);
for (int alignmentRow : rows)
}
}
+ sendProgressUpdate((pixelCol + 1) * (endRow - pixelRow),
+ totalPixels, lastRowUpdate);
pixelCol = endCol + 1;
}
colIndex++;
if (pixelRow != endRow + 1)
{
- changeSupport.firePropertyChange(UPDATE,
- Math.round(100 * (float) pixelRow / alignmentHeight),
- Math.round(
- 100 * ((float) (endRow + 1) / alignmentHeight)));
+ lastRowUpdate = sendProgressUpdate(endRow + 1, alignmentHeight, 0);
pixelRow = endRow + 1;
}
seqIndex++;
// final update to progress bar if present
if (redraw)
{
- changeSupport.firePropertyChange(UPDATE,
- Math.round(100 * (float) (pixelRow - 1) / alignmentHeight),
- 0);
+ sendProgressUpdate(pixelRow - 1, alignmentHeight, 0);
}
else
{
- changeSupport.firePropertyChange(UPDATE,
- Math.round(100 * alignmentHeight / miniMe.getHeight() - 1),
- Math.round(100 * alignmentHeight / miniMe.getHeight()));
+ sendProgressUpdate(alignmentHeight, miniMe.getHeight(), 0);
}
return miniMe;
}
/*
+ * Calculate progress update value and fire event
+ */
+ private int sendProgressUpdate(int position, int maximum, int offset)
+ {
+ int newUpdate = offset
+ + Math.round(MAX_PROGRESS * ((float) position / maximum));
+ if (newUpdate > offset)
+ {
+ changeSupport.firePropertyChange(UPDATE, offset, newUpdate);
+ return newUpdate;
+ }
+ return offset;
+ }
+
+ /*
* Find the colour of a sequence at a specified column position
*/
private int getColumnColourFromSequence(jalview.datamodel.SequenceI seq,
{
if (redraw)
{
- changeSupport.firePropertyChange(UPDATE, 99, 0);
+ changeSupport.firePropertyChange(UPDATE, MAX_PROGRESS - 1, 0);
break;
}
g.fillRect(pixelCol, y - height, endCol - pixelCol + 1, height);
}
+
pixelCol = endCol + 1;
colIndex++;
}
}
- changeSupport.firePropertyChange(UPDATE, 99, 100);
+ changeSupport.firePropertyChange(UPDATE, MAX_PROGRESS - 1,
+ MAX_PROGRESS);
}
public void setRedraw(boolean b)