toImageJ(Collection extends ROIWrapper> rois, S
}
+ /**
+ * Combines a list of ROIs into a single ROI.
+ * {@code SHAPE_ID} property is the concatenation of shape IDs.
+ *
+ * @param rois The ROIs to combine (must contain at least 1 element).
+ *
+ * @return See above.
+ */
+ private static ij.gui.Roi xor(Collection extends ij.gui.Roi> rois) {
+ String idProperty = GenericShapeWrapper.IJ_IDPROPERTY;
+ String shapeIDs = rois.stream()
+ .map(r -> r.getProperty(idProperty))
+ .collect(Collectors.joining(","));
+
+ ij.gui.Roi roi = rois.iterator().next();
+ if (rois.size() > 1) {
+ ij.gui.Roi xor = rois.stream()
+ .map(ShapeRoi::new)
+ .reduce(ShapeRoi::xor)
+ .map(ij.gui.Roi.class::cast)
+ .orElse(roi);
+ xor.setStrokeColor(roi.getStrokeColor());
+ xor.setFillColor(roi.getFillColor());
+ xor.setPosition(roi.getCPosition(), roi.getZPosition(), roi.getTPosition());
+ xor.setName(roi.getName());
+ xor.setProperty(idProperty, shapeIDs);
+ roi = xor;
+ }
+ return roi;
+ }
+
+
+ /**
+ * Combines a list of points into a single PointRoi.
+ *
+ * @param points The points to combine (must contain at least 1 element).
+ *
+ * @return See above.
+ */
+ private static PointRoi combine(Collection extends PointRoi> points) {
+ String idProperty = GenericShapeWrapper.IJ_IDPROPERTY;
+ String shapeIDs = points.stream()
+ .map(p -> p.getProperty(idProperty))
+ .collect(Collectors.joining(","));
+
+ PointRoi point = points.iterator().next();
+ points.stream()
+ .skip(1)
+ .forEachOrdered(p -> point.addPoint(p.getXBase(), p.getYBase()));
+ point.setProperty(idProperty, shapeIDs);
+ return point;
+ }
+
+
+ /**
+ * Converts a shape to an ImageJ ROI and adds a name if there is none.
+ *
+ * @param shape The shape to convert.
+ *
+ * @return See above.
+ */
+ private ij.gui.Roi shapeToIJRoiWithName(GenericShapeWrapper> shape) {
+ ij.gui.Roi roi = shape.toImageJ();
+ String name = roi.getName();
+ String defaultName = String.format("%d-%d", getId(), shape.getId());
+ if (name.isEmpty()) {
+ roi.setName(defaultName);
+ }
+ return roi;
+ }
+
+
/**
* Gets the ROI name.
*
@@ -338,7 +409,9 @@ public void addShape(GenericShapeWrapper> shape) {
public ShapeList getShapes() {
List shapeData = data.getShapes();
ShapeList shapes = new ShapeList(shapeData.size());
- shapeData.stream().sorted(Comparator.comparing(ShapeData::getId)).forEach(shapes::add);
+ shapeData.stream()
+ .sorted(Comparator.comparing(ShapeData::getId))
+ .forEachOrdered(shapes::add);
return shapes;
}
@@ -454,6 +527,10 @@ public List toImageJ() {
*/
public List toImageJ(String property) {
property = checkProperty(property);
+ String ijIDProperty = ijIDProperty(property);
+ String ijNameProperty = ijNameProperty(property);
+ String roiID = String.valueOf(getId());
+
ShapeList shapes = getShapes();
Map>> sameSlice = shapes.stream()
@@ -463,28 +540,39 @@ public List toImageJ(String property) {
sameSlice.values().removeIf(List::isEmpty);
List rois = new ArrayList<>(shapes.size());
for (List> slice : sameSlice.values()) {
- GenericShapeWrapper> shape = slice.iterator().next();
-
- ij.gui.Roi roi = shape.toImageJ();
- String txt = shape.getText();
- if (slice.size() > 1) {
- ij.gui.Roi xor = slice.stream()
- .map(GenericShapeWrapper::toImageJ)
- .map(ShapeRoi::new)
- .reduce(ShapeRoi::xor)
- .map(ij.gui.Roi.class::cast)
- .orElse(roi);
- xor.setStrokeColor(roi.getStrokeColor());
- xor.setPosition(roi.getCPosition(), roi.getZPosition(), roi.getTPosition());
- roi = xor;
+ // Handle 2D shapes using XOR (Rectangles, Ellipses and Polygons)
+ List toXOR = slice.stream()
+ .filter(s -> (s instanceof RectangleWrapper)
+ || (s instanceof EllipseWrapper)
+ || (s instanceof PolygonWrapper))
+ .map(this::shapeToIJRoiWithName)
+ .collect(Collectors.toList());
+ if (!toXOR.isEmpty()) {
+ rois.add(xor(toXOR));
}
- if (txt.isEmpty()) {
- roi.setName(String.format("%d-%d", getId(), shape.getId()));
- } else {
- roi.setName(txt);
+
+ // Handle points by combining them
+ List points = slice.stream()
+ .filter(PointWrapper.class::isInstance)
+ .map(this::shapeToIJRoiWithName)
+ .map(PointRoi.class::cast)
+ .collect(Collectors.toList());
+ if (!points.isEmpty()) {
+ rois.add(combine(points));
}
- roi.setProperty(ijIDProperty(property), String.valueOf(getId()));
- rois.add(roi);
+
+ // Simply convert and add the others
+ slice.stream()
+ .filter(s -> !(s instanceof RectangleWrapper)
+ && !(s instanceof EllipseWrapper)
+ && !(s instanceof PolygonWrapper)
+ && !(s instanceof PointWrapper))
+ .map(this::shapeToIJRoiWithName)
+ .forEachOrdered(rois::add);
+
+ // Add properties
+ rois.forEach(r -> r.setProperty(ijIDProperty, roiID));
+ rois.forEach(r -> r.setProperty(ijNameProperty, getName()));
}
return rois;
}
diff --git a/src/main/java/fr/igred/omero/roi/RectangleWrapper.java b/src/main/java/fr/igred/omero/roi/RectangleWrapper.java
index 06b47e90..df2d6210 100644
--- a/src/main/java/fr/igred/omero/roi/RectangleWrapper.java
+++ b/src/main/java/fr/igred/omero/roi/RectangleWrapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/main/java/fr/igred/omero/roi/ShapeList.java b/src/main/java/fr/igred/omero/roi/ShapeList.java
index cce1f3fc..f9fe30f7 100644
--- a/src/main/java/fr/igred/omero/roi/ShapeList.java
+++ b/src/main/java/fr/igred/omero/roi/ShapeList.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/main/java/fr/igred/omero/roi/TextWrapper.java b/src/main/java/fr/igred/omero/roi/TextWrapper.java
index a9c5cfe9..ad2568ce 100644
--- a/src/main/java/fr/igred/omero/roi/TextWrapper.java
+++ b/src/main/java/fr/igred/omero/roi/TextWrapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/main/java/fr/igred/omero/roi/package-info.java b/src/main/java/fr/igred/omero/roi/package-info.java
index b2901e72..f377c2c0 100644
--- a/src/main/java/fr/igred/omero/roi/package-info.java
+++ b/src/main/java/fr/igred/omero/roi/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/main/java/fr/igred/omero/util/LibraryChecker.java b/src/main/java/fr/igred/omero/util/LibraryChecker.java
index 013dda5b..1de59670 100644
--- a/src/main/java/fr/igred/omero/util/LibraryChecker.java
+++ b/src/main/java/fr/igred/omero/util/LibraryChecker.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/main/java/fr/igred/omero/util/Wrapper.java b/src/main/java/fr/igred/omero/util/Wrapper.java
index 40276ceb..cd94e94e 100644
--- a/src/main/java/fr/igred/omero/util/Wrapper.java
+++ b/src/main/java/fr/igred/omero/util/Wrapper.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/main/java/fr/igred/omero/util/package-info.java b/src/main/java/fr/igred/omero/util/package-info.java
index 06c28503..1ac1583a 100644
--- a/src/main/java/fr/igred/omero/util/package-info.java
+++ b/src/main/java/fr/igred/omero/util/package-info.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/BasicTest.java b/src/test/java/fr/igred/omero/BasicTest.java
index 74ca4cfe..f56df760 100644
--- a/src/test/java/fr/igred/omero/BasicTest.java
+++ b/src/test/java/fr/igred/omero/BasicTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/ClientTest.java b/src/test/java/fr/igred/omero/ClientTest.java
index 1be2b7c2..440e19b2 100644
--- a/src/test/java/fr/igred/omero/ClientTest.java
+++ b/src/test/java/fr/igred/omero/ClientTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/ConnectionTest.java b/src/test/java/fr/igred/omero/ConnectionTest.java
index c2a7e7e4..0c2daa1d 100644
--- a/src/test/java/fr/igred/omero/ConnectionTest.java
+++ b/src/test/java/fr/igred/omero/ConnectionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/LoggingExtension.java b/src/test/java/fr/igred/omero/LoggingExtension.java
index 96ecce10..239da804 100644
--- a/src/test/java/fr/igred/omero/LoggingExtension.java
+++ b/src/test/java/fr/igred/omero/LoggingExtension.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/RootTest.java b/src/test/java/fr/igred/omero/RootTest.java
index c2d5227b..52a428f2 100644
--- a/src/test/java/fr/igred/omero/RootTest.java
+++ b/src/test/java/fr/igred/omero/RootTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/SudoTest.java b/src/test/java/fr/igred/omero/SudoTest.java
index 37577fd6..1034a93f 100644
--- a/src/test/java/fr/igred/omero/SudoTest.java
+++ b/src/test/java/fr/igred/omero/SudoTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/TestObject.java b/src/test/java/fr/igred/omero/TestObject.java
index cb7d15ad..3cacbf1c 100644
--- a/src/test/java/fr/igred/omero/TestObject.java
+++ b/src/test/java/fr/igred/omero/TestObject.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/UserTest.java b/src/test/java/fr/igred/omero/UserTest.java
index 52bfaa2d..8cdbe7fe 100644
--- a/src/test/java/fr/igred/omero/UserTest.java
+++ b/src/test/java/fr/igred/omero/UserTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java b/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java
index 80e12674..4ef776dc 100644
--- a/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java
+++ b/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/annotations/MapAnnotationTest.java b/src/test/java/fr/igred/omero/annotations/MapAnnotationTest.java
index ac3e5c61..1f064d80 100644
--- a/src/test/java/fr/igred/omero/annotations/MapAnnotationTest.java
+++ b/src/test/java/fr/igred/omero/annotations/MapAnnotationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/annotations/RatingAnnotationTest.java b/src/test/java/fr/igred/omero/annotations/RatingAnnotationTest.java
index adb141f3..31aa2676 100644
--- a/src/test/java/fr/igred/omero/annotations/RatingAnnotationTest.java
+++ b/src/test/java/fr/igred/omero/annotations/RatingAnnotationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/annotations/TableTest.java b/src/test/java/fr/igred/omero/annotations/TableTest.java
index fdf33d07..14983c2e 100644
--- a/src/test/java/fr/igred/omero/annotations/TableTest.java
+++ b/src/test/java/fr/igred/omero/annotations/TableTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/annotations/TagSetTest.java b/src/test/java/fr/igred/omero/annotations/TagSetTest.java
index 4cd4c500..d060ed6c 100644
--- a/src/test/java/fr/igred/omero/annotations/TagSetTest.java
+++ b/src/test/java/fr/igred/omero/annotations/TagSetTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/annotations/TagTest.java b/src/test/java/fr/igred/omero/annotations/TagTest.java
index 58dc5ec5..167764ae 100644
--- a/src/test/java/fr/igred/omero/annotations/TagTest.java
+++ b/src/test/java/fr/igred/omero/annotations/TagTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/annotations/TextualAnnotationTest.java b/src/test/java/fr/igred/omero/annotations/TextualAnnotationTest.java
index 31da2282..77c4fbe2 100644
--- a/src/test/java/fr/igred/omero/annotations/TextualAnnotationTest.java
+++ b/src/test/java/fr/igred/omero/annotations/TextualAnnotationTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/exception/AccessExceptionTest.java b/src/test/java/fr/igred/omero/exception/AccessExceptionTest.java
index 1aa86fdb..eef9712d 100644
--- a/src/test/java/fr/igred/omero/exception/AccessExceptionTest.java
+++ b/src/test/java/fr/igred/omero/exception/AccessExceptionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/exception/ExceptionTest.java b/src/test/java/fr/igred/omero/exception/ExceptionTest.java
index 80d49805..7fb5dca3 100644
--- a/src/test/java/fr/igred/omero/exception/ExceptionTest.java
+++ b/src/test/java/fr/igred/omero/exception/ExceptionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/meta/ExperimenterTest.java b/src/test/java/fr/igred/omero/meta/ExperimenterTest.java
index fce13742..029b13d9 100644
--- a/src/test/java/fr/igred/omero/meta/ExperimenterTest.java
+++ b/src/test/java/fr/igred/omero/meta/ExperimenterTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/meta/GroupTest.java b/src/test/java/fr/igred/omero/meta/GroupTest.java
index a2e35a3e..9784c0f6 100644
--- a/src/test/java/fr/igred/omero/meta/GroupTest.java
+++ b/src/test/java/fr/igred/omero/meta/GroupTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/meta/PlaneInfoWrapperTest.java b/src/test/java/fr/igred/omero/meta/PlaneInfoWrapperTest.java
index a8a4a14c..a5aea1dc 100644
--- a/src/test/java/fr/igred/omero/meta/PlaneInfoWrapperTest.java
+++ b/src/test/java/fr/igred/omero/meta/PlaneInfoWrapperTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/ChannelTest.java b/src/test/java/fr/igred/omero/repository/ChannelTest.java
index e8f2d9df..b0859714 100644
--- a/src/test/java/fr/igred/omero/repository/ChannelTest.java
+++ b/src/test/java/fr/igred/omero/repository/ChannelTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/DatasetTest.java b/src/test/java/fr/igred/omero/repository/DatasetTest.java
index 761f7156..2ea85f58 100644
--- a/src/test/java/fr/igred/omero/repository/DatasetTest.java
+++ b/src/test/java/fr/igred/omero/repository/DatasetTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/FolderTest.java b/src/test/java/fr/igred/omero/repository/FolderTest.java
index 2438ef56..3c7e32d7 100644
--- a/src/test/java/fr/igred/omero/repository/FolderTest.java
+++ b/src/test/java/fr/igred/omero/repository/FolderTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/ImageImportTest.java b/src/test/java/fr/igred/omero/repository/ImageImportTest.java
index 0d1890c4..00b45297 100644
--- a/src/test/java/fr/igred/omero/repository/ImageImportTest.java
+++ b/src/test/java/fr/igred/omero/repository/ImageImportTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/ImageTest.java b/src/test/java/fr/igred/omero/repository/ImageTest.java
index 1bf4e778..771f8a30 100644
--- a/src/test/java/fr/igred/omero/repository/ImageTest.java
+++ b/src/test/java/fr/igred/omero/repository/ImageTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/PixelsTest.java b/src/test/java/fr/igred/omero/repository/PixelsTest.java
index 4e03e1cd..d11a49b7 100644
--- a/src/test/java/fr/igred/omero/repository/PixelsTest.java
+++ b/src/test/java/fr/igred/omero/repository/PixelsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/PlateAcquisitionTest.java b/src/test/java/fr/igred/omero/repository/PlateAcquisitionTest.java
index 3d5206aa..398251ad 100644
--- a/src/test/java/fr/igred/omero/repository/PlateAcquisitionTest.java
+++ b/src/test/java/fr/igred/omero/repository/PlateAcquisitionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/PlateTest.java b/src/test/java/fr/igred/omero/repository/PlateTest.java
index 5aa4d280..122a564c 100644
--- a/src/test/java/fr/igred/omero/repository/PlateTest.java
+++ b/src/test/java/fr/igred/omero/repository/PlateTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/ProjectTest.java b/src/test/java/fr/igred/omero/repository/ProjectTest.java
index ba3c6838..81332865 100644
--- a/src/test/java/fr/igred/omero/repository/ProjectTest.java
+++ b/src/test/java/fr/igred/omero/repository/ProjectTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/ScreenTest.java b/src/test/java/fr/igred/omero/repository/ScreenTest.java
index a404a77e..0d27d54b 100644
--- a/src/test/java/fr/igred/omero/repository/ScreenTest.java
+++ b/src/test/java/fr/igred/omero/repository/ScreenTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/WellSampleTest.java b/src/test/java/fr/igred/omero/repository/WellSampleTest.java
index 980fe691..82d46171 100644
--- a/src/test/java/fr/igred/omero/repository/WellSampleTest.java
+++ b/src/test/java/fr/igred/omero/repository/WellSampleTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/repository/WellTest.java b/src/test/java/fr/igred/omero/repository/WellTest.java
index f19c8587..5c5d68af 100644
--- a/src/test/java/fr/igred/omero/repository/WellTest.java
+++ b/src/test/java/fr/igred/omero/repository/WellTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/roi/ROI2ImageJTest.java b/src/test/java/fr/igred/omero/roi/ROI2ImageJTest.java
index 672d3815..2876a873 100644
--- a/src/test/java/fr/igred/omero/roi/ROI2ImageJTest.java
+++ b/src/test/java/fr/igred/omero/roi/ROI2ImageJTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
@@ -31,8 +31,11 @@
import ij.gui.ShapeRoi;
import ij.gui.TextRoi;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import java.awt.Color;
+import java.awt.Font;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
@@ -41,7 +44,9 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNull;
@@ -325,23 +330,40 @@ void convertMask() {
MaskWrapper mask = new MaskWrapper();
mask.setCoordinates(3, 3, 10, 10);
mask.setCZT(0, 0, 2);
+ mask.setFill(Color.WHITE);
- Roi ijRectangle = mask.toImageJ();
- assertEquals(mask.toAWTShape().getBounds(), ijRectangle.getBounds());
+ int[][] maskPixels = new int[10][10];
+ for (int i = 0; i < 10; i++) {
+ for (int j = 0; j < 10; j++) {
+ if (i > 3 && i < 7 && j > 4 && j < 8) {
+ maskPixels[i][j] = 1;
+ }
+ }
+ }
+ mask.setMask(maskPixels);
+
+ Roi imgRoi = mask.toImageJ();
+ assertEquals(mask.toAWTShape().getBounds(), imgRoi.getBounds());
List roiList = new ArrayList<>(1);
- roiList.add(ijRectangle);
+ roiList.add(imgRoi);
ROIWrapper roi = ROIWrapper.fromImageJ(roiList).get(0);
- RectangleWrapper newRectangle = roi.getShapes().getElementsOf(RectangleWrapper.class).get(0);
+ MaskWrapper newMask = roi.getShapes().getElementsOf(MaskWrapper.class).get(0);
+ int[][] checkMask = newMask.getMaskAsBinaryArray();
+
+ assertEquals(mask.getX(), newMask.getX(), Double.MIN_VALUE);
+ assertEquals(mask.getY(), newMask.getY(), Double.MIN_VALUE);
+ assertEquals(mask.getWidth(), newMask.getWidth(), Double.MIN_VALUE);
+ assertEquals(mask.getHeight(), newMask.getHeight(), Double.MIN_VALUE);
+ assertEquals(mask.getC(), newMask.getC());
+ assertEquals(mask.getZ(), newMask.getZ());
+ assertEquals(mask.getT(), newMask.getT());
+ assertEquals(maskPixels.length, checkMask.length);
+ for (int i = 0; i < maskPixels.length; i++) {
+ assertArrayEquals(maskPixels[i], checkMask[i]);
+ }
- assertEquals(mask.getX(), newRectangle.getX(), Double.MIN_VALUE);
- assertEquals(mask.getY(), newRectangle.getY(), Double.MIN_VALUE);
- assertEquals(mask.getWidth(), newRectangle.getWidth(), Double.MIN_VALUE);
- assertEquals(mask.getHeight(), newRectangle.getHeight(), Double.MIN_VALUE);
- assertEquals(mask.getC(), newRectangle.getC());
- assertEquals(mask.getZ(), newRectangle.getZ());
- assertEquals(mask.getT(), newRectangle.getT());
}
@@ -399,6 +421,30 @@ void convertText() {
}
+ @ParameterizedTest(name = "{0}")
+ @ValueSource(ints = {Font.PLAIN, Font.BOLD, Font.ITALIC, Font.BOLD | Font.ITALIC})
+ void convertText(int style) {
+ Font font = new Font("Arial", style, 25);
+ List roiList = new ArrayList<>(1);
+ TextRoi ijText = new TextRoi(3, 3, "Text");
+ ijText.setAngle(33);
+ ijText.setFont(font);
+ roiList.add(ijText);
+
+ Roi ijRoi = ROIWrapper.toImageJ(ROIWrapper.fromImageJ(roiList)).get(0);
+
+ assertInstanceOf(TextRoi.class, ijRoi);
+ assertEquals(ijText.getXBase(), ijRoi.getXBase(), Double.MIN_VALUE);
+ assertEquals(ijText.getYBase(), ijRoi.getYBase(), Double.MIN_VALUE);
+ assertEquals(ijText.getAngle(), ijRoi.getAngle(), Double.MIN_VALUE);
+
+ Font newFont = ((TextRoi) ijRoi).getCurrentFont();
+ assertEquals(font.getFamily(), newFont.getFamily());
+ assertEquals(font.getStyle(), newFont.getStyle());
+ assertEquals(font.getSize(), newFont.getSize());
+ }
+
+
@Test
void convertPolygon() {
List points2D = new ArrayList<>(3);
diff --git a/src/test/java/fr/igred/omero/roi/ROITest.java b/src/test/java/fr/igred/omero/roi/ROITest.java
index 467708a2..4006f0ef 100644
--- a/src/test/java/fr/igred/omero/roi/ROITest.java
+++ b/src/test/java/fr/igred/omero/roi/ROITest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/roi/ShapeErrorTest.java b/src/test/java/fr/igred/omero/roi/ShapeErrorTest.java
index 83849b33..fe1c8751 100644
--- a/src/test/java/fr/igred/omero/roi/ShapeErrorTest.java
+++ b/src/test/java/fr/igred/omero/roi/ShapeErrorTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/roi/ShapeTest.java b/src/test/java/fr/igred/omero/roi/ShapeTest.java
index 9b4d3821..32ffd4b4 100644
--- a/src/test/java/fr/igred/omero/roi/ShapeTest.java
+++ b/src/test/java/fr/igred/omero/roi/ShapeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/util/LibraryCheckerTest.java b/src/test/java/fr/igred/omero/util/LibraryCheckerTest.java
index 4f1ab800..d8fb8056 100644
--- a/src/test/java/fr/igred/omero/util/LibraryCheckerTest.java
+++ b/src/test/java/fr/igred/omero/util/LibraryCheckerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
diff --git a/src/test/java/fr/igred/omero/util/WrapperTest.java b/src/test/java/fr/igred/omero/util/WrapperTest.java
index 54b0a5c2..ca5aa2b7 100644
--- a/src/test/java/fr/igred/omero/util/WrapperTest.java
+++ b/src/test/java/fr/igred/omero/util/WrapperTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2020-2023 GReD
+ * Copyright (C) 2020-2024 GReD
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software