public class OverviewCanvas extends JComponent
{
- private static final long RUNNING_TIME = 2000;
+ private static final long RUNNING_TIME = 1000;
private static final int SPEED = 40;
private volatile boolean updaterunning = false;
+ private boolean dispose = false;
+
private BufferedImage miniMe;
private BufferedImage lastMiniMe = null;
System.gc();
or.removePropertyChangeListener(progressPanel);
+ or = null;
if (restart)
{
restart = false;
- draw(showSequenceFeatures, showAnnotation, transferRenderer);
+ if (!dispose)
+ {
+ draw(showSequenceFeatures, showAnnotation, transferRenderer);
+ }
}
else
{
g.setColor(Color.red);
od.drawBox(g);
}
+
+ public void dispose()
+ {
+ dispose = true;
+ synchronized (this)
+ {
+ restart = true;
+ if (or != null)
+ {
+ or.setRedraw(true);
+ }
+ }
+ }
}
@Override
public void run()
{
- oviewCanvas.draw(av.isShowSequenceFeatures(),
- (av.isShowAnnotation() && av
- .getAlignmentConservationAnnotation() != null), ap
- .getSeqPanel().seqCanvas.getFeatureRenderer());
- setBoxPosition();
+ if (oviewCanvas != null)
+ {
+ oviewCanvas.draw(av.isShowSequenceFeatures(),
+ (av.isShowAnnotation()
+ && av.getAlignmentConservationAnnotation() != null),
+ ap.getSeqPanel().seqCanvas.getFeatureRenderer());
+ setBoxPosition();
+ }
}
/**
*/
private void setBoxPosition()
{
- od.setBoxPosition(av.getAlignment().getHiddenSequences(), av
- .getAlignment().getHiddenColumns());
- repaint();
+ if (od != null)
+ {
+ od.setBoxPosition(av.getAlignment().getHiddenSequences(),
+ av.getAlignment().getHiddenColumns());
+ repaint();
+ }
}
@Override
try
{
av.getRanges().removePropertyChangeListener(this);
+ oviewCanvas.dispose();
} finally
{
progressPanel = null;
{
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)