From 7ca0b96df06cad84814480ace1f26b5e51f83f41 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Thu, 21 Nov 2024 18:18:02 +0100 Subject: [PATCH 01/10] Reorder imports and update headers --- .../fr/igred/omero/AnnotatableWrapper.java | 2 +- .../igred/omero/RepositoryObjectWrapper.java | 3 ++- .../omero/annotations/AnnotationWrapper.java | 8 +++--- .../java/fr/igred/omero/client/Browser.java | 8 +++--- .../java/fr/igred/omero/client/Client.java | 6 ++--- .../fr/igred/omero/client/package-info.java | 2 +- .../omero/containers/DatasetWrapper.java | 8 +++--- .../igred/omero/containers/FolderWrapper.java | 6 ++--- .../omero/containers/ProjectWrapper.java | 8 +++--- .../fr/igred/omero/core/ImageWrapper.java | 10 +++---- .../fr/igred/omero/core/PixelsWrapper.java | 4 +-- .../fr/igred/omero/core/package-info.java | 2 +- .../igred/omero/meta/ExperimenterWrapper.java | 2 +- .../java/fr/igred/omero/roi/ROIWrapper.java | 8 +++--- .../fr/igred/omero/screen/PlateWrapper.java | 2 +- .../igred/omero/screen/WellSampleWrapper.java | 2 +- .../fr/igred/omero/screen/package-info.java | 2 +- .../java/fr/igred/omero/util/Wrapper.java | 26 +++++++++---------- .../omero/annotations/ImageJTableTest.java | 4 +-- .../fr/igred/omero/annotations/TagTest.java | 2 +- .../fr/igred/omero/client/ClientTest.java | 6 ++--- .../java/fr/igred/omero/core/ImageTest.java | 2 +- .../omero/exception/AccessExceptionTest.java | 4 +-- .../java/fr/igred/omero/util/WrapperTest.java | 20 +++++++------- 24 files changed, 74 insertions(+), 73 deletions(-) diff --git a/src/main/java/fr/igred/omero/AnnotatableWrapper.java b/src/main/java/fr/igred/omero/AnnotatableWrapper.java index 6daf551c..a40b84e9 100644 --- a/src/main/java/fr/igred/omero/AnnotatableWrapper.java +++ b/src/main/java/fr/igred/omero/AnnotatableWrapper.java @@ -18,6 +18,7 @@ package fr.igred.omero; +import fr.igred.omero.RepositoryObjectWrapper.ReplacePolicy; import fr.igred.omero.annotations.AnnotationList; import fr.igred.omero.annotations.AnnotationWrapper; import fr.igred.omero.annotations.FileAnnotationWrapper; @@ -28,7 +29,6 @@ import fr.igred.omero.client.Client; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ServiceException; -import fr.igred.omero.RepositoryObjectWrapper.ReplacePolicy; import omero.gateway.facility.TablesFacility; import omero.gateway.model.AnnotationData; import omero.gateway.model.DataObject; diff --git a/src/main/java/fr/igred/omero/RepositoryObjectWrapper.java b/src/main/java/fr/igred/omero/RepositoryObjectWrapper.java index e2ae7936..f5e02757 100644 --- a/src/main/java/fr/igred/omero/RepositoryObjectWrapper.java +++ b/src/main/java/fr/igred/omero/RepositoryObjectWrapper.java @@ -78,7 +78,8 @@ protected RepositoryObjectWrapper(T o) { * * @return The list of imported pixels. */ - private static List importCandidates(DataObject target, ImportLibrary library, ImportConfig config, ImportCandidates candidates) { + private static List importCandidates(DataObject target, ImportLibrary library, ImportConfig config, + ImportCandidates candidates) { List pixels = new ArrayList<>(0); ExecutorService threadPool = Executors.newFixedThreadPool(config.parallelUpload.get()); diff --git a/src/main/java/fr/igred/omero/annotations/AnnotationWrapper.java b/src/main/java/fr/igred/omero/annotations/AnnotationWrapper.java index c2fa4e7c..78f305d5 100644 --- a/src/main/java/fr/igred/omero/annotations/AnnotationWrapper.java +++ b/src/main/java/fr/igred/omero/annotations/AnnotationWrapper.java @@ -18,16 +18,16 @@ package fr.igred.omero.annotations; -import fr.igred.omero.client.Client; import fr.igred.omero.ObjectWrapper; -import fr.igred.omero.exception.AccessException; -import fr.igred.omero.exception.ServiceException; +import fr.igred.omero.client.Client; import fr.igred.omero.containers.DatasetWrapper; import fr.igred.omero.containers.FolderWrapper; +import fr.igred.omero.containers.ProjectWrapper; import fr.igred.omero.core.ImageWrapper; +import fr.igred.omero.exception.AccessException; +import fr.igred.omero.exception.ServiceException; import fr.igred.omero.screen.PlateAcquisitionWrapper; import fr.igred.omero.screen.PlateWrapper; -import fr.igred.omero.containers.ProjectWrapper; import fr.igred.omero.screen.ScreenWrapper; import fr.igred.omero.screen.WellWrapper; import omero.RLong; diff --git a/src/main/java/fr/igred/omero/client/Browser.java b/src/main/java/fr/igred/omero/client/Browser.java index 2698b706..bb201c9e 100644 --- a/src/main/java/fr/igred/omero/client/Browser.java +++ b/src/main/java/fr/igred/omero/client/Browser.java @@ -22,14 +22,14 @@ import fr.igred.omero.annotations.AnnotationWrapper; import fr.igred.omero.annotations.MapAnnotationWrapper; import fr.igred.omero.annotations.TagAnnotationWrapper; -import fr.igred.omero.exception.AccessException; -import fr.igred.omero.exception.ServiceException; -import fr.igred.omero.meta.ExperimenterWrapper; import fr.igred.omero.containers.DatasetWrapper; import fr.igred.omero.containers.FolderWrapper; +import fr.igred.omero.containers.ProjectWrapper; import fr.igred.omero.core.ImageWrapper; +import fr.igred.omero.exception.AccessException; +import fr.igred.omero.exception.ServiceException; +import fr.igred.omero.meta.ExperimenterWrapper; import fr.igred.omero.screen.PlateWrapper; -import fr.igred.omero.containers.ProjectWrapper; import fr.igred.omero.screen.ScreenWrapper; import fr.igred.omero.screen.WellWrapper; import omero.RLong; diff --git a/src/main/java/fr/igred/omero/client/Client.java b/src/main/java/fr/igred/omero/client/Client.java index 4a22485a..13135c59 100644 --- a/src/main/java/fr/igred/omero/client/Client.java +++ b/src/main/java/fr/igred/omero/client/Client.java @@ -21,14 +21,14 @@ import fr.igred.omero.ObjectWrapper; import fr.igred.omero.annotations.AnnotationWrapper; import fr.igred.omero.annotations.TableWrapper; +import fr.igred.omero.containers.FolderWrapper; +import fr.igred.omero.containers.ProjectWrapper; +import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ExceptionHandler; import fr.igred.omero.exception.ServiceException; import fr.igred.omero.meta.ExperimenterWrapper; import fr.igred.omero.meta.GroupWrapper; -import fr.igred.omero.containers.FolderWrapper; -import fr.igred.omero.core.ImageWrapper; -import fr.igred.omero.containers.ProjectWrapper; import omero.ApiUsageException; import omero.gateway.Gateway; import omero.gateway.SecurityContext; diff --git a/src/main/java/fr/igred/omero/client/package-info.java b/src/main/java/fr/igred/omero/client/package-info.java index 3005b5dd..ea92aad1 100644 --- a/src/main/java/fr/igred/omero/client/package-info.java +++ b/src/main/java/fr/igred/omero/client/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/containers/DatasetWrapper.java b/src/main/java/fr/igred/omero/containers/DatasetWrapper.java index ace2e5e8..cb9cb322 100644 --- a/src/main/java/fr/igred/omero/containers/DatasetWrapper.java +++ b/src/main/java/fr/igred/omero/containers/DatasetWrapper.java @@ -18,14 +18,14 @@ package fr.igred.omero.containers; -import fr.igred.omero.client.Browser; -import fr.igred.omero.client.Client; import fr.igred.omero.ObjectWrapper; +import fr.igred.omero.RepositoryObjectWrapper; import fr.igred.omero.annotations.TagAnnotationWrapper; +import fr.igred.omero.client.Browser; +import fr.igred.omero.client.Client; +import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ServiceException; -import fr.igred.omero.core.ImageWrapper; -import fr.igred.omero.RepositoryObjectWrapper; import fr.igred.omero.roi.ROIWrapper; import omero.RLong; import omero.gateway.model.DatasetData; diff --git a/src/main/java/fr/igred/omero/containers/FolderWrapper.java b/src/main/java/fr/igred/omero/containers/FolderWrapper.java index 40788ad6..c62d8b6d 100644 --- a/src/main/java/fr/igred/omero/containers/FolderWrapper.java +++ b/src/main/java/fr/igred/omero/containers/FolderWrapper.java @@ -18,14 +18,14 @@ package fr.igred.omero.containers; +import fr.igred.omero.ObjectWrapper; +import fr.igred.omero.RepositoryObjectWrapper; import fr.igred.omero.client.Browser; import fr.igred.omero.client.Client; -import fr.igred.omero.ObjectWrapper; +import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ExceptionHandler; import fr.igred.omero.exception.ServiceException; -import fr.igred.omero.core.ImageWrapper; -import fr.igred.omero.RepositoryObjectWrapper; import fr.igred.omero.roi.ROIWrapper; import omero.gateway.facility.ROIFacility; import omero.gateway.model.AnnotationData; diff --git a/src/main/java/fr/igred/omero/containers/ProjectWrapper.java b/src/main/java/fr/igred/omero/containers/ProjectWrapper.java index f1c2556c..04ff6363 100644 --- a/src/main/java/fr/igred/omero/containers/ProjectWrapper.java +++ b/src/main/java/fr/igred/omero/containers/ProjectWrapper.java @@ -18,14 +18,14 @@ package fr.igred.omero.containers; -import fr.igred.omero.client.Browser; -import fr.igred.omero.client.Client; import fr.igred.omero.ObjectWrapper; +import fr.igred.omero.RepositoryObjectWrapper; import fr.igred.omero.annotations.TagAnnotationWrapper; +import fr.igred.omero.client.Browser; +import fr.igred.omero.client.Client; +import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ServiceException; -import fr.igred.omero.core.ImageWrapper; -import fr.igred.omero.RepositoryObjectWrapper; import omero.gateway.model.ImageData; import omero.gateway.model.ProjectData; import omero.model.ProjectDatasetLink; diff --git a/src/main/java/fr/igred/omero/core/ImageWrapper.java b/src/main/java/fr/igred/omero/core/ImageWrapper.java index 771cd7ee..4d23d1f4 100644 --- a/src/main/java/fr/igred/omero/core/ImageWrapper.java +++ b/src/main/java/fr/igred/omero/core/ImageWrapper.java @@ -18,23 +18,23 @@ package fr.igred.omero.core; +import fr.igred.omero.ObjectWrapper; +import fr.igred.omero.RepositoryObjectWrapper; import fr.igred.omero.client.Browser; import fr.igred.omero.client.Client; -import fr.igred.omero.ObjectWrapper; import fr.igred.omero.containers.DatasetWrapper; import fr.igred.omero.containers.FolderWrapper; import fr.igred.omero.containers.ProjectWrapper; -import fr.igred.omero.exception.AccessException; -import fr.igred.omero.exception.ServiceException; import fr.igred.omero.core.PixelsWrapper.Bounds; import fr.igred.omero.core.PixelsWrapper.Coordinates; +import fr.igred.omero.exception.AccessException; +import fr.igred.omero.exception.ServiceException; +import fr.igred.omero.roi.ROIWrapper; import fr.igred.omero.screen.PlateAcquisitionWrapper; import fr.igred.omero.screen.PlateWrapper; -import fr.igred.omero.RepositoryObjectWrapper; import fr.igred.omero.screen.ScreenWrapper; import fr.igred.omero.screen.WellSampleWrapper; import fr.igred.omero.screen.WellWrapper; -import fr.igred.omero.roi.ROIWrapper; import ij.CompositeImage; import ij.IJ; import ij.ImagePlus; diff --git a/src/main/java/fr/igred/omero/core/PixelsWrapper.java b/src/main/java/fr/igred/omero/core/PixelsWrapper.java index 5a82f167..5e139c03 100644 --- a/src/main/java/fr/igred/omero/core/PixelsWrapper.java +++ b/src/main/java/fr/igred/omero/core/PixelsWrapper.java @@ -18,8 +18,8 @@ package fr.igred.omero.core; -import fr.igred.omero.client.Client; import fr.igred.omero.ObjectWrapper; +import fr.igred.omero.client.Client; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ExceptionHandler; import fr.igred.omero.exception.ServiceException; @@ -38,8 +38,8 @@ import java.util.List; import java.util.concurrent.ExecutionException; -import static fr.igred.omero.exception.ExceptionHandler.call; import static fr.igred.omero.core.PlaneInfoWrapper.getMinPosition; +import static fr.igred.omero.exception.ExceptionHandler.call; import static ome.formats.model.UnitsFactory.convertLength; diff --git a/src/main/java/fr/igred/omero/core/package-info.java b/src/main/java/fr/igred/omero/core/package-info.java index 922a64fe..2ed4c4d9 100644 --- a/src/main/java/fr/igred/omero/core/package-info.java +++ b/src/main/java/fr/igred/omero/core/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/meta/ExperimenterWrapper.java b/src/main/java/fr/igred/omero/meta/ExperimenterWrapper.java index 067ef61b..59703dcd 100644 --- a/src/main/java/fr/igred/omero/meta/ExperimenterWrapper.java +++ b/src/main/java/fr/igred/omero/meta/ExperimenterWrapper.java @@ -18,8 +18,8 @@ package fr.igred.omero.meta; -import fr.igred.omero.client.Client; import fr.igred.omero.ObjectWrapper; +import fr.igred.omero.client.Client; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ServiceException; import omero.gateway.model.ExperimenterData; diff --git a/src/main/java/fr/igred/omero/roi/ROIWrapper.java b/src/main/java/fr/igred/omero/roi/ROIWrapper.java index 94b9e2b9..2ccb0c05 100644 --- a/src/main/java/fr/igred/omero/roi/ROIWrapper.java +++ b/src/main/java/fr/igred/omero/roi/ROIWrapper.java @@ -19,14 +19,14 @@ import fr.igred.omero.AnnotatableWrapper; -import fr.igred.omero.client.Client; import fr.igred.omero.ObjectWrapper; -import fr.igred.omero.exception.AccessException; -import fr.igred.omero.exception.ExceptionHandler; -import fr.igred.omero.exception.ServiceException; +import fr.igred.omero.client.Client; import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.core.PixelsWrapper.Bounds; import fr.igred.omero.core.PixelsWrapper.Coordinates; +import fr.igred.omero.exception.AccessException; +import fr.igred.omero.exception.ExceptionHandler; +import fr.igred.omero.exception.ServiceException; import ij.IJ; import ij.gui.PointRoi; import ij.gui.ShapeRoi; diff --git a/src/main/java/fr/igred/omero/screen/PlateWrapper.java b/src/main/java/fr/igred/omero/screen/PlateWrapper.java index 152c4941..2f219251 100644 --- a/src/main/java/fr/igred/omero/screen/PlateWrapper.java +++ b/src/main/java/fr/igred/omero/screen/PlateWrapper.java @@ -18,10 +18,10 @@ package fr.igred.omero.screen; +import fr.igred.omero.ObjectWrapper; import fr.igred.omero.RepositoryObjectWrapper; import fr.igred.omero.client.Browser; import fr.igred.omero.client.Client; -import fr.igred.omero.ObjectWrapper; import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ServiceException; diff --git a/src/main/java/fr/igred/omero/screen/WellSampleWrapper.java b/src/main/java/fr/igred/omero/screen/WellSampleWrapper.java index fab9fea2..5c8e16a0 100644 --- a/src/main/java/fr/igred/omero/screen/WellSampleWrapper.java +++ b/src/main/java/fr/igred/omero/screen/WellSampleWrapper.java @@ -18,9 +18,9 @@ package fr.igred.omero.screen; +import fr.igred.omero.ObjectWrapper; import fr.igred.omero.client.Browser; import fr.igred.omero.client.Client; -import fr.igred.omero.ObjectWrapper; import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ServiceException; diff --git a/src/main/java/fr/igred/omero/screen/package-info.java b/src/main/java/fr/igred/omero/screen/package-info.java index fd4d8c28..de4c205c 100644 --- a/src/main/java/fr/igred/omero/screen/package-info.java +++ b/src/main/java/fr/igred/omero/screen/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/Wrapper.java b/src/main/java/fr/igred/omero/util/Wrapper.java index b50dd2c1..31488984 100644 --- a/src/main/java/fr/igred/omero/util/Wrapper.java +++ b/src/main/java/fr/igred/omero/util/Wrapper.java @@ -20,29 +20,23 @@ import fr.igred.omero.AnnotatableWrapper; import fr.igred.omero.ObjectWrapper; -import fr.igred.omero.annotations.FileAnnotationWrapper; +import fr.igred.omero.RepositoryObjectWrapper; import fr.igred.omero.annotations.AnnotationWrapper; +import fr.igred.omero.annotations.FileAnnotationWrapper; import fr.igred.omero.annotations.MapAnnotationWrapper; import fr.igred.omero.annotations.RatingAnnotationWrapper; import fr.igred.omero.annotations.TagAnnotationWrapper; import fr.igred.omero.annotations.TextualAnnotationWrapper; -import fr.igred.omero.meta.ExperimenterWrapper; -import fr.igred.omero.meta.GroupWrapper; -import fr.igred.omero.core.PlaneInfoWrapper; -import fr.igred.omero.core.ChannelWrapper; import fr.igred.omero.containers.DatasetWrapper; import fr.igred.omero.containers.FolderWrapper; -import fr.igred.omero.RepositoryObjectWrapper; +import fr.igred.omero.containers.ProjectWrapper; +import fr.igred.omero.core.ChannelWrapper; import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.core.PixelsWrapper; -import fr.igred.omero.screen.PlateAcquisitionWrapper; -import fr.igred.omero.screen.PlateWrapper; -import fr.igred.omero.containers.ProjectWrapper; -import fr.igred.omero.screen.ScreenWrapper; -import fr.igred.omero.screen.WellSampleWrapper; -import fr.igred.omero.screen.WellWrapper; +import fr.igred.omero.core.PlaneInfoWrapper; +import fr.igred.omero.meta.ExperimenterWrapper; +import fr.igred.omero.meta.GroupWrapper; import fr.igred.omero.roi.EllipseWrapper; -import fr.igred.omero.roi.ShapeWrapper; import fr.igred.omero.roi.LineWrapper; import fr.igred.omero.roi.MaskWrapper; import fr.igred.omero.roi.PointWrapper; @@ -50,7 +44,13 @@ import fr.igred.omero.roi.PolylineWrapper; import fr.igred.omero.roi.ROIWrapper; import fr.igred.omero.roi.RectangleWrapper; +import fr.igred.omero.roi.ShapeWrapper; import fr.igred.omero.roi.TextWrapper; +import fr.igred.omero.screen.PlateAcquisitionWrapper; +import fr.igred.omero.screen.PlateWrapper; +import fr.igred.omero.screen.ScreenWrapper; +import fr.igred.omero.screen.WellSampleWrapper; +import fr.igred.omero.screen.WellWrapper; import omero.gateway.model.AnnotationData; import omero.gateway.model.ChannelData; import omero.gateway.model.DataObject; diff --git a/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java b/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java index 6c85be93..3f798c8e 100644 --- a/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java +++ b/src/test/java/fr/igred/omero/annotations/ImageJTableTest.java @@ -18,11 +18,11 @@ package fr.igred.omero.annotations; -import fr.igred.omero.client.Client; import fr.igred.omero.UserTest; +import fr.igred.omero.client.Client; +import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ServiceException; -import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.roi.ROIWrapper; import fr.igred.omero.roi.RectangleWrapper; import ij.gui.Roi; diff --git a/src/test/java/fr/igred/omero/annotations/TagTest.java b/src/test/java/fr/igred/omero/annotations/TagTest.java index 7fd65586..cf1cca2d 100644 --- a/src/test/java/fr/igred/omero/annotations/TagTest.java +++ b/src/test/java/fr/igred/omero/annotations/TagTest.java @@ -20,9 +20,9 @@ import fr.igred.omero.UserTest; import fr.igred.omero.containers.DatasetWrapper; +import fr.igred.omero.containers.ProjectWrapper; import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.screen.PlateWrapper; -import fr.igred.omero.containers.ProjectWrapper; import fr.igred.omero.screen.ScreenWrapper; import fr.igred.omero.screen.WellWrapper; import org.junit.jupiter.api.Test; diff --git a/src/test/java/fr/igred/omero/client/ClientTest.java b/src/test/java/fr/igred/omero/client/ClientTest.java index dff2b305..aefc8c3f 100644 --- a/src/test/java/fr/igred/omero/client/ClientTest.java +++ b/src/test/java/fr/igred/omero/client/ClientTest.java @@ -19,12 +19,12 @@ import fr.igred.omero.UserTest; -import fr.igred.omero.meta.ExperimenterWrapper; -import fr.igred.omero.meta.GroupWrapper; import fr.igred.omero.containers.DatasetWrapper; +import fr.igred.omero.containers.ProjectWrapper; import fr.igred.omero.core.ImageWrapper; +import fr.igred.omero.meta.ExperimenterWrapper; +import fr.igred.omero.meta.GroupWrapper; import fr.igred.omero.screen.PlateWrapper; -import fr.igred.omero.containers.ProjectWrapper; import fr.igred.omero.screen.ScreenWrapper; import fr.igred.omero.screen.WellWrapper; import org.junit.jupiter.api.Test; diff --git a/src/test/java/fr/igred/omero/core/ImageTest.java b/src/test/java/fr/igred/omero/core/ImageTest.java index 5d6b5894..7154d6e7 100644 --- a/src/test/java/fr/igred/omero/core/ImageTest.java +++ b/src/test/java/fr/igred/omero/core/ImageTest.java @@ -56,10 +56,10 @@ import java.util.Map; import java.util.NoSuchElementException; +import static java.lang.Math.abs; import static java.util.stream.Collectors.groupingBy; import static java.util.stream.Collectors.mapping; import static java.util.stream.Collectors.toList; -import static java.lang.Math.abs; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; diff --git a/src/test/java/fr/igred/omero/exception/AccessExceptionTest.java b/src/test/java/fr/igred/omero/exception/AccessExceptionTest.java index a78611e3..c2f39671 100644 --- a/src/test/java/fr/igred/omero/exception/AccessExceptionTest.java +++ b/src/test/java/fr/igred/omero/exception/AccessExceptionTest.java @@ -19,12 +19,12 @@ import fr.igred.omero.BasicTest; -import fr.igred.omero.client.Client; import fr.igred.omero.annotations.MapAnnotationWrapper; import fr.igred.omero.annotations.TagAnnotationWrapper; +import fr.igred.omero.client.Client; import fr.igred.omero.containers.FolderWrapper; -import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.containers.ProjectWrapper; +import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.roi.ROIWrapper; import fr.igred.omero.roi.RectangleWrapper; import omero.gateway.model.ProjectData; diff --git a/src/test/java/fr/igred/omero/util/WrapperTest.java b/src/test/java/fr/igred/omero/util/WrapperTest.java index 329a54b2..47ccd230 100644 --- a/src/test/java/fr/igred/omero/util/WrapperTest.java +++ b/src/test/java/fr/igred/omero/util/WrapperTest.java @@ -26,20 +26,15 @@ import fr.igred.omero.annotations.RatingAnnotationWrapper; import fr.igred.omero.annotations.TagAnnotationWrapper; import fr.igred.omero.annotations.TextualAnnotationWrapper; -import fr.igred.omero.meta.ExperimenterWrapper; -import fr.igred.omero.meta.GroupWrapper; -import fr.igred.omero.core.PlaneInfoWrapper; -import fr.igred.omero.core.ChannelWrapper; import fr.igred.omero.containers.DatasetWrapper; import fr.igred.omero.containers.FolderWrapper; +import fr.igred.omero.containers.ProjectWrapper; +import fr.igred.omero.core.ChannelWrapper; import fr.igred.omero.core.ImageWrapper; import fr.igred.omero.core.PixelsWrapper; -import fr.igred.omero.screen.PlateAcquisitionWrapper; -import fr.igred.omero.screen.PlateWrapper; -import fr.igred.omero.containers.ProjectWrapper; -import fr.igred.omero.screen.ScreenWrapper; -import fr.igred.omero.screen.WellSampleWrapper; -import fr.igred.omero.screen.WellWrapper; +import fr.igred.omero.core.PlaneInfoWrapper; +import fr.igred.omero.meta.ExperimenterWrapper; +import fr.igred.omero.meta.GroupWrapper; import fr.igred.omero.roi.EllipseWrapper; import fr.igred.omero.roi.LineWrapper; import fr.igred.omero.roi.MaskWrapper; @@ -49,6 +44,11 @@ import fr.igred.omero.roi.ROIWrapper; import fr.igred.omero.roi.RectangleWrapper; import fr.igred.omero.roi.TextWrapper; +import fr.igred.omero.screen.PlateAcquisitionWrapper; +import fr.igred.omero.screen.PlateWrapper; +import fr.igred.omero.screen.ScreenWrapper; +import fr.igred.omero.screen.WellSampleWrapper; +import fr.igred.omero.screen.WellWrapper; import omero.gateway.model.AnnotationData; import omero.gateway.model.ChannelData; import omero.gateway.model.DataObject; From cb3798a48eccc0159a0867444866ec9d6f966e4b Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Mon, 27 Feb 2023 00:35:53 +0100 Subject: [PATCH 02/10] Rename PixelsWrapper to Bounds --- .../igred/omero/{core/PixelsWrapper.java => util/Bounds.java} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename src/main/java/fr/igred/omero/{core/PixelsWrapper.java => util/Bounds.java} (99%) diff --git a/src/main/java/fr/igred/omero/core/PixelsWrapper.java b/src/main/java/fr/igred/omero/util/Bounds.java similarity index 99% rename from src/main/java/fr/igred/omero/core/PixelsWrapper.java rename to src/main/java/fr/igred/omero/util/Bounds.java index 5e139c03..0bc9424b 100644 --- a/src/main/java/fr/igred/omero/core/PixelsWrapper.java +++ b/src/main/java/fr/igred/omero/util/Bounds.java @@ -15,11 +15,12 @@ * Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package fr.igred.omero.core; +package fr.igred.omero.util; import fr.igred.omero.ObjectWrapper; import fr.igred.omero.client.Client; +import fr.igred.omero.core.PlaneInfoWrapper; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ExceptionHandler; import fr.igred.omero.exception.ServiceException; From e6cef92c2aa980c1fe727ce885cac7d96abcc393 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Mon, 27 Feb 2023 00:37:03 +0100 Subject: [PATCH 03/10] Keep Bounds in Bounds.java and add tests --- src/main/java/fr/igred/omero/util/Bounds.java | 833 +----------------- .../java/fr/igred/omero/util/BoundsTest.java | 47 + 2 files changed, 85 insertions(+), 795 deletions(-) create mode 100644 src/test/java/fr/igred/omero/util/BoundsTest.java diff --git a/src/main/java/fr/igred/omero/util/Bounds.java b/src/main/java/fr/igred/omero/util/Bounds.java index 0bc9424b..bf88da75 100644 --- a/src/main/java/fr/igred/omero/util/Bounds.java +++ b/src/main/java/fr/igred/omero/util/Bounds.java @@ -18,828 +18,71 @@ package fr.igred.omero.util; -import fr.igred.omero.ObjectWrapper; -import fr.igred.omero.client.Client; -import fr.igred.omero.core.PlaneInfoWrapper; -import fr.igred.omero.exception.AccessException; -import fr.igred.omero.exception.ExceptionHandler; -import fr.igred.omero.exception.ServiceException; -import ome.units.unit.Unit; -import omero.gateway.exception.DataSourceException; -import omero.gateway.facility.RawDataFacility; -import omero.gateway.model.PixelsData; -import omero.gateway.model.PlaneInfoData; -import omero.gateway.rnd.Plane2D; -import omero.model.Length; -import omero.model.LengthI; -import omero.model.Time; +/** Class containing 5D bounds coordinates */ +public class Bounds { -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ExecutionException; - -import static fr.igred.omero.core.PlaneInfoWrapper.getMinPosition; -import static fr.igred.omero.exception.ExceptionHandler.call; -import static ome.formats.model.UnitsFactory.convertLength; - - -/** - * Class containing a PixelData object. - *

Wraps function calls to the PixelData contained. - */ -public class PixelsWrapper extends ObjectWrapper { - - /** Size of tiles when retrieving pixels */ - public static final int MAX_DIST = 5000; - - /** Planes info (needs to be loaded) */ - private List planesInfo = new ArrayList<>(0); - - /** Raw Data Facility to retrieve pixels */ - private RawDataFacility rawDataFacility; - - - /** - * Constructor of the PixelsWrapper class - * - * @param pixels The PixelData to be wrap. - */ - public PixelsWrapper(PixelsData pixels) { - super(pixels); - rawDataFacility = null; - } - - - /** - * Copies the value from the plane at the corresponding position in the 2D array - * - * @param tab 2D array containing the results. - * @param p Plane2D containing the voxels value. - * @param start Start position of the tile. - * @param width Width of the plane. - * @param height Height of the plane. - */ - private static void copy(double[][] tab, Plane2D p, Coordinates start, int width, int height) { - int startX = start.getX(); - int startY = start.getY(); - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - tab[startY + y][startX + x] = p.getPixelValue(x, y); - } - } - } - - - /** - * Copies the value from the plane at the corresponding position in the array - * - * @param bytes Array containing the results. - * @param p Plane2D containing the voxels value. - * @param start Starting pixel coordinates. - * @param width Width of the plane. - * @param height Height of the plane. - * @param imgWidth Width of the image. - * @param bpp Bytes per pixels of the image. - */ - private static void copy(byte[] bytes, Plane2D p, Coordinates start, int width, int height, int imgWidth, int bpp) { - int x0 = start.getX(); - int y0 = start.getY(); - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - for (int i = 0; i < bpp; i++) { - bytes[((y + y0) * imgWidth + x + x0) * bpp + i] = p.getRawValue((x + y * width) * bpp + i); - } - } - } - } - - - /** - * Checks bounds. - *
If the lower bound is outside [0 - imageSize-1], the resulting value will be 0. - *
Conversely, if the higher bound is outside [0 - imageSize-1], the resulting value will be imageSize-1. - * - * @param bounds Array containing the specified bounds for 1 coordinate. - * @param imageSize Size of the image (in the corresponding dimension). - * - * @return New array with valid bounds. - */ - private static int[] checkBounds(int[] bounds, int imageSize) { - int[] b = {0, imageSize - 1}; - if (bounds != null && bounds.length > 1) { - b[0] = bounds[0] >= b[0] && bounds[0] <= b[1] ? bounds[0] : b[0]; - b[1] = bounds[1] >= b[0] && bounds[1] <= b[1] ? bounds[1] : b[1]; - } - return b; - } - - - /** - * Loads the planes information. - * - * @param client The client handling the connection. - * - * @throws ServiceException Cannot connect to OMERO. - * @throws AccessException Cannot access data. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public void loadPlanesInfo(Client client) - throws ServiceException, AccessException, ExecutionException { - List planes = call(client.getMetadata(), - m -> m.getPlaneInfos(client.getCtx(), - data), - "Cannot retrieve planes info."); - planesInfo = wrap(planes, PlaneInfoWrapper::new); - } - - - /** - * Retrieves the planes information (which need to be {@link #loadPlanesInfo(Client) loaded} first). - * - * @return See above. - */ - public List getPlanesInfo() { - return Collections.unmodifiableList(planesInfo); - } - - - /** - * Gets the pixel type. - * - * @return the pixel type. - */ - public String getPixelType() { - return data.getPixelType(); - } - - - /** - * Gets the size of a single image pixel on the X axis. - * - * @return Size of a pixel on the X axis. - */ - public Length getPixelSizeX() { - return data.asPixels().getPhysicalSizeX(); - } - - - /** - * Gets the size of a single image pixel on the Y axis. - * - * @return Size of a pixel on the Y axis. - */ - public Length getPixelSizeY() { - return data.asPixels().getPhysicalSizeY(); - } - - - /** - * Gets the size of a single image pixel on the Z axis. - * - * @return Size of a pixel on the Z axis. - */ - public Length getPixelSizeZ() { - return data.asPixels().getPhysicalSizeZ(); - } - - - /** - * Gets the time increment between time points. - * - * @return Time increment between time points. - */ - public Time getTimeIncrement() { - return data.asPixels().getTimeIncrement(); - } - - - /** - * Computes the mean time interval from the planes deltaTs. - *

Planes information needs to be {@link #loadPlanesInfo(Client) loaded} first.

- * - * @return See above. - */ - public Time getMeanTimeInterval() { - return PlaneInfoWrapper.computeMeanTimeInterval(planesInfo, getSizeT()); - } - - - /** - * Computes the mean exposure time for a given channel from the planes exposureTime. - *

Planes information needs to be {@link #loadPlanesInfo(Client) loaded} first.

- * - * @param channel The channel index. - * - * @return See above. - */ - public Time getMeanExposureTime(int channel) { - return PlaneInfoWrapper.computeMeanExposureTime(planesInfo, channel); - } - - - /** - * Retrieves the X stage position, using the same unit as {@link #getPixelSizeX()} if possible. - *

Planes information needs to be {@link #loadPlanesInfo(Client) loaded} first.

- * - * @return See above. - */ - public Length getPositionX() { - Length x = getMinPosition(planesInfo, PlaneInfoWrapper::getPositionX); - - ome.units.quantity.Length pixSizeX = convertLength(getPixelSizeX()); - ome.units.quantity.Length posX = convertLength(x); - - if (pixSizeX != null) { - Unit unit = pixSizeX.unit(); - if (posX.value(unit) != null) { - x = new LengthI(posX.value(unit).doubleValue(), unit); - } - } - - return x; - } - - - /** - * Retrieves the Y stage position, using the same unit as {@link #getPixelSizeY()} if possible. - *

Planes information needs to be {@link #loadPlanesInfo(Client) loaded} first.

- * - * @return See above. - */ - public Length getPositionY() { - Length y = getMinPosition(planesInfo, PlaneInfoWrapper::getPositionY); - - ome.units.quantity.Length pixSizeY = convertLength(getPixelSizeY()); - ome.units.quantity.Length posY = convertLength(y); - - if (pixSizeY != null) { - Unit unit = pixSizeY.unit(); - if (posY.value(unit) != null) { - y = new LengthI(posY.value(unit).doubleValue(), unit); - } - } - - return y; - } + /** Start coordinates */ + private final Coordinates start; + /** Bounds size */ + private final Coordinates size; /** - * Retrieves the Z stage position, using the same unit as {@link #getPixelSizeZ()} if possible. - *

Planes information needs to be {@link #loadPlanesInfo(Client) loaded} first.

+ * Bounds constructor. * - * @return See above. + * @param start Start coordinates. + * @param end End coordinates. */ - public Length getPositionZ() { - Length z = getMinPosition(planesInfo, PlaneInfoWrapper::getPositionZ); - - ome.units.quantity.Length pixSizeZ = convertLength(getPixelSizeZ()); - ome.units.quantity.Length posZ = convertLength(z); - - if (pixSizeZ != null) { - Unit unit = pixSizeZ.unit(); - if (posZ.value(unit) != null) { - z = new LengthI(posZ.value(unit).doubleValue(), unit); - } - } - - return z; + public Bounds(Coordinates start, Coordinates end) { + this.start = start; + this.size = new Coordinates(end.getX() - start.getX() + 1, + end.getY() - start.getY() + 1, + end.getC() - start.getC() + 1, + end.getZ() - start.getZ() + 1, + end.getT() - start.getT() + 1); } /** - * Gets the size of the image on the X axis + * Gets starting coordinates. * - * @return Size of the image on the X axis. + * @return Starting coordinates. */ - public int getSizeX() { - return data.getSizeX(); + public Coordinates getStart() { + return start; } /** - * Gets the size of the image on the Y axis + * Gets size of bounds for each coordinate. * - * @return Size of the image on the Y axis. + * @return Bounds size. */ - public int getSizeY() { - return data.getSizeY(); + public Coordinates getEnd() { + return new Coordinates(start.getX() + size.getX() - 1, + start.getY() + size.getY() - 1, + start.getC() + size.getC() - 1, + start.getZ() + size.getZ() - 1, + start.getT() + size.getT() - 1); } /** - * Gets the size of the image on the Z axis + * Gets size of bounds for each coordinate. * - * @return Size of the image on the Z axis. + * @return Bounds size. */ - public int getSizeZ() { - return data.getSizeZ(); + public Coordinates getSize() { + return size; } - /** - * Gets the size of the image on the C axis - * - * @return Size of the image on the C axis. - */ - public int getSizeC() { - return data.getSizeC(); - } - - - /** - * Gets the size of the image on the T axis - * - * @return Size of the image on the T axis. - */ - public int getSizeT() { - return data.getSizeT(); - } - - - /** - * Creates a {@link omero.gateway.facility.RawDataFacility} to retrieve the pixel values. - * - * @param client The client handling the connection. - * - * @return
  • True if a new RawDataFacility was created
  • - *
  • False otherwise
- * - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - boolean createRawDataFacility(Client client) throws ExecutionException { - boolean created = false; - if (rawDataFacility == null) { - rawDataFacility = client.getGateway() - .getFacility(RawDataFacility.class); - created = true; - } - return created; - } - - - /** - * Destroy the {@link omero.gateway.facility.RawDataFacility}. - */ - void destroyRawDataFacility() { - rawDataFacility.close(); - rawDataFacility = null; - } - - - /** - * Returns an array containing the value for each voxel - * - * @param client The client handling the connection. - * - * @return Array containing the value for each voxel of the image. - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public double[][][][][] getAllPixels(Client client) - throws AccessException, ExecutionException { - return getAllPixels(client, null, null, null, null, null); - } - - - /** - * Returns an array containing the value for each voxel corresponding to the bounds - * - * @param client The client handling the connection. - * @param xBounds Array containing the X bounds from which the pixels should be retrieved. - * @param yBounds Array containing the Y bounds from which the pixels should be retrieved. - * @param cBounds Array containing the C bounds from which the pixels should be retrieved. - * @param zBounds Array containing the Z bounds from which the pixels should be retrieved. - * @param tBounds Array containing the T bounds from which the pixels should be retrieved. - * - * @return Array containing the value for each voxel of the image. - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public double[][][][][] getAllPixels(Client client, - int[] xBounds, - int[] yBounds, - int[] cBounds, - int[] zBounds, - int[] tBounds) - throws AccessException, ExecutionException { - boolean rdf = createRawDataFacility(client); - Bounds lim = getBounds(xBounds, yBounds, cBounds, zBounds, tBounds); - - Coordinates start = lim.getStart(); - Coordinates size = lim.getSize(); - - int x0 = start.getX(); - int y0 = start.getY(); - int sx = size.getX(); - int sy = size.getY(); - - int startC = start.getC(); - int startZ = start.getZ(); - int startT = start.getT(); - int sizeC = size.getC(); - int sizeZ = size.getZ(); - int sizeT = size.getT(); - - double[][][][][] tab = new double[sizeT][sizeZ][sizeC][][]; - - for (int t = 0, posT = startT; t < sizeT; t++, posT++) { - for (int z = 0, posZ = startZ; z < sizeZ; z++, posZ++) { - for (int c = 0, posC = startC; c < sizeC; c++, posC++) { - Coordinates pos = new Coordinates(x0, y0, posC, posZ, posT); - tab[t][z][c] = getTile(client, pos, sx, sy); - } - } - } - - if (rdf) { - destroyRawDataFacility(); - } - return tab; - } - - - /** - * Gets the tile at the specified position, with the defined width and height. - * - * @param client The client handling the connection. - * @param start Start position of the tile. - * @param width Width of the tile. - * @param height Height of the tile. - * - * @return 2D array containing tile pixel values (as double). - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - double[][] getTile(Client client, Coordinates start, int width, int height) - throws AccessException, ExecutionException { - boolean rdf = createRawDataFacility(client); - double[][] tile = ExceptionHandler.of(this, - t -> t.getTileUnchecked(client, start, width, height)) - .rethrow(DataSourceException.class, - AccessException::new, - "Cannot read tile") - .get(); - if (rdf) { - destroyRawDataFacility(); - } - return tile; - } - - - /** - * Gets the tile at the specified position, with the defined width and height. - *

The {@link #rawDataFacility} has to be created first.

- * - * @param client The client handling the connection. - * @param start Start position of the tile. - * @param width Width of the tile. - * @param height Height of the tile. - * - * @return 2D array containing tile pixel values (as double). - * - * @throws DataSourceException If an error occurs while retrieving the plane data from the pixels source. - */ - private double[][] getTileUnchecked(Client client, Coordinates start, int width, int height) - throws DataSourceException { - double[][] tile = new double[height][width]; - - int c = start.getC(); - int z = start.getZ(); - int t = start.getT(); - - for (int relX = 0, x = start.getX(); relX < width; relX += MAX_DIST, x += MAX_DIST) { - int sizeX = Math.min(MAX_DIST, width - relX); - for (int relY = 0, y = start.getY(); relY < height; relY += MAX_DIST, y += MAX_DIST) { - int sizeY = Math.min(MAX_DIST, height - relY); - Plane2D p = rawDataFacility.getTile(client.getCtx(), data, z, t, c, x, y, sizeX, sizeY); - Coordinates pos = new Coordinates(relX, relY, c, z, t); - copy(tile, p, pos, sizeX, sizeY); - } - } - return tile; - } - - - /** - * Returns an array containing the raw values for each voxel for each planes - * - * @param client The client handling the connection. - * @param bpp Bytes per pixels of the image. - * - * @return a table of bytes containing the pixel values - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public byte[][][][] getRawPixels(Client client, int bpp) - throws AccessException, ExecutionException { - return getRawPixels(client, null, null, null, null, null, bpp); - } - - - /** - * Returns an array containing the raw values for each voxel for each plane corresponding to the bounds - * - * @param client The client handling the connection. - * @param xBounds Array containing the X bounds from which the pixels should be retrieved. - * @param yBounds Array containing the Y bounds from which the pixels should be retrieved. - * @param cBounds Array containing the C bounds from which the pixels should be retrieved. - * @param zBounds Array containing the Z bounds from which the pixels should be retrieved. - * @param tBounds Array containing the T bounds from which the pixels should be retrieved. - * @param bpp Bytes per pixels of the image. - * - * @return a table of bytes containing the pixel values - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public byte[][][][] getRawPixels(Client client, - int[] xBounds, - int[] yBounds, - int[] cBounds, - int[] zBounds, - int[] tBounds, - int bpp) - throws ExecutionException, AccessException { - boolean rdf = createRawDataFacility(client); - Bounds lim = getBounds(xBounds, yBounds, cBounds, zBounds, tBounds); - - Coordinates start = lim.getStart(); - Coordinates size = lim.getSize(); - - int x0 = start.getX(); - int y0 = start.getY(); - int startC = start.getC(); - int startZ = start.getZ(); - int startT = start.getT(); - - int sx = size.getX(); - int sy = size.getY(); - int sizeC = size.getC(); - int sizeZ = size.getZ(); - int sizeT = size.getT(); - - byte[][][][] bytes = new byte[sizeT][sizeZ][sizeC][]; - - for (int t = 0, posT = startT; t < sizeT; t++, posT++) { - for (int z = 0, posZ = startZ; z < sizeZ; z++, posZ++) { - for (int c = 0, posC = startC; c < sizeC; c++, posC++) { - Coordinates pos = new Coordinates(x0, y0, posC, posZ, posT); - bytes[t][z][c] = getRawTile(client, pos, sx, sy, bpp); - } - } - } - if (rdf) { - destroyRawDataFacility(); - } - return bytes; - } - - - /** - * Gets the tile at the specified position, with the defined width and height. - * - * @param client The client handling the connection. - * @param start Start position of the tile. - * @param width Width of the tile. - * @param height Height of the tile. - * @param bpp Bytes per pixels of the image. - * - * @return Array of bytes containing the pixel values. - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - byte[] getRawTile(Client client, Coordinates start, int width, int height, int bpp) - throws AccessException, ExecutionException { - boolean rdf = createRawDataFacility(client); - byte[] tile = ExceptionHandler.of(this, - t -> t.getRawTileUnchecked(client, start, width, height, bpp)) - .rethrow(DataSourceException.class, - AccessException::new, - "Cannot read raw tile") - .get(); - if (rdf) { - destroyRawDataFacility(); - } - return tile; - } - - - /** - * Gets the tile at the specified position, with the defined width and height. - *

The {@link #rawDataFacility} has to be created first.

- * - * @param client The client handling the connection. - * @param start Start position of the tile. - * @param width Width of the tile. - * @param height Height of the tile. - * @param bpp Bytes per pixels of the image. - * - * @return Array of bytes containing the pixel values. - * - * @throws DataSourceException If an error occurs while retrieving the plane data from the pixels source. - */ - private byte[] getRawTileUnchecked(Client client, Coordinates start, int width, int height, int bpp) - throws DataSourceException { - byte[] tile = new byte[height * width * bpp]; - - int c = start.getC(); - int z = start.getZ(); - int t = start.getT(); - - for (int relX = 0, x = start.getX(); relX < width; relX += MAX_DIST, x += MAX_DIST) { - int sizeX = Math.min(MAX_DIST, width - relX); - for (int relY = 0, y = start.getY(); relY < height; relY += MAX_DIST, y += MAX_DIST) { - int sizeY = Math.min(MAX_DIST, height - relY); - Plane2D p = rawDataFacility.getTile(client.getCtx(), data, z, t, c, x, y, sizeX, sizeY); - Coordinates pos = new Coordinates(relX, relY, c, z, t); - copy(tile, p, pos, sizeX, sizeY, width, bpp); - } - } - return tile; - } - - - /** - * Checks all bounds - * - * @param xBounds Array containing the X bounds from which the pixels should be retrieved. - * @param yBounds Array containing the Y bounds from which the pixels should be retrieved. - * @param cBounds Array containing the C bounds from which the pixels should be retrieved. - * @param zBounds Array containing the Z bounds from which the pixels should be retrieved. - * @param tBounds Array containing the T bounds from which the pixels should be retrieved. - * - * @return 5D bounds. - */ - Bounds getBounds(int[] xBounds, int[] yBounds, int[] cBounds, int[] zBounds, int[] tBounds) { - int[][] limits = new int[5][2]; - limits[0] = checkBounds(xBounds, data.getSizeX()); - limits[1] = checkBounds(yBounds, data.getSizeY()); - limits[2] = checkBounds(cBounds, data.getSizeC()); - limits[3] = checkBounds(zBounds, data.getSizeZ()); - limits[4] = checkBounds(tBounds, data.getSizeT()); - Coordinates start = new Coordinates(limits[0][0], - limits[1][0], - limits[2][0], - limits[3][0], - limits[4][0]); - Coordinates end = new Coordinates(limits[0][1], - limits[1][1], - limits[2][1], - limits[3][1], - limits[4][1]); - return new Bounds(start, end); - } - - - /** Class containing 5D pixel coordinates */ - public static class Coordinates { - - /** X coordinate */ - private final int x; - /** Y coordinate */ - private final int y; - /** C coordinate */ - private final int c; - /** Z coordinate */ - private final int z; - /** T coordinate */ - private final int t; - - - /** - * Coordinates constructor. - * - * @param x X coordinate. - * @param y Y coordinate. - * @param c C coordinate. - * @param z Z coordinate. - * @param t T coordinate. - */ - public Coordinates(int x, int y, int c, int z, int t) { - this.x = x; - this.y = y; - this.c = c; - this.z = z; - this.t = t; - } - - - /** - * Gets X coordinate. - * - * @return x coordinate. - */ - public int getX() { - return x; - } - - - /** - * Gets Y coordinate. - * - * @return Y coordinate. - */ - public int getY() { - return y; - } - - - /** - * Gets C coordinate. - * - * @return C coordinate. - */ - public int getC() { - return c; - } - - - /** - * Gets Z coordinate. - * - * @return Z coordinate. - */ - public int getZ() { - return z; - } - - - /** - * Gets T coordinate. - * - * @return T coordinate. - */ - public int getT() { - return t; - } - - } - - - /** Class containing 5D bounds coordinates */ - public static class Bounds { - - /** Start coordinates */ - private final Coordinates start; - /** Bounds size */ - private final Coordinates size; - - - /** - * Bounds constructor. - * - * @param start Start coordinates. - * @param end End coordinates. - */ - public Bounds(Coordinates start, Coordinates end) { - this.start = start; - this.size = new Coordinates(end.getX() - start.getX() + 1, - end.getY() - start.getY() + 1, - end.getC() - start.getC() + 1, - end.getZ() - start.getZ() + 1, - end.getT() - start.getT() + 1); - } - - - /** - * Gets starting coordinates. - * - * @return Starting coordinates. - */ - public Coordinates getStart() { - return start; - } - - - /** - * Gets size of bounds for each coordinate. - * - * @return Bounds size. - */ - public Coordinates getEnd() { - return new Coordinates(start.getX() + size.getX() - 1, - start.getY() + size.getY() - 1, - start.getC() + size.getC() - 1, - start.getZ() + size.getZ() - 1, - start.getT() + size.getT() - 1); - } - - - /** - * Gets size of bounds for each coordinate. - * - * @return Bounds size. - */ - public Coordinates getSize() { - return size; - } - + @Override + public String toString() { + return "Bounds{" + + "start=" + start + + ", size=" + size + + "}"; } } diff --git a/src/test/java/fr/igred/omero/util/BoundsTest.java b/src/test/java/fr/igred/omero/util/BoundsTest.java new file mode 100644 index 00000000..801430ad --- /dev/null +++ b/src/test/java/fr/igred/omero/util/BoundsTest.java @@ -0,0 +1,47 @@ +package fr.igred.omero.util; + + +import fr.igred.omero.BasicTest; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + + +class BoundsTest extends BasicTest { + + @Test + void testCoordinatesToString() { + int x = 1; + int y = 2; + int c = 3; + int z = 4; + int t = 5; + + Coordinates pos = new Coordinates(x, y, c, z, t); + + String expected = "Coordinates{" + + "x=" + x + + ", y=" + y + + ", c=" + c + + ", z=" + z + + ", t=" + t + + "}"; + assertEquals(expected, pos.toString()); + } + + + @Test + void testBoundsToString() { + Coordinates start = new Coordinates(1, 2, 3, 4, 5); + Coordinates end = new Coordinates(10, 9, 8, 7, 6); + Coordinates size = new Coordinates(10, 8, 6, 4, 2); + + Bounds bounds = new Bounds(start, end); + String expected = "Bounds{" + + "start=" + start + + ", size=" + size + + "}"; + assertEquals(expected, bounds.toString()); + } + +} From 1fb7335fdaedd27e679a66b33104231cd5ba25e9 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Mon, 27 Feb 2023 00:32:51 +0100 Subject: [PATCH 04/10] Rename PixelsWrapper to Coordinates --- .../omero/{core/PixelsWrapper.java => util/Coordinates.java} | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename src/main/java/fr/igred/omero/{core/PixelsWrapper.java => util/Coordinates.java} (99%) diff --git a/src/main/java/fr/igred/omero/core/PixelsWrapper.java b/src/main/java/fr/igred/omero/util/Coordinates.java similarity index 99% rename from src/main/java/fr/igred/omero/core/PixelsWrapper.java rename to src/main/java/fr/igred/omero/util/Coordinates.java index 5e139c03..0bc9424b 100644 --- a/src/main/java/fr/igred/omero/core/PixelsWrapper.java +++ b/src/main/java/fr/igred/omero/util/Coordinates.java @@ -15,11 +15,12 @@ * Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package fr.igred.omero.core; +package fr.igred.omero.util; import fr.igred.omero.ObjectWrapper; import fr.igred.omero.client.Client; +import fr.igred.omero.core.PlaneInfoWrapper; import fr.igred.omero.exception.AccessException; import fr.igred.omero.exception.ExceptionHandler; import fr.igred.omero.exception.ServiceException; From fa2fdbc4daea2b75bdad72221246a70db4c41f39 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Mon, 27 Feb 2023 00:34:46 +0100 Subject: [PATCH 05/10] Keep Coordinates in Coordinates.java --- .../java/fr/igred/omero/util/Coordinates.java | 832 ++---------------- 1 file changed, 51 insertions(+), 781 deletions(-) diff --git a/src/main/java/fr/igred/omero/util/Coordinates.java b/src/main/java/fr/igred/omero/util/Coordinates.java index 0bc9424b..267c0fab 100644 --- a/src/main/java/fr/igred/omero/util/Coordinates.java +++ b/src/main/java/fr/igred/omero/util/Coordinates.java @@ -18,828 +18,98 @@ package fr.igred.omero.util; -import fr.igred.omero.ObjectWrapper; -import fr.igred.omero.client.Client; -import fr.igred.omero.core.PlaneInfoWrapper; -import fr.igred.omero.exception.AccessException; -import fr.igred.omero.exception.ExceptionHandler; -import fr.igred.omero.exception.ServiceException; -import ome.units.unit.Unit; -import omero.gateway.exception.DataSourceException; -import omero.gateway.facility.RawDataFacility; -import omero.gateway.model.PixelsData; -import omero.gateway.model.PlaneInfoData; -import omero.gateway.rnd.Plane2D; -import omero.model.Length; -import omero.model.LengthI; -import omero.model.Time; +/** Class containing 5D pixel coordinates */ +public class Coordinates { -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.ExecutionException; - -import static fr.igred.omero.core.PlaneInfoWrapper.getMinPosition; -import static fr.igred.omero.exception.ExceptionHandler.call; -import static ome.formats.model.UnitsFactory.convertLength; - - -/** - * Class containing a PixelData object. - *

Wraps function calls to the PixelData contained. - */ -public class PixelsWrapper extends ObjectWrapper { - - /** Size of tiles when retrieving pixels */ - public static final int MAX_DIST = 5000; - - /** Planes info (needs to be loaded) */ - private List planesInfo = new ArrayList<>(0); - - /** Raw Data Facility to retrieve pixels */ - private RawDataFacility rawDataFacility; - - - /** - * Constructor of the PixelsWrapper class - * - * @param pixels The PixelData to be wrap. - */ - public PixelsWrapper(PixelsData pixels) { - super(pixels); - rawDataFacility = null; - } - - - /** - * Copies the value from the plane at the corresponding position in the 2D array - * - * @param tab 2D array containing the results. - * @param p Plane2D containing the voxels value. - * @param start Start position of the tile. - * @param width Width of the plane. - * @param height Height of the plane. - */ - private static void copy(double[][] tab, Plane2D p, Coordinates start, int width, int height) { - int startX = start.getX(); - int startY = start.getY(); - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - tab[startY + y][startX + x] = p.getPixelValue(x, y); - } - } - } - - - /** - * Copies the value from the plane at the corresponding position in the array - * - * @param bytes Array containing the results. - * @param p Plane2D containing the voxels value. - * @param start Starting pixel coordinates. - * @param width Width of the plane. - * @param height Height of the plane. - * @param imgWidth Width of the image. - * @param bpp Bytes per pixels of the image. - */ - private static void copy(byte[] bytes, Plane2D p, Coordinates start, int width, int height, int imgWidth, int bpp) { - int x0 = start.getX(); - int y0 = start.getY(); - for (int x = 0; x < width; x++) { - for (int y = 0; y < height; y++) { - for (int i = 0; i < bpp; i++) { - bytes[((y + y0) * imgWidth + x + x0) * bpp + i] = p.getRawValue((x + y * width) * bpp + i); - } - } - } - } - - - /** - * Checks bounds. - *
If the lower bound is outside [0 - imageSize-1], the resulting value will be 0. - *
Conversely, if the higher bound is outside [0 - imageSize-1], the resulting value will be imageSize-1. - * - * @param bounds Array containing the specified bounds for 1 coordinate. - * @param imageSize Size of the image (in the corresponding dimension). - * - * @return New array with valid bounds. - */ - private static int[] checkBounds(int[] bounds, int imageSize) { - int[] b = {0, imageSize - 1}; - if (bounds != null && bounds.length > 1) { - b[0] = bounds[0] >= b[0] && bounds[0] <= b[1] ? bounds[0] : b[0]; - b[1] = bounds[1] >= b[0] && bounds[1] <= b[1] ? bounds[1] : b[1]; - } - return b; - } - - - /** - * Loads the planes information. - * - * @param client The client handling the connection. - * - * @throws ServiceException Cannot connect to OMERO. - * @throws AccessException Cannot access data. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public void loadPlanesInfo(Client client) - throws ServiceException, AccessException, ExecutionException { - List planes = call(client.getMetadata(), - m -> m.getPlaneInfos(client.getCtx(), - data), - "Cannot retrieve planes info."); - planesInfo = wrap(planes, PlaneInfoWrapper::new); - } - - - /** - * Retrieves the planes information (which need to be {@link #loadPlanesInfo(Client) loaded} first). - * - * @return See above. - */ - public List getPlanesInfo() { - return Collections.unmodifiableList(planesInfo); - } + /** X coordinate */ + private final int x; + /** Y coordinate */ + private final int y; + /** C coordinate */ + private final int c; + /** Z coordinate */ + private final int z; + /** T coordinate */ + private final int t; /** - * Gets the pixel type. + * Coordinates constructor. * - * @return the pixel type. + * @param x X coordinate. + * @param y Y coordinate. + * @param c C coordinate. + * @param z Z coordinate. + * @param t T coordinate. */ - public String getPixelType() { - return data.getPixelType(); + public Coordinates(int x, int y, int c, int z, int t) { + this.x = x; + this.y = y; + this.c = c; + this.z = z; + this.t = t; } /** - * Gets the size of a single image pixel on the X axis. + * Gets X coordinate. * - * @return Size of a pixel on the X axis. + * @return x coordinate. */ - public Length getPixelSizeX() { - return data.asPixels().getPhysicalSizeX(); - } - - - /** - * Gets the size of a single image pixel on the Y axis. - * - * @return Size of a pixel on the Y axis. - */ - public Length getPixelSizeY() { - return data.asPixels().getPhysicalSizeY(); - } - - - /** - * Gets the size of a single image pixel on the Z axis. - * - * @return Size of a pixel on the Z axis. - */ - public Length getPixelSizeZ() { - return data.asPixels().getPhysicalSizeZ(); - } - - - /** - * Gets the time increment between time points. - * - * @return Time increment between time points. - */ - public Time getTimeIncrement() { - return data.asPixels().getTimeIncrement(); - } - - - /** - * Computes the mean time interval from the planes deltaTs. - *

Planes information needs to be {@link #loadPlanesInfo(Client) loaded} first.

- * - * @return See above. - */ - public Time getMeanTimeInterval() { - return PlaneInfoWrapper.computeMeanTimeInterval(planesInfo, getSizeT()); - } - - - /** - * Computes the mean exposure time for a given channel from the planes exposureTime. - *

Planes information needs to be {@link #loadPlanesInfo(Client) loaded} first.

- * - * @param channel The channel index. - * - * @return See above. - */ - public Time getMeanExposureTime(int channel) { - return PlaneInfoWrapper.computeMeanExposureTime(planesInfo, channel); - } - - - /** - * Retrieves the X stage position, using the same unit as {@link #getPixelSizeX()} if possible. - *

Planes information needs to be {@link #loadPlanesInfo(Client) loaded} first.

- * - * @return See above. - */ - public Length getPositionX() { - Length x = getMinPosition(planesInfo, PlaneInfoWrapper::getPositionX); - - ome.units.quantity.Length pixSizeX = convertLength(getPixelSizeX()); - ome.units.quantity.Length posX = convertLength(x); - - if (pixSizeX != null) { - Unit unit = pixSizeX.unit(); - if (posX.value(unit) != null) { - x = new LengthI(posX.value(unit).doubleValue(), unit); - } - } - + public int getX() { return x; } /** - * Retrieves the Y stage position, using the same unit as {@link #getPixelSizeY()} if possible. - *

Planes information needs to be {@link #loadPlanesInfo(Client) loaded} first.

+ * Gets Y coordinate. * - * @return See above. + * @return Y coordinate. */ - public Length getPositionY() { - Length y = getMinPosition(planesInfo, PlaneInfoWrapper::getPositionY); - - ome.units.quantity.Length pixSizeY = convertLength(getPixelSizeY()); - ome.units.quantity.Length posY = convertLength(y); - - if (pixSizeY != null) { - Unit unit = pixSizeY.unit(); - if (posY.value(unit) != null) { - y = new LengthI(posY.value(unit).doubleValue(), unit); - } - } - + public int getY() { return y; } /** - * Retrieves the Z stage position, using the same unit as {@link #getPixelSizeZ()} if possible. - *

Planes information needs to be {@link #loadPlanesInfo(Client) loaded} first.

+ * Gets C coordinate. * - * @return See above. + * @return C coordinate. */ - public Length getPositionZ() { - Length z = getMinPosition(planesInfo, PlaneInfoWrapper::getPositionZ); - - ome.units.quantity.Length pixSizeZ = convertLength(getPixelSizeZ()); - ome.units.quantity.Length posZ = convertLength(z); - - if (pixSizeZ != null) { - Unit unit = pixSizeZ.unit(); - if (posZ.value(unit) != null) { - z = new LengthI(posZ.value(unit).doubleValue(), unit); - } - } - - return z; - } - - - /** - * Gets the size of the image on the X axis - * - * @return Size of the image on the X axis. - */ - public int getSizeX() { - return data.getSizeX(); + public int getC() { + return c; } /** - * Gets the size of the image on the Y axis + * Gets Z coordinate. * - * @return Size of the image on the Y axis. + * @return Z coordinate. */ - public int getSizeY() { - return data.getSizeY(); - } - - - /** - * Gets the size of the image on the Z axis - * - * @return Size of the image on the Z axis. - */ - public int getSizeZ() { - return data.getSizeZ(); - } - - - /** - * Gets the size of the image on the C axis - * - * @return Size of the image on the C axis. - */ - public int getSizeC() { - return data.getSizeC(); - } - - - /** - * Gets the size of the image on the T axis - * - * @return Size of the image on the T axis. - */ - public int getSizeT() { - return data.getSizeT(); - } - - - /** - * Creates a {@link omero.gateway.facility.RawDataFacility} to retrieve the pixel values. - * - * @param client The client handling the connection. - * - * @return
  • True if a new RawDataFacility was created
  • - *
  • False otherwise
- * - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - boolean createRawDataFacility(Client client) throws ExecutionException { - boolean created = false; - if (rawDataFacility == null) { - rawDataFacility = client.getGateway() - .getFacility(RawDataFacility.class); - created = true; - } - return created; - } - - - /** - * Destroy the {@link omero.gateway.facility.RawDataFacility}. - */ - void destroyRawDataFacility() { - rawDataFacility.close(); - rawDataFacility = null; - } - - - /** - * Returns an array containing the value for each voxel - * - * @param client The client handling the connection. - * - * @return Array containing the value for each voxel of the image. - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public double[][][][][] getAllPixels(Client client) - throws AccessException, ExecutionException { - return getAllPixels(client, null, null, null, null, null); - } - - - /** - * Returns an array containing the value for each voxel corresponding to the bounds - * - * @param client The client handling the connection. - * @param xBounds Array containing the X bounds from which the pixels should be retrieved. - * @param yBounds Array containing the Y bounds from which the pixels should be retrieved. - * @param cBounds Array containing the C bounds from which the pixels should be retrieved. - * @param zBounds Array containing the Z bounds from which the pixels should be retrieved. - * @param tBounds Array containing the T bounds from which the pixels should be retrieved. - * - * @return Array containing the value for each voxel of the image. - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public double[][][][][] getAllPixels(Client client, - int[] xBounds, - int[] yBounds, - int[] cBounds, - int[] zBounds, - int[] tBounds) - throws AccessException, ExecutionException { - boolean rdf = createRawDataFacility(client); - Bounds lim = getBounds(xBounds, yBounds, cBounds, zBounds, tBounds); - - Coordinates start = lim.getStart(); - Coordinates size = lim.getSize(); - - int x0 = start.getX(); - int y0 = start.getY(); - int sx = size.getX(); - int sy = size.getY(); - - int startC = start.getC(); - int startZ = start.getZ(); - int startT = start.getT(); - int sizeC = size.getC(); - int sizeZ = size.getZ(); - int sizeT = size.getT(); - - double[][][][][] tab = new double[sizeT][sizeZ][sizeC][][]; - - for (int t = 0, posT = startT; t < sizeT; t++, posT++) { - for (int z = 0, posZ = startZ; z < sizeZ; z++, posZ++) { - for (int c = 0, posC = startC; c < sizeC; c++, posC++) { - Coordinates pos = new Coordinates(x0, y0, posC, posZ, posT); - tab[t][z][c] = getTile(client, pos, sx, sy); - } - } - } - - if (rdf) { - destroyRawDataFacility(); - } - return tab; - } - - - /** - * Gets the tile at the specified position, with the defined width and height. - * - * @param client The client handling the connection. - * @param start Start position of the tile. - * @param width Width of the tile. - * @param height Height of the tile. - * - * @return 2D array containing tile pixel values (as double). - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - double[][] getTile(Client client, Coordinates start, int width, int height) - throws AccessException, ExecutionException { - boolean rdf = createRawDataFacility(client); - double[][] tile = ExceptionHandler.of(this, - t -> t.getTileUnchecked(client, start, width, height)) - .rethrow(DataSourceException.class, - AccessException::new, - "Cannot read tile") - .get(); - if (rdf) { - destroyRawDataFacility(); - } - return tile; - } - - - /** - * Gets the tile at the specified position, with the defined width and height. - *

The {@link #rawDataFacility} has to be created first.

- * - * @param client The client handling the connection. - * @param start Start position of the tile. - * @param width Width of the tile. - * @param height Height of the tile. - * - * @return 2D array containing tile pixel values (as double). - * - * @throws DataSourceException If an error occurs while retrieving the plane data from the pixels source. - */ - private double[][] getTileUnchecked(Client client, Coordinates start, int width, int height) - throws DataSourceException { - double[][] tile = new double[height][width]; - - int c = start.getC(); - int z = start.getZ(); - int t = start.getT(); - - for (int relX = 0, x = start.getX(); relX < width; relX += MAX_DIST, x += MAX_DIST) { - int sizeX = Math.min(MAX_DIST, width - relX); - for (int relY = 0, y = start.getY(); relY < height; relY += MAX_DIST, y += MAX_DIST) { - int sizeY = Math.min(MAX_DIST, height - relY); - Plane2D p = rawDataFacility.getTile(client.getCtx(), data, z, t, c, x, y, sizeX, sizeY); - Coordinates pos = new Coordinates(relX, relY, c, z, t); - copy(tile, p, pos, sizeX, sizeY); - } - } - return tile; - } - - - /** - * Returns an array containing the raw values for each voxel for each planes - * - * @param client The client handling the connection. - * @param bpp Bytes per pixels of the image. - * - * @return a table of bytes containing the pixel values - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public byte[][][][] getRawPixels(Client client, int bpp) - throws AccessException, ExecutionException { - return getRawPixels(client, null, null, null, null, null, bpp); - } - - - /** - * Returns an array containing the raw values for each voxel for each plane corresponding to the bounds - * - * @param client The client handling the connection. - * @param xBounds Array containing the X bounds from which the pixels should be retrieved. - * @param yBounds Array containing the Y bounds from which the pixels should be retrieved. - * @param cBounds Array containing the C bounds from which the pixels should be retrieved. - * @param zBounds Array containing the Z bounds from which the pixels should be retrieved. - * @param tBounds Array containing the T bounds from which the pixels should be retrieved. - * @param bpp Bytes per pixels of the image. - * - * @return a table of bytes containing the pixel values - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public byte[][][][] getRawPixels(Client client, - int[] xBounds, - int[] yBounds, - int[] cBounds, - int[] zBounds, - int[] tBounds, - int bpp) - throws ExecutionException, AccessException { - boolean rdf = createRawDataFacility(client); - Bounds lim = getBounds(xBounds, yBounds, cBounds, zBounds, tBounds); - - Coordinates start = lim.getStart(); - Coordinates size = lim.getSize(); - - int x0 = start.getX(); - int y0 = start.getY(); - int startC = start.getC(); - int startZ = start.getZ(); - int startT = start.getT(); - - int sx = size.getX(); - int sy = size.getY(); - int sizeC = size.getC(); - int sizeZ = size.getZ(); - int sizeT = size.getT(); - - byte[][][][] bytes = new byte[sizeT][sizeZ][sizeC][]; - - for (int t = 0, posT = startT; t < sizeT; t++, posT++) { - for (int z = 0, posZ = startZ; z < sizeZ; z++, posZ++) { - for (int c = 0, posC = startC; c < sizeC; c++, posC++) { - Coordinates pos = new Coordinates(x0, y0, posC, posZ, posT); - bytes[t][z][c] = getRawTile(client, pos, sx, sy, bpp); - } - } - } - if (rdf) { - destroyRawDataFacility(); - } - return bytes; - } - - - /** - * Gets the tile at the specified position, with the defined width and height. - * - * @param client The client handling the connection. - * @param start Start position of the tile. - * @param width Width of the tile. - * @param height Height of the tile. - * @param bpp Bytes per pixels of the image. - * - * @return Array of bytes containing the pixel values. - * - * @throws AccessException If an error occurs while retrieving the plane data from the pixels source. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - byte[] getRawTile(Client client, Coordinates start, int width, int height, int bpp) - throws AccessException, ExecutionException { - boolean rdf = createRawDataFacility(client); - byte[] tile = ExceptionHandler.of(this, - t -> t.getRawTileUnchecked(client, start, width, height, bpp)) - .rethrow(DataSourceException.class, - AccessException::new, - "Cannot read raw tile") - .get(); - if (rdf) { - destroyRawDataFacility(); - } - return tile; - } - - - /** - * Gets the tile at the specified position, with the defined width and height. - *

The {@link #rawDataFacility} has to be created first.

- * - * @param client The client handling the connection. - * @param start Start position of the tile. - * @param width Width of the tile. - * @param height Height of the tile. - * @param bpp Bytes per pixels of the image. - * - * @return Array of bytes containing the pixel values. - * - * @throws DataSourceException If an error occurs while retrieving the plane data from the pixels source. - */ - private byte[] getRawTileUnchecked(Client client, Coordinates start, int width, int height, int bpp) - throws DataSourceException { - byte[] tile = new byte[height * width * bpp]; - - int c = start.getC(); - int z = start.getZ(); - int t = start.getT(); - - for (int relX = 0, x = start.getX(); relX < width; relX += MAX_DIST, x += MAX_DIST) { - int sizeX = Math.min(MAX_DIST, width - relX); - for (int relY = 0, y = start.getY(); relY < height; relY += MAX_DIST, y += MAX_DIST) { - int sizeY = Math.min(MAX_DIST, height - relY); - Plane2D p = rawDataFacility.getTile(client.getCtx(), data, z, t, c, x, y, sizeX, sizeY); - Coordinates pos = new Coordinates(relX, relY, c, z, t); - copy(tile, p, pos, sizeX, sizeY, width, bpp); - } - } - return tile; + public int getZ() { + return z; } /** - * Checks all bounds - * - * @param xBounds Array containing the X bounds from which the pixels should be retrieved. - * @param yBounds Array containing the Y bounds from which the pixels should be retrieved. - * @param cBounds Array containing the C bounds from which the pixels should be retrieved. - * @param zBounds Array containing the Z bounds from which the pixels should be retrieved. - * @param tBounds Array containing the T bounds from which the pixels should be retrieved. + * Gets T coordinate. * - * @return 5D bounds. + * @return T coordinate. */ - Bounds getBounds(int[] xBounds, int[] yBounds, int[] cBounds, int[] zBounds, int[] tBounds) { - int[][] limits = new int[5][2]; - limits[0] = checkBounds(xBounds, data.getSizeX()); - limits[1] = checkBounds(yBounds, data.getSizeY()); - limits[2] = checkBounds(cBounds, data.getSizeC()); - limits[3] = checkBounds(zBounds, data.getSizeZ()); - limits[4] = checkBounds(tBounds, data.getSizeT()); - Coordinates start = new Coordinates(limits[0][0], - limits[1][0], - limits[2][0], - limits[3][0], - limits[4][0]); - Coordinates end = new Coordinates(limits[0][1], - limits[1][1], - limits[2][1], - limits[3][1], - limits[4][1]); - return new Bounds(start, end); + public int getT() { + return t; } - /** Class containing 5D pixel coordinates */ - public static class Coordinates { - - /** X coordinate */ - private final int x; - /** Y coordinate */ - private final int y; - /** C coordinate */ - private final int c; - /** Z coordinate */ - private final int z; - /** T coordinate */ - private final int t; - - - /** - * Coordinates constructor. - * - * @param x X coordinate. - * @param y Y coordinate. - * @param c C coordinate. - * @param z Z coordinate. - * @param t T coordinate. - */ - public Coordinates(int x, int y, int c, int z, int t) { - this.x = x; - this.y = y; - this.c = c; - this.z = z; - this.t = t; - } - - - /** - * Gets X coordinate. - * - * @return x coordinate. - */ - public int getX() { - return x; - } - - - /** - * Gets Y coordinate. - * - * @return Y coordinate. - */ - public int getY() { - return y; - } - - - /** - * Gets C coordinate. - * - * @return C coordinate. - */ - public int getC() { - return c; - } - - - /** - * Gets Z coordinate. - * - * @return Z coordinate. - */ - public int getZ() { - return z; - } - - - /** - * Gets T coordinate. - * - * @return T coordinate. - */ - public int getT() { - return t; - } - - } - - - /** Class containing 5D bounds coordinates */ - public static class Bounds { - - /** Start coordinates */ - private final Coordinates start; - /** Bounds size */ - private final Coordinates size; - - - /** - * Bounds constructor. - * - * @param start Start coordinates. - * @param end End coordinates. - */ - public Bounds(Coordinates start, Coordinates end) { - this.start = start; - this.size = new Coordinates(end.getX() - start.getX() + 1, - end.getY() - start.getY() + 1, - end.getC() - start.getC() + 1, - end.getZ() - start.getZ() + 1, - end.getT() - start.getT() + 1); - } - - - /** - * Gets starting coordinates. - * - * @return Starting coordinates. - */ - public Coordinates getStart() { - return start; - } - - - /** - * Gets size of bounds for each coordinate. - * - * @return Bounds size. - */ - public Coordinates getEnd() { - return new Coordinates(start.getX() + size.getX() - 1, - start.getY() + size.getY() - 1, - start.getC() + size.getC() - 1, - start.getZ() + size.getZ() - 1, - start.getT() + size.getT() - 1); - } - - - /** - * Gets size of bounds for each coordinate. - * - * @return Bounds size. - */ - public Coordinates getSize() { - return size; - } - + @Override + public String toString() { + return "Coordinates{" + + "x=" + x + + ", y=" + y + + ", c=" + c + + ", z=" + z + + ", t=" + t + + "}"; } } From 0f76528a63c40dfaffab5cfbe34d5f155ea39519 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Mon, 27 Feb 2023 00:37:58 +0100 Subject: [PATCH 06/10] Remove Bounds and Coordinates from PixelsWrapper --- .../fr/igred/omero/core/PixelsWrapper.java | 146 ------------------ 1 file changed, 146 deletions(-) diff --git a/src/main/java/fr/igred/omero/core/PixelsWrapper.java b/src/main/java/fr/igred/omero/core/PixelsWrapper.java index 5e139c03..22a0b0a1 100644 --- a/src/main/java/fr/igred/omero/core/PixelsWrapper.java +++ b/src/main/java/fr/igred/omero/core/PixelsWrapper.java @@ -695,150 +695,4 @@ Bounds getBounds(int[] xBounds, int[] yBounds, int[] cBounds, int[] zBounds, int return new Bounds(start, end); } - - /** Class containing 5D pixel coordinates */ - public static class Coordinates { - - /** X coordinate */ - private final int x; - /** Y coordinate */ - private final int y; - /** C coordinate */ - private final int c; - /** Z coordinate */ - private final int z; - /** T coordinate */ - private final int t; - - - /** - * Coordinates constructor. - * - * @param x X coordinate. - * @param y Y coordinate. - * @param c C coordinate. - * @param z Z coordinate. - * @param t T coordinate. - */ - public Coordinates(int x, int y, int c, int z, int t) { - this.x = x; - this.y = y; - this.c = c; - this.z = z; - this.t = t; - } - - - /** - * Gets X coordinate. - * - * @return x coordinate. - */ - public int getX() { - return x; - } - - - /** - * Gets Y coordinate. - * - * @return Y coordinate. - */ - public int getY() { - return y; - } - - - /** - * Gets C coordinate. - * - * @return C coordinate. - */ - public int getC() { - return c; - } - - - /** - * Gets Z coordinate. - * - * @return Z coordinate. - */ - public int getZ() { - return z; - } - - - /** - * Gets T coordinate. - * - * @return T coordinate. - */ - public int getT() { - return t; - } - - } - - - /** Class containing 5D bounds coordinates */ - public static class Bounds { - - /** Start coordinates */ - private final Coordinates start; - /** Bounds size */ - private final Coordinates size; - - - /** - * Bounds constructor. - * - * @param start Start coordinates. - * @param end End coordinates. - */ - public Bounds(Coordinates start, Coordinates end) { - this.start = start; - this.size = new Coordinates(end.getX() - start.getX() + 1, - end.getY() - start.getY() + 1, - end.getC() - start.getC() + 1, - end.getZ() - start.getZ() + 1, - end.getT() - start.getT() + 1); - } - - - /** - * Gets starting coordinates. - * - * @return Starting coordinates. - */ - public Coordinates getStart() { - return start; - } - - - /** - * Gets size of bounds for each coordinate. - * - * @return Bounds size. - */ - public Coordinates getEnd() { - return new Coordinates(start.getX() + size.getX() - 1, - start.getY() + size.getY() - 1, - start.getC() + size.getC() - 1, - start.getZ() + size.getZ() - 1, - start.getT() + size.getT() - 1); - } - - - /** - * Gets size of bounds for each coordinate. - * - * @return Bounds size. - */ - public Coordinates getSize() { - return size; - } - - } - } From e2fed4d772d58ac504920a4a2e3fb1c996b6baa1 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Mon, 27 Feb 2023 00:43:32 +0100 Subject: [PATCH 07/10] Rename RepositoryObjectWrapper.java to ReplacePolicy.java --- .../{RepositoryObjectWrapper.java => util/ReplacePolicy.java} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/java/fr/igred/omero/{RepositoryObjectWrapper.java => util/ReplacePolicy.java} (100%) diff --git a/src/main/java/fr/igred/omero/RepositoryObjectWrapper.java b/src/main/java/fr/igred/omero/util/ReplacePolicy.java similarity index 100% rename from src/main/java/fr/igred/omero/RepositoryObjectWrapper.java rename to src/main/java/fr/igred/omero/util/ReplacePolicy.java From 277eff6c158b74d690116985409e3911939b5392 Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Mon, 27 Feb 2023 00:45:10 +0100 Subject: [PATCH 08/10] Only keep ReplacePolicy in ReplacePolicy.java --- .../fr/igred/omero/util/ReplacePolicy.java | 254 +----------------- 1 file changed, 9 insertions(+), 245 deletions(-) diff --git a/src/main/java/fr/igred/omero/util/ReplacePolicy.java b/src/main/java/fr/igred/omero/util/ReplacePolicy.java index f5e02757..24257bd9 100644 --- a/src/main/java/fr/igred/omero/util/ReplacePolicy.java +++ b/src/main/java/fr/igred/omero/util/ReplacePolicy.java @@ -15,255 +15,19 @@ * Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -package fr.igred.omero; - - -import fr.igred.omero.client.Browser; -import fr.igred.omero.client.Client; -import fr.igred.omero.client.GatewayWrapper; -import fr.igred.omero.exception.AccessException; -import fr.igred.omero.exception.ExceptionHandler; -import fr.igred.omero.exception.ServiceException; -import loci.formats.in.DefaultMetadataOptions; -import loci.formats.in.MetadataLevel; -import ome.formats.OMEROMetadataStoreClient; -import ome.formats.importer.ImportCandidates; -import ome.formats.importer.ImportConfig; -import ome.formats.importer.ImportContainer; -import ome.formats.importer.ImportLibrary; -import ome.formats.importer.OMEROWrapper; -import ome.formats.importer.cli.ErrorHandler; -import ome.formats.importer.cli.LoggingImportMonitor; -import omero.gateway.model.DataObject; -import omero.gateway.util.PojoMapper; -import omero.model.Pixels; - -import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.Logger; - -import static java.util.stream.Collectors.toList; +package fr.igred.omero.util; /** - * Generic class containing a DataObject (or a subclass) object. - * - * @param Subclass of {@link DataObject} + * Policy to specify how to handle objects when they are replaced. */ -public abstract class RepositoryObjectWrapper extends AnnotatableWrapper { - - /** - * Constructor of the class RepositoryObjectWrapper. - * - * @param o The DataObject to wrap in the RepositoryObjectWrapper. - */ - protected RepositoryObjectWrapper(T o) { - super(o); - } - - - /** - * Method used for importing a number of import candidates. - * - * @param target The import target. - * @param library The importer. - * @param config The configuration information. - * @param candidates Hosts information about the files to import. - * - * @return The list of imported pixels. - */ - private static List importCandidates(DataObject target, ImportLibrary library, ImportConfig config, - ImportCandidates candidates) { - List pixels = new ArrayList<>(0); - - ExecutorService threadPool = Executors.newFixedThreadPool(config.parallelUpload.get()); - - List containers = candidates.getContainers(); - if (containers != null) { - pixels = new ArrayList<>(containers.size()); - for (int i = 0; i < containers.size(); i++) { - ImportContainer container = containers.get(i); - container.setTarget(target.asIObject()); - List imported = new ArrayList<>(1); - try { - imported = library.importImage(container, threadPool, i); - } catch (Throwable e) { - String filename = container.getFile().getName(); - String error = String.format("Error during image import for: %s", filename); - Logger.getLogger(MethodHandles.lookup().lookupClass().getName()).severe(error); - if (Boolean.FALSE.equals(config.contOnError.get())) { - return pixels; - } - } - pixels.addAll(imported); - } - } - threadPool.shutdown(); - return pixels; - } - - - /** - * Imports all images candidates in the paths to the target in OMERO. - * - * @param client The client handling the connection. - * @param target The import target. - * @param threads The number of threads (same value used for filesets and uploads). - * @param paths Paths to the image files on the computer. - * - * @return If the import did not exit because of an error. - * - * @throws ServiceException Cannot connect to OMERO. - * @throws AccessException Cannot access data. - * @throws IOException Cannot read file. - */ - protected static boolean importImages(GatewayWrapper client, DataObject target, int threads, String... paths) - throws ServiceException, AccessException, IOException { - boolean success; - - ImportConfig config = new ImportConfig(); - String type = PojoMapper.getGraphType(target.getClass()); - config.target.set(type + ":" + target.getId()); - config.username.set(client.getUser().getUserName()); - config.email.set(client.getUser().getEmail()); - config.parallelFileset.set(threads); - config.parallelUpload.set(threads); - - OMEROMetadataStoreClient store = client.getImportStore(); - try (OMEROWrapper reader = new OMEROWrapper(config)) { - ExceptionHandler.ofConsumer(store, s -> s.logVersionInfo(config.getIniVersionNumber())) - .handleServerAndService("Cannot log version information during import.") - .rethrow(); - reader.setMetadataOptions(new DefaultMetadataOptions(MetadataLevel.ALL)); - - ImportLibrary library = new ImportLibrary(store, reader); - library.addObserver(new LoggingImportMonitor()); - - ErrorHandler handler = new ErrorHandler(config); - - ImportCandidates candidates = new ImportCandidates(reader, paths, handler); - success = library.importCandidates(config, candidates); - } finally { - client.closeImport(); - } - - return success; - } - - - /** - * Imports one image file to the target in OMERO. - * - * @param client The client handling the connection. - * @param target The import target. - * @param path Path to the image file on the computer. - * - * @return The list of IDs of the newly imported images. - * - * @throws ServiceException Cannot connect to OMERO. - * @throws AccessException Cannot access data. - * @throws IOException Cannot read file. - */ - protected static List importImage(GatewayWrapper client, DataObject target, String path) - throws ServiceException, AccessException, IOException { - ImportConfig config = new ImportConfig(); - String type = PojoMapper.getGraphType(target.getClass()); - config.target.set(type + ":" + target.getId()); - config.username.set(client.getUser().getUserName()); - config.email.set(client.getUser().getEmail()); - - Collection pixels; - - OMEROMetadataStoreClient store = client.getImportStore(); - try (OMEROWrapper reader = new OMEROWrapper(config)) { - ExceptionHandler.ofConsumer(store, s -> s.logVersionInfo(config.getIniVersionNumber())) - .handleServerAndService("Cannot log version information during import.") - .rethrow(); - reader.setMetadataOptions(new DefaultMetadataOptions(MetadataLevel.ALL)); - - ImportLibrary library = new ImportLibrary(store, reader); - library.addObserver(new LoggingImportMonitor()); - - ErrorHandler handler = new ErrorHandler(config); - - ImportCandidates candidates = new ImportCandidates(reader, new String[]{path}, handler); - pixels = importCandidates(target, library, config, candidates); - } finally { - client.closeImport(); - } - - return pixels.stream() - .map(pix -> pix.getImage().getId().getValue()) - .distinct() - .collect(toList()); - } - - - /** - * Gets the object name. - * - * @return See above. - */ - public abstract String getName(); - - - /** - * Gets the object description - * - * @return See above. - */ - public abstract String getDescription(); - - - /** - * Copies annotation links from some other object to this one. - *

Kept for API compatibility purposes.

- * - * @param client The client handling the connection. - * @param object Other repository object to copy annotations from. - * - * @throws ServiceException Cannot connect to OMERO. - * @throws AccessException Cannot access data. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - @SuppressWarnings("MethodOverloadsMethodOfSuperclass") - public void copyAnnotationLinks(Client client, RepositoryObjectWrapper object) - throws AccessException, ServiceException, ExecutionException { - super.copyAnnotationLinks(client, object); - } - - - /** - * Reloads the object from OMERO. - * - * @param browser The data browser. - * - * @throws ServiceException Cannot connect to OMERO. - * @throws AccessException Cannot access data. - * @throws ExecutionException A Facility can't be retrieved or instantiated. - */ - public abstract void reload(Browser browser) - throws ServiceException, AccessException, ExecutionException; - - - /** - * Policy to specify how to handle objects when they are replaced. - */ - public enum ReplacePolicy { - /** Unlink objects only */ - UNLINK, - - /** Delete all objects */ - DELETE, +public enum ReplacePolicy { + /** Unlink objects only */ + UNLINK, - /** Delete orphaned objects */ - DELETE_ORPHANED - } + /** Delete all objects */ + DELETE, + /** Delete orphaned objects */ + DELETE_ORPHANED } From 81fef11ea4d24beec45757d3049c4c52c9b5767f Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Mon, 27 Feb 2023 00:45:54 +0100 Subject: [PATCH 09/10] Remove ReplacePolicy from RepositoryObjectWrapper.java --- .../fr/igred/omero/RepositoryObjectWrapper.java | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/main/java/fr/igred/omero/RepositoryObjectWrapper.java b/src/main/java/fr/igred/omero/RepositoryObjectWrapper.java index f5e02757..4e6d3ba9 100644 --- a/src/main/java/fr/igred/omero/RepositoryObjectWrapper.java +++ b/src/main/java/fr/igred/omero/RepositoryObjectWrapper.java @@ -251,19 +251,4 @@ public void copyAnnotationLinks(Client client, RepositoryObjectWrapper object public abstract void reload(Browser browser) throws ServiceException, AccessException, ExecutionException; - - /** - * Policy to specify how to handle objects when they are replaced. - */ - public enum ReplacePolicy { - /** Unlink objects only */ - UNLINK, - - /** Delete all objects */ - DELETE, - - /** Delete orphaned objects */ - DELETE_ORPHANED - } - } From 734ffd76b43352f9dae446350a847ccb013f412a Mon Sep 17 00:00:00 2001 From: Pierre Pouchin Date: Fri, 22 Nov 2024 01:01:05 +0100 Subject: [PATCH 10/10] Update .editorconfig --- .editorconfig | 54 ++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/.editorconfig b/.editorconfig index a94cd207..1c10e0fb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -11,7 +11,7 @@ tab_width = 4 ij_continuation_indent_size = 8 ij_formatter_off_tag = @formatter:off ij_formatter_on_tag = @formatter:on -ij_formatter_tags_enabled = false +ij_formatter_tags_enabled = true ij_smart_tabs = false ij_visual_guides = none ij_wrap_on_typing = false @@ -26,6 +26,7 @@ ij_java_align_multiline_array_initializer_expression = true ij_java_align_multiline_assignment = true ij_java_align_multiline_binary_operation = true ij_java_align_multiline_chained_methods = true +ij_java_align_multiline_deconstruction_list_components = true ij_java_align_multiline_extends_list = true ij_java_align_multiline_for = true ij_java_align_multiline_method_parentheses = false @@ -39,6 +40,7 @@ ij_java_align_multiline_text_blocks = true ij_java_align_multiline_throws_list = true ij_java_align_subsequent_simple_methods = false ij_java_align_throws_keyword = true +ij_java_align_types_in_multi_catch = true ij_java_annotation_parameter_wrap = off ij_java_array_initializer_new_line_after_left_brace = false ij_java_array_initializer_right_brace_on_new_line = false @@ -55,6 +57,7 @@ ij_java_blank_lines_after_package = 2 ij_java_blank_lines_around_class = 2 ij_java_blank_lines_around_field = 0 ij_java_blank_lines_around_field_in_interface = 0 +ij_java_blank_lines_around_field_with_annotations = 0 ij_java_blank_lines_around_initializer = 1 ij_java_blank_lines_around_method = 2 ij_java_blank_lines_around_method_in_interface = 2 @@ -63,6 +66,7 @@ ij_java_blank_lines_before_imports = 1 ij_java_blank_lines_before_method_body = 0 ij_java_blank_lines_before_package = 0 ij_java_block_brace_style = end_of_line +ij_java_block_comment_add_space = false ij_java_block_comment_at_first_column = true ij_java_call_parameters_new_line_after_left_paren = false ij_java_call_parameters_right_paren_on_new_line = false @@ -71,7 +75,7 @@ ij_java_case_statement_on_separate_line = true ij_java_catch_on_new_line = false ij_java_class_annotation_wrap = split_into_lines ij_java_class_brace_style = end_of_line -ij_java_class_count_to_use_import_on_demand = 20 +ij_java_class_count_to_use_import_on_demand = 30 ij_java_class_names_in_javadoc = 1 ij_java_do_not_indent_top_level_class_members = false ij_java_do_not_wrap_after_single_annotation = false @@ -92,7 +96,7 @@ ij_java_doc_keep_empty_return_tag = true ij_java_doc_keep_empty_throws_tag = true ij_java_doc_keep_invalid_tags = true ij_java_doc_param_description_on_new_line = false -ij_java_doc_preserve_line_breaks = false +ij_java_doc_preserve_line_breaks = true ij_java_doc_use_throws_not_exception_tag = true ij_java_else_on_new_line = false ij_java_enum_constants_wrap = on_every_item @@ -106,8 +110,9 @@ ij_java_for_statement_right_paren_on_new_line = false ij_java_for_statement_wrap = on_every_item ij_java_generate_final_locals = false ij_java_generate_final_parameters = false +ij_java_generate_use_type_annotation_before_type = true ij_java_if_brace_force = always -ij_java_imports_layout = *, |, javax.**, java.**, |, $* +ij_java_imports_layout = *,|,javax.**,java.**,|,$* ij_java_indent_case_from_switch = true ij_java_insert_inner_class_imports = false ij_java_insert_override_annotation = true @@ -115,7 +120,7 @@ ij_java_keep_blank_lines_before_right_brace = 2 ij_java_keep_blank_lines_between_package_declaration_and_header = 2 ij_java_keep_blank_lines_in_code = 2 ij_java_keep_blank_lines_in_declarations = 2 -ij_java_keep_builder_methods_indents = true +ij_java_keep_builder_methods_indents = false ij_java_keep_control_statement_in_one_line = true ij_java_keep_first_column_comment = true ij_java_keep_indents_on_empty_lines = false @@ -130,6 +135,7 @@ ij_java_label_indent_size = 0 ij_java_lambda_brace_style = end_of_line ij_java_layout_static_imports_separately = true ij_java_line_comment_add_space = false +ij_java_line_comment_add_space_on_reformat = false ij_java_line_comment_at_first_column = true ij_java_method_annotation_wrap = split_into_lines ij_java_method_brace_style = end_of_line @@ -138,8 +144,12 @@ ij_java_method_parameters_new_line_after_left_paren = false ij_java_method_parameters_right_paren_on_new_line = false ij_java_method_parameters_wrap = normal ij_java_modifier_list_wrap = false -ij_java_names_count_to_use_import_on_demand = 10 +ij_java_multi_catch_types_wrap = normal +ij_java_names_count_to_use_import_on_demand = 20 +ij_java_new_line_after_lparen_in_annotation = false +ij_java_new_line_after_lparen_in_deconstruction_pattern = true ij_java_new_line_after_lparen_in_record_header = false +ij_java_new_line_when_body_is_presented = false ij_java_packages_to_use_import_on_demand = javax.swing.* ij_java_parameter_annotation_wrap = off ij_java_parentheses_expression_new_line_after_left_paren = false @@ -173,6 +183,7 @@ ij_java_space_before_class_left_brace = true ij_java_space_before_colon = true ij_java_space_before_colon_in_foreach = true ij_java_space_before_comma = false +ij_java_space_before_deconstruction_list = false ij_java_space_before_do_left_brace = true ij_java_space_before_else_keyword = true ij_java_space_before_else_left_brace = true @@ -203,6 +214,7 @@ ij_java_space_within_empty_array_initializer_braces = false ij_java_space_within_empty_method_call_parentheses = false ij_java_space_within_empty_method_parentheses = false ij_java_spaces_around_additive_operators = true +ij_java_spaces_around_annotation_eq = true ij_java_spaces_around_assignment_operators = true ij_java_spaces_around_bitwise_operators = true ij_java_spaces_around_equality_operators = true @@ -214,6 +226,7 @@ ij_java_spaces_around_relational_operators = true ij_java_spaces_around_shift_operators = true ij_java_spaces_around_type_bounds_in_type_parameters = true ij_java_spaces_around_unary_operator = false +ij_java_spaces_inside_block_braces_when_body_is_present = false ij_java_spaces_within_angle_brackets = false ij_java_spaces_within_annotation_parentheses = false ij_java_spaces_within_array_initializer_braces = false @@ -221,6 +234,7 @@ ij_java_spaces_within_braces = false ij_java_spaces_within_brackets = false ij_java_spaces_within_cast_parentheses = false ij_java_spaces_within_catch_parentheses = false +ij_java_spaces_within_deconstruction_list = false ij_java_spaces_within_for_parentheses = false ij_java_spaces_within_if_parentheses = false ij_java_spaces_within_method_call_parentheses = false @@ -233,6 +247,7 @@ ij_java_spaces_within_try_parentheses = false ij_java_spaces_within_while_parentheses = false ij_java_special_else_if_treatment = true ij_java_subclass_name_suffix = Impl +ij_java_switch_expressions_wrap = normal ij_java_ternary_operation_signs_on_next_line = false ij_java_ternary_operation_wrap = normal ij_java_test_name_suffix = Test @@ -249,6 +264,13 @@ ij_java_while_on_new_line = false ij_java_wrap_comments = true ij_java_wrap_first_method_in_call_chain = false ij_java_wrap_long_lines = false +ij_java_wrap_semicolon_after_call_chain = false + +[*.properties] +ij_properties_align_group_field_declarations = false +ij_properties_keep_blank_lines = false +ij_properties_key_value_delimiter = equals +ij_properties_spaces_around_key_value_delimiter = false [.editorconfig] ij_editorconfig_align_group_field_declarations = false @@ -262,6 +284,7 @@ ij_editorconfig_spaces_around_assignment_operators = true ij_xml_align_attributes = true ij_xml_align_text = false ij_xml_attribute_wrap = normal +ij_xml_block_comment_add_space = false ij_xml_block_comment_at_first_column = true ij_xml_keep_blank_lines = 2 ij_xml_keep_indents_on_empty_lines = false @@ -275,20 +298,34 @@ ij_xml_space_after_tag_name = false ij_xml_space_around_equals_in_attribute = false ij_xml_space_inside_empty_tag = false ij_xml_text_wrap = normal -ij_xml_use_custom_settings = false + +[{*.bash,*.sh,*.zsh}] +indent_size = 2 +tab_width = 2 +ij_shell_binary_ops_start_line = false +ij_shell_keep_column_alignment_padding = false +ij_shell_minify_program = false +ij_shell_redirect_followed_by_space = false +ij_shell_switch_cases_indented = false +ij_shell_use_unix_line_separator = true [{*.markdown,*.md}] ij_markdown_force_one_space_after_blockquote_symbol = true ij_markdown_force_one_space_after_header_symbol = true ij_markdown_force_one_space_after_list_bullet = true ij_markdown_force_one_space_between_words = true +ij_markdown_format_tables = true +ij_markdown_insert_quote_arrows_on_wrap = true ij_markdown_keep_indents_on_empty_lines = false +ij_markdown_keep_line_breaks_inside_text_blocks = true ij_markdown_max_lines_around_block_elements = 1 ij_markdown_max_lines_around_header = 1 ij_markdown_max_lines_between_paragraphs = 1 ij_markdown_min_lines_around_block_elements = 1 ij_markdown_min_lines_around_header = 1 ij_markdown_min_lines_between_paragraphs = 1 +ij_markdown_wrap_text_if_long = true +ij_markdown_wrap_text_inside_blockquotes = true [{*.yaml,*.yml}] indent_size = 2 @@ -298,6 +335,9 @@ ij_yaml_block_mapping_on_new_line = false ij_yaml_indent_sequence_value = true ij_yaml_keep_indents_on_empty_lines = false ij_yaml_keep_line_breaks = true +ij_yaml_line_comment_add_space = false +ij_yaml_line_comment_add_space_on_reformat = false +ij_yaml_line_comment_at_first_column = true ij_yaml_sequence_on_new_line = false ij_yaml_space_before_colon = false ij_yaml_spaces_within_braces = true