+ MAX_PASIMAP_SEQ);
}
- PairwiseAlignPanel pap = new PairwiseAlignPanel(av, selGroup, true,
+ final PairwiseAlignPanel pap = new PairwiseAlignPanel(av, selGroup, true,
GAP_OPEN_COST, GAP_EXTEND_COST, false, null);
pap.setDiscardAlignments(true);
pap.setQuiet(true);
System.out.println(pap != null);
setPairwiseAlignPanel(pap);
- getPasimapModel().calculate(pap);
-
- xCombobox.setSelectedIndex(0);
- yCombobox.setSelectedIndex(1);
- zCombobox.setSelectedIndex(2);
+ progressBar.registerHandler(progId, new IProgressIndicatorHandler()
+ {
+
+ @Override
+ public boolean cancelActivity(long id)
+ {
+ getPasimapModel().cancel();
+ return true;
+ }
+
+ @Override
+ public boolean canCancel()
+ {
+ return true;
+ }
+ });
- getPasimapModel().updateRc(getRotatableCanvas());
- // rc.invalidate();
- setTop(getPasimapModel().getTop());
+ getPasimapModel().calculate(pap);
+ if (!getPasimapModel().isCancelled())
+ {
+ xCombobox.setSelectedIndex(0);
+ yCombobox.setSelectedIndex(1);
+ zCombobox.setSelectedIndex(2);
+ getPasimapModel().updateRc(getRotatableCanvas());
+ // rc.invalidate();
+ setTop(getPasimapModel().getTop());
+ }
} catch (OutOfMemoryError er)
{
new OOMWarning("calculating PaSiMap", er);
return;
} finally
{
- progressBar.setProgressBar("", progId);
+ if (!getPasimapModel().isCancelled()) {
+ // finish up the progress bar if we weren't cancelled.
+ progressBar.setProgressBar("", progId);
+ }
}
repaint();
- if (getParent() == null)
+ if (!getPasimapModel().isCancelled() && getParent() == null)
{
Desktop.addInternalFrame(this,
MessageManager.formatMessage("label.calc_title", "PaSiMap",
public static final String PROGRESS = "progress";
+ private volatile boolean cancelled;
+
private int total;
private int progress;
public void calculate(ScoreMatrix sm)
{
-
+ cancelled=false;
StringBuilder sb = new StringBuilder(1024);
sequences = new Vector<SequenceI>();
alignmentScores[i - 1][i - 1] = Float.NaN;
for (int j = 0; j < i; j++)
{
+ if (cancelled)
+ {
+ alignmentOutput = "Alignment was cancelled.";
+ return;
+ }
AlignSeq as = new AlignSeq(seqs[i], seqStrings[i], seqs[j],
seqStrings[j], type, GAP_OPEN_COST, GAP_EXTEND_COST);
{
discardAlignments = discard;
}
+
+ public boolean isCancelled()
+ {
+ return cancelled;
+ }
}