Added error message for Van-Krevelen diagrams
@@ -100,11 +100,18 @@ public class VanKrevelenDiagramTask extends AbstractTask {
@Override
public void run() {
+ try {
setStatus(TaskStatus.PROCESSING);
logger.info("Create Van Krevelen diagram of " + peakList);
// Task canceled?
if (isCanceled())
return;
+ // Check for identities
+ if (hasNoIdentity()) {
+ throw new IllegalArgumentException(
+ "Nothing to plot here.\n" + "Have you annotated your features with sum formulas?\n"
+ + "You can use the peak list method \"Formula prediction\" to handle the task.");
+ }
JFreeChart chart = null;
// 2D, if no third dimension was selected
if (zAxisLabel.equals("none")) {
@@ -136,6 +143,11 @@ public class VanKrevelenDiagramTask extends AbstractTask {
frame.pack();
setStatus(TaskStatus.FINISHED);
logger.info("Finished creating van Krevelen diagram of " + peakList);
+
+ } catch (Throwable t) {
+ setErrorMessage(t.getMessage());
+ setStatus(TaskStatus.ERROR);
+ }
}
/**
@@ -290,4 +302,20 @@ public class VanKrevelenDiagramTask extends AbstractTask {
return chart;
}
+ // Check for peak identities
+ private boolean hasNoIdentity() {
+ Boolean hasNoIdentity = true;
+ int countIdentities = 0;
+ for (PeakListRow row : rows) {
+ if (row.getPreferredPeakIdentity() != null) {
+ hasNoIdentity = false;
+ countIdentities++;
+ }
+ if (countIdentities > 0) {
+ break;
+ }
+ }
+ return hasNoIdentity;
+ }
+
}
