From b5855e88b25b8e3351f54a2a76db3980ef2f1331 Mon Sep 17 00:00:00 2001
From: Stephane Dallongeville <stephane.dallongeville@pasteur.fr>
Date: Wed, 1 Dec 2021 14:25:28 +0100
Subject: [PATCH] Updated for Icy kernel 2.4.0 (interruptible process)

---
 pom.xml                                            |  4 ++--
 .../stef/roi/quantify/PathIntensityProfiler.java   | 14 ++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2bf68fe..42b022e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -8,12 +8,12 @@
     <parent>
         <groupId>org.bioimageanalysis.icy</groupId>
         <artifactId>parent-pom-plugin</artifactId>
-        <version>1.0.3</version>
+        <version>1.0.6</version>
     </parent>
 
     <!-- Project Information -->
     <artifactId>path-intensity-profiler</artifactId>
-    <version>1.2.2</version>
+    <version>1.2.3</version>
 
     <packaging>jar</packaging>
 
diff --git a/src/main/java/plugins/stef/roi/quantify/PathIntensityProfiler.java b/src/main/java/plugins/stef/roi/quantify/PathIntensityProfiler.java
index ff206a0..462a505 100644
--- a/src/main/java/plugins/stef/roi/quantify/PathIntensityProfiler.java
+++ b/src/main/java/plugins/stef/roi/quantify/PathIntensityProfiler.java
@@ -11,6 +11,7 @@ import javax.swing.JComponent;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 
 import icy.gui.dialog.MessageDialog;
+import icy.gui.frame.progress.FailedAnnounceFrame;
 import icy.math.Line3DIterator;
 import icy.math.MathUtil;
 import icy.roi.BooleanMask2D;
@@ -18,6 +19,7 @@ import icy.roi.ROI;
 import icy.roi.ROI2D;
 import icy.roi.ROI3D;
 import icy.sequence.Sequence;
+import icy.system.IcyExceptionHandler;
 import icy.type.collection.CollectionUtil;
 import icy.type.geom.Line3D;
 import icy.type.point.Point3D;
@@ -171,6 +173,14 @@ public class PathIntensityProfiler extends EzPlug implements Block, EzStoppable
                 varWorkbook.setValue(
                         getPathIntensityProfil(sequence, validRois, varRealUnit.getValue().booleanValue(), getUI()));
             }
+            catch (IllegalArgumentException e)
+            {
+                IcyExceptionHandler.handleException(e, true);
+            }
+            catch (InterruptedException e)
+            {
+                new FailedAnnounceFrame("Path intensity profile process interrupted..");
+            }
             finally
             {
                 // interactive mode
@@ -187,8 +197,10 @@ public class PathIntensityProfiler extends EzPlug implements Block, EzStoppable
      * Computes intensity profil along path (contour for area ROI) for the given list of ROI.
      * 
      * @return result in a XLSX workbook where we have one sheet per ROI.
+     * @throws InterruptedException
      */
     private static XSSFWorkbook getPathIntensityProfil(Sequence sequence, List<ROI> rois, boolean useRealUnit, EzGUI ui)
+            throws InterruptedException
     {
         final XSSFWorkbook result = (XSSFWorkbook) Workbooks.createEmptyWorkbook(WorkbookFormat.XLSX);
 
@@ -401,8 +413,10 @@ public class PathIntensityProfiler extends EzPlug implements Block, EzStoppable
      * Computes intensity profil along path (contour for area ROI) for the given list of ROI.<br>
      * 
      * @return result in a XLSX workbook where we have one sheet per ROI.
+     * @throws InterruptedException
      */
     public static XSSFWorkbook getPathIntensityProfil(Sequence sequence, List<ROI> rois, boolean useRealUnit)
+            throws InterruptedException
     {
         return getPathIntensityProfil(sequence, rois, useRealUnit, null);
     }
-- 
GitLab