return;
}
int max=pBar.getMaximum();
+ updateProgressBarEta(minutes);
+ pBar.setMaximum(max);
+ pBar.setValue(progress);
+ }
+
+ public void updateProgressBarEta(double minutes)
+ {
+ JProgressBar pBar = progressBar.getProgressBar(progId);
+
+ if (pBar == null)
+ {
+ return;
+ }
progressBar.setProgressBarMessage(progId,
progressBar.getMessage(progId) + " ("
+ (Double.isNaN(minutes) ? " .. working ..)"
: (minutes < 1.0 ? "Less than a minute)"
- : ((int) Math.ceil(minutes)) + " mins. to go)")));
- pBar.setMaximum(max);
- pBar.setValue(progress);
-
+ : ((int) Math.ceil(minutes))
+ + " mins. to go)")));
}
+
public void updateProgressBar(int progress)
{
JProgressBar pBar = progressBar.getProgressBar(progId);
{
if (PairwiseAlignPanel.PROGRESS.equals(pcEvent.getPropertyName()))
{
- updateProgressBarWithEta((int) pcEvent.getNewValue(), pap.getEta());
-
+ updateProgressBar((int) pcEvent.getNewValue());
}
else if (PairwiseAlignPanel.TOTAL.equals(pcEvent.getPropertyName()))
{
updateProgressBar((int) pcEvent.getNewValue(), 0);
}
+ else if (PairwiseAlignPanel.ETA.equals(pcEvent.getPropertyName()))
+ {
+ updateProgressBarEta((double) pcEvent.getNewValue());
+ }
}
});
}
public static final String PROGRESS = "progress";
+ protected static final String ETA = "eta_in_minutes";
+
private volatile boolean cancelled;
- private int total;
+ private long total;
- private int progress;
+ private long progress;
private SequenceGroup selection;
this.GAP_EXTEND_COST = gapExtendCost;
this.endGaps = endGaps;
this.selection = selection;
- this.total = MiscMath.combinations(av.getAlignment().getHeight(), 2);
+ this.total = av.getAlignment().getHeight();
+ total = (total*total-total)/2;
this.scoreMatrix = scoreMatrix;
if (run)
{
float[][] alignmentScores = new float[seqs.length][seqs.length];
double totscore = 0D;
int count = seqs.length;
-
+ int fracprogress=0;
boolean first = true;
long time=System.currentTimeMillis();
- progress = 0;
- firePropertyChange(TOTAL, 0, total);
+ long fprogress = 0;
+ firePropertyChange(TOTAL, 0, 500);
for (int i = 1; i < count; i++)
{
sequences.add(as.getAlignedSeq1());
sequences.add(as.getAlignedSeq2());
}
- firePropertyChange(PROGRESS, progress, ++progress);
+ ++fprogress;
}
if (i<count)
{
- // remaining time in minutes ~ is (elapsed time)/ 0.5*(n*n)
- etime = 0.0001*(total-progress)*(System.currentTimeMillis()-time)/progress;
+ int newfracprogress=(int) Math.floor((500.0*(double)fprogress)/((double)total));
+ // need to fake a different starting value until we have an ETA calculated
+ firePropertyChange(PROGRESS, fracprogress, newfracprogress);
+ fracprogress = newfracprogress;
+ progress=fprogress;
+ // remaining time in minutes ~ is remaining*(elapsed time)/progress;
+ double lasteta=etime;
+ double rate = ((double)(System.currentTimeMillis()-time))/(double)progress;
+ etime = rate*(total-progress)/60000;
+ firePropertyChange(ETA, 0,etime);
}
}
alignmentScores[count - 1][count - 1] = Float.NaN;
public boolean hasEta()
{
- return !Double.isNaN(etime);
+ return etime>0;
}
public double getEta()
{