From 4ea79ac9ef1ab7d8ae8ff18f489ece53c1e8b5fe Mon Sep 17 00:00:00 2001 From: carlosuc3m <100329787@alumnos.uc3m.es> Date: Tue, 23 Apr 2024 16:44:52 +0200 Subject: [PATCH] reorder packages and code --- ...bstractSamJ.java => AbstractSamJ_old.java} | 0 .../java/ai/nets/samj/gui/SAMJDialog.java | 2 +- .../java/ai/nets/samj/gui/SAMModelPanel.java | 2 +- .../samj/{ => install}/SamEnvManager.java | 4 +++- .../AbstractSamJ.java} | 4 ++-- .../nets/samj/{ => models}/EfficientSamJ.java | 19 ++++--------------- .../samj/{ => models}/EfficientViTSamJ.java | 7 +++++-- .../samj/{ => models}/ImgLib2SAMUtils.java | 8 ++++---- .../nets/samj/{ => models}/PythonMethods.java | 2 +- 9 files changed, 21 insertions(+), 27 deletions(-) rename src/main/java/ai/nets/samj/{AbstractSamJ.java => AbstractSamJ_old.java} (100%) rename src/main/java/ai/nets/samj/{ => install}/SamEnvManager.java (99%) rename src/main/java/ai/nets/samj/{AbstractSamJ2.java => models/AbstractSamJ.java} (99%) rename src/main/java/ai/nets/samj/{ => models}/EfficientSamJ.java (97%) rename src/main/java/ai/nets/samj/{ => models}/EfficientViTSamJ.java (99%) rename src/main/java/ai/nets/samj/{ => models}/ImgLib2SAMUtils.java (96%) rename src/main/java/ai/nets/samj/{ => models}/PythonMethods.java (99%) diff --git a/src/main/java/ai/nets/samj/AbstractSamJ.java b/src/main/java/ai/nets/samj/AbstractSamJ_old.java similarity index 100% rename from src/main/java/ai/nets/samj/AbstractSamJ.java rename to src/main/java/ai/nets/samj/AbstractSamJ_old.java diff --git a/src/main/java/ai/nets/samj/gui/SAMJDialog.java b/src/main/java/ai/nets/samj/gui/SAMJDialog.java index 938c91a..7e30588 100644 --- a/src/main/java/ai/nets/samj/gui/SAMJDialog.java +++ b/src/main/java/ai/nets/samj/gui/SAMJDialog.java @@ -62,7 +62,7 @@ import ai.nets.samj.ui.PromptsResultsDisplay.SAMJException; import ai.nets.samj.ui.SAMJLogger; import ai.nets.samj.ui.UtilityMethods; -import ai.nets.samj.SamEnvManager; +import ai.nets.samj.install.SamEnvManager; /** * Class that creates a default graphical user interface to interact with SAMJ models diff --git a/src/main/java/ai/nets/samj/gui/SAMModelPanel.java b/src/main/java/ai/nets/samj/gui/SAMModelPanel.java index bde60f1..d60facc 100644 --- a/src/main/java/ai/nets/samj/gui/SAMModelPanel.java +++ b/src/main/java/ai/nets/samj/gui/SAMModelPanel.java @@ -54,7 +54,7 @@ import ai.nets.samj.gui.components.HTMLPane; import ai.nets.samj.gui.tools.Files; import io.bioimage.modelrunner.apposed.appose.Mamba; -import ai.nets.samj.SamEnvManager; +import ai.nets.samj.install.SamEnvManager; /** * Class that creates a subpanel in the main panel of SAMJ default GUI. diff --git a/src/main/java/ai/nets/samj/SamEnvManager.java b/src/main/java/ai/nets/samj/install/SamEnvManager.java similarity index 99% rename from src/main/java/ai/nets/samj/SamEnvManager.java rename to src/main/java/ai/nets/samj/install/SamEnvManager.java index 10090c3..8f9c10d 100644 --- a/src/main/java/ai/nets/samj/SamEnvManager.java +++ b/src/main/java/ai/nets/samj/install/SamEnvManager.java @@ -17,7 +17,7 @@ * limitations under the License. * #L% */ -package ai.nets.samj; +package ai.nets.samj.install; import java.io.File; import java.io.IOException; @@ -47,6 +47,8 @@ import io.bioimage.modelrunner.utils.CommonUtils; import org.apache.commons.compress.archivers.ArchiveException; + +import ai.nets.samj.models.EfficientViTSamJ; import io.bioimage.modelrunner.apposed.appose.Mamba; import io.bioimage.modelrunner.apposed.appose.MambaInstallException; import io.bioimage.modelrunner.apposed.appose.MambaInstallerUtils; diff --git a/src/main/java/ai/nets/samj/AbstractSamJ2.java b/src/main/java/ai/nets/samj/models/AbstractSamJ.java similarity index 99% rename from src/main/java/ai/nets/samj/AbstractSamJ2.java rename to src/main/java/ai/nets/samj/models/AbstractSamJ.java index 884e1a5..a6b7b94 100644 --- a/src/main/java/ai/nets/samj/AbstractSamJ2.java +++ b/src/main/java/ai/nets/samj/models/AbstractSamJ.java @@ -17,7 +17,7 @@ * limitations under the License. * #L% */ -package ai.nets.samj; +package ai.nets.samj.models; import java.lang.AutoCloseable; import java.time.LocalDateTime; @@ -52,7 +52,7 @@ * @author Carlos Garcia * @author vladimir Ulman */ -public abstract class AbstractSamJ2 implements AutoCloseable { +public abstract class AbstractSamJ implements AutoCloseable { protected static int LOWER_REENCODE_THRESH = 50; diff --git a/src/main/java/ai/nets/samj/EfficientSamJ.java b/src/main/java/ai/nets/samj/models/EfficientSamJ.java similarity index 97% rename from src/main/java/ai/nets/samj/EfficientSamJ.java rename to src/main/java/ai/nets/samj/models/EfficientSamJ.java index 499a5e9..956bad5 100644 --- a/src/main/java/ai/nets/samj/EfficientSamJ.java +++ b/src/main/java/ai/nets/samj/models/EfficientSamJ.java @@ -17,26 +17,17 @@ * limitations under the License. * #L% */ -package ai.nets.samj; +package ai.nets.samj.models; + +import ai.nets.samj.install.SamEnvManager; -import java.lang.AutoCloseable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.awt.Polygon; -import java.awt.Rectangle; import java.io.File; import java.io.IOException; import io.bioimage.modelrunner.apposed.appose.Environment; -import io.bioimage.modelrunner.apposed.appose.Service; import io.bioimage.modelrunner.apposed.appose.Service.Task; import io.bioimage.modelrunner.apposed.appose.Service.TaskStatus; import io.bioimage.modelrunner.tensor.shm.SharedMemoryArray; -import io.bioimage.modelrunner.utils.CommonUtils; import net.imglib2.RandomAccessibleInterval; import net.imglib2.converter.RealTypeConverters; import net.imglib2.img.array.ArrayImgs; @@ -44,9 +35,7 @@ import net.imglib2.type.numeric.RealType; import net.imglib2.type.numeric.integer.UnsignedByteType; import net.imglib2.type.numeric.real.FloatType; -import net.imglib2.util.Cast; import net.imglib2.util.Intervals; -import net.imglib2.util.Util; import net.imglib2.view.IntervalView; import net.imglib2.view.Views; @@ -55,7 +44,7 @@ * @author Carlos Garcia * @author vladimir Ulman */ -public class EfficientSamJ extends AbstractSamJ2 { +public class EfficientSamJ extends AbstractSamJ { /** * All the Python imports and configurations needed to start using EfficientSAM. */ diff --git a/src/main/java/ai/nets/samj/EfficientViTSamJ.java b/src/main/java/ai/nets/samj/models/EfficientViTSamJ.java similarity index 99% rename from src/main/java/ai/nets/samj/EfficientViTSamJ.java rename to src/main/java/ai/nets/samj/models/EfficientViTSamJ.java index 3e61ed7..a383f9c 100644 --- a/src/main/java/ai/nets/samj/EfficientViTSamJ.java +++ b/src/main/java/ai/nets/samj/models/EfficientViTSamJ.java @@ -17,11 +17,14 @@ * limitations under the License. * #L% */ -package ai.nets.samj; +package ai.nets.samj.models; import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; + +import ai.nets.samj.install.SamEnvManager; + import java.io.File; import java.io.IOException; @@ -46,7 +49,7 @@ * @author Carlos Javier Garcia Lopez de Haro * @author Vladimir Ulman */ -public class EfficientViTSamJ extends AbstractSamJ2 { +public class EfficientViTSamJ extends AbstractSamJ { /** * Map that associates the key for each of the existing EfficientViTSAM models to its complete name */ diff --git a/src/main/java/ai/nets/samj/ImgLib2SAMUtils.java b/src/main/java/ai/nets/samj/models/ImgLib2SAMUtils.java similarity index 96% rename from src/main/java/ai/nets/samj/ImgLib2SAMUtils.java rename to src/main/java/ai/nets/samj/models/ImgLib2SAMUtils.java index b631e3b..e701556 100644 --- a/src/main/java/ai/nets/samj/ImgLib2SAMUtils.java +++ b/src/main/java/ai/nets/samj/models/ImgLib2SAMUtils.java @@ -1,6 +1,6 @@ -package ai.nets.samj; +package ai.nets.samj.models; -import ai.nets.samj.AbstractSamJ2.DebugTextPrinter; +import ai.nets.samj.models.AbstractSamJ.DebugTextPrinter; import net.imglib2.IterableInterval; import net.imglib2.RandomAccessibleInterval; import net.imglib2.converter.Converter; @@ -132,11 +132,11 @@ RandomAccessibleInterval convertViewToRGB(final RandomAccessib protected static & NativeType> RandomAccessibleInterval reescaleIfNeeded(RandomAccessibleInterval rai) { if ((rai.dimensionsAsLongArray()[0] > rai.dimensionsAsLongArray()[1]) - && (rai.dimensionsAsLongArray()[0] > AbstractSamJ2.MAX_ENCODED_AREA_RS)) { + && (rai.dimensionsAsLongArray()[0] > AbstractSamJ.MAX_ENCODED_AREA_RS)) { // TODO reescale return rai; } else if ((rai.dimensionsAsLongArray()[0] < rai.dimensionsAsLongArray()[1]) - && (rai.dimensionsAsLongArray()[1] > AbstractSamJ2.MAX_ENCODED_SIDE)) { + && (rai.dimensionsAsLongArray()[1] > AbstractSamJ.MAX_ENCODED_SIDE)) { // TODO reescale return rai; } else { diff --git a/src/main/java/ai/nets/samj/PythonMethods.java b/src/main/java/ai/nets/samj/models/PythonMethods.java similarity index 99% rename from src/main/java/ai/nets/samj/PythonMethods.java rename to src/main/java/ai/nets/samj/models/PythonMethods.java index 41d76f6..a6243aa 100644 --- a/src/main/java/ai/nets/samj/PythonMethods.java +++ b/src/main/java/ai/nets/samj/models/PythonMethods.java @@ -17,7 +17,7 @@ * limitations under the License. * #L% */ -package ai.nets.samj; +package ai.nets.samj.models; /** * Class that declares the Python methods that can be used then in the script for several tasks