private MatrixI eigenMatrix;
+ private volatile boolean canCancel;
+
/**
* Constructor given the sequences to compute for, the similarity model to
* use, and a set of parameters for sequence comparison
@Override
public void run()
{
+ canCancel=true;
try
{
// alignment = new PairwiseAlignPanel(seqs, true, 100, 5);
cancel();
return;
}
+ //alignment.setProgressMessage("Preparing to calculate pasimap...");
float[][] scores = alignment.getAlignmentScores(); // bigger index first
// -- eg scores[14][13]
SequenceI[] iseqs = alignment.getInputSequences();
Connectivity.getConnectivity(iseqs, scores, dim);
-
+
+ canCancel=false;
+ alignment.updateProgress(PairwiseAlignPanel.PROGRESSMESSAGE, "Creating the PaSiMap");
pairwiseScores = new Matrix(scores);
pairwiseScores.fillDiagonal();
ccAnalysis cc = new ccAnalysis(pairwiseScores, dim);
eigenMatrix = cc.run().mirrorCol();
+ alignment.updateProgress(PairwiseAlignPanel.PROGRESSCOMPLETE, "Finished PaSiMap.");
} catch (Exception q)
{
{
return dim;
}
+
+ /**
+ *
+ * @return true if pasimap calculation can (still) be interrupted
+ */
+ public boolean isCancellable()
+ {
+ return canCancel;
+ }
}
addProgressListenerFor(pap);
progressBar.registerHandler(progId, new IProgressIndicatorHandler()
{
-
@Override
public boolean cancelActivity(long id)
{
@Override
public boolean canCancel()
{
- return true;
+ return getPasimapModel().canCancel();
}
});
-
getPasimapModel().calculate(pap);
if (!getPasimapModel().isCancelled())
{
{
updateProgressBarEta((double) pcEvent.getNewValue());
}
+ else if (PairwiseAlignPanel.PROGRESSMESSAGE.equals(pcEvent.getPropertyName()))
+ {
+ setProgressBarMessage(progId, (String) pcEvent.getNewValue());
+ }
+ else if (PairwiseAlignPanel.PROGRESSCOMPLETE.equals(pcEvent.getPropertyName()))
+ {
+ setProgressBarMessage(progId, (String) pcEvent.getNewValue());
+ }
}
});
}
protected static final String ETA = "eta_in_minutes";
+ public static final String PROGRESSCOMPLETE = "finished_stop_progress";
+ public static final String PROGRESSMESSAGE = "message_in_progress";
+
private volatile boolean cancelled;
private long total;
{
return cancelled;
}
+
+ /**
+ * sends status updates to the progress bar for this panel
+ * @param type - PROGRESSMESSAGE or PROGRESSCOMPLETE
+ * @param message - the message (may be internationalised key)
+ */
+ public void updateProgress(String type, String message)
+ {
+ firePropertyChange(type, "", MessageManager.getStringOrReturn("progress", message));
+ }
}
"call setProgressBar before registering the progress bar's handler.");
return;
}
-
- /*
- * Nothing useful to do if not a Cancel handler
- */
- if (!handler.canCancel())
- {
- return;
- }
-
progressBarHandlers.put(id, handler);
JButton cancel = new JButton(
MessageManager.getString("action.cancel"));
}
});
progressPanel.add(cancel, BorderLayout.EAST);
- refreshLayout();
+ updateCancelHandler(progressPanel, handler);
}
});
}
+ protected void updateCancelHandler(Container progressPanel, IProgressIndicatorHandler handler)
+ {
+ for (Component j:progressPanel.getComponents())
+ {
+ if (j instanceof JButton)
+ {
+ j.setEnabled(handler.canCancel());
+ }
+ }
+ refreshLayout();
+ }
/*
*
{
if (component.getClass().equals(JLabel.class))
{
- ((JLabel) component).setText(message);;
- refreshLayout();
+ ((JLabel) component).setText(message);
+ IProgressIndicatorHandler handler = progressBarHandlers.get(id);
+ if (handler!=null) {
+ // show/hide cancel on message change
+ updateCancelHandler(progBar, handler);
+ } else {
+ refreshLayout();
+ }
}
}
}
{
pasimap.cancel();
}
+
+ public boolean canCancel()
+ {
+ return (!isCancelled() && pasimap.isCancellable());
+ }
}