From 1c982d5cf66bec2ab55e6da4fd217362255668bb Mon Sep 17 00:00:00 2001 From: ctrebeau <ctrebeau@pasteur.fr> Date: Thu, 10 Apr 2025 09:49:45 +0200 Subject: [PATCH] feat(gui): Add two bound StringProperties to pass input name from Preprocessing to Projection controller - Introduced two StringProperty fields in the GUI, bound to each other - Used to transfer the input name from the PreprocessingController to the ProjectionController - Input name is now displayed in the Projection view --- .../ida/zellige/gui/controller/MainController.java | 1 + .../gui/controller/PreprocessingController.java | 1 + .../gui/interactor/ProjectionInteractor.java | 4 +++- .../ida/zellige/gui/model/PreprocessingModel.java | 14 ++++++++++---- .../ida/zellige/gui/model/ProjectionModel.java | 8 ++++++++ 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/controller/MainController.java b/src/main/java/fr/pasteur/ida/zellige/gui/controller/MainController.java index 0edc9cf..29572a0 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/controller/MainController.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/controller/MainController.java @@ -122,6 +122,7 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme constructionController.getModel().getInput().bind( preprocessingController.getModel().getInput() ); constructionController.getModel().getFactory().bind( preprocessingController.getModel().getFactory() ); projectionController.getModel().getColors().bind( preprocessingController.getModel().getColors() ); + projectionController.getModel().inputNameProperty().bind(preprocessingController.getModel().inputNameProperty()); // Sets the projection display when the projection tab is clicked on. tabPane.getTabs().get( 2 ).selectedProperty().addListener( ( observableValue, number, newValue ) -> diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/controller/PreprocessingController.java b/src/main/java/fr/pasteur/ida/zellige/gui/controller/PreprocessingController.java index 115c548..dda6761 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/controller/PreprocessingController.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/controller/PreprocessingController.java @@ -119,6 +119,7 @@ public class PreprocessingController< T extends RealType< T > & NativeType< T > { getModel().getInput().set( ( RandomAccessibleInterval< T > ) newValue.getImgPlus() ); } + getModel().inputNameProperty().set( FilenameUtils.removeExtension( newValue.getName() )); // Set the input factory getModel().getFactory().setValue( ( ImgFactory< T > ) newValue.getImgPlus().factory() ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/interactor/ProjectionInteractor.java b/src/main/java/fr/pasteur/ida/zellige/gui/interactor/ProjectionInteractor.java index da9929b..0848789 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/interactor/ProjectionInteractor.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/interactor/ProjectionInteractor.java @@ -40,7 +40,9 @@ public class ProjectionInteractor< T extends RealType< T > & NativeType< T > > { LOGGER.debug( "The projection has succeed!" ); // Wraps the projection inside an ImgPlus to display the colors if necessary. - ImgPlus< T > imgPlus = ReferenceSurfaceProjection.setColorsAndName( task.getValue(), getModel().getColors().get(), "" ); + String inputName = getModel().inputNameProperty().get(); + String projectionName = String.format( "%s_proj_%d", inputName, ( index + 1 ) ); + ImgPlus< T > imgPlus = ReferenceSurfaceProjection.setColorsAndName( task.getValue(), getModel().getColors().get(), projectionName ); Context context = ( Context ) IJ.runPlugIn( "org.scijava.Context", "" ); net.imagej.ImageJ ij = new net.imagej.ImageJ( context ); ij.ui().show( imgPlus ); diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/model/PreprocessingModel.java b/src/main/java/fr/pasteur/ida/zellige/gui/model/PreprocessingModel.java index 8c5f28c..41e406e 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/model/PreprocessingModel.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/model/PreprocessingModel.java @@ -1,9 +1,6 @@ package fr.pasteur.ida.zellige.gui.model; -import javafx.beans.property.IntegerProperty; -import javafx.beans.property.SimpleBooleanProperty; -import javafx.beans.property.SimpleIntegerProperty; -import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.property.*; import net.imglib2.RandomAccessibleInterval; import net.imglib2.display.ColorTable; import net.imglib2.img.Img; @@ -17,6 +14,8 @@ import java.util.ArrayList; public class PreprocessingModel< T extends RealType< T > & NativeType< T > > { + private final StringProperty inputName = new SimpleStringProperty(); + private final IntegerProperty bin = new SimpleIntegerProperty(); private final IntegerProperty channel = new SimpleIntegerProperty(); @@ -35,6 +34,13 @@ public class PreprocessingModel< T extends RealType< T > & NativeType< T > > private final SimpleObjectProperty< ArrayList< ColorTable > > colors = new SimpleObjectProperty<>(new ArrayList<>()); + + + public StringProperty inputNameProperty() + { + return inputName; + } + public IntegerProperty binProperty() { return bin; diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/model/ProjectionModel.java b/src/main/java/fr/pasteur/ida/zellige/gui/model/ProjectionModel.java index b22dd85..9d0efef 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/model/ProjectionModel.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/model/ProjectionModel.java @@ -41,6 +41,7 @@ import java.util.ArrayList; public class ProjectionModel< T extends RealType< T > & NativeType< T > > { + private final SimpleStringProperty inputName = new SimpleStringProperty(); private final SimpleObjectProperty< ArrayList< ReferenceSurface< T > > > referenceSurfaces = new SimpleObjectProperty<>( new ArrayList<>() ); private final SimpleObjectProperty< ArrayList< ProjectionProperties< T > > > projectionProperties = new SimpleObjectProperty<>( new ArrayList<>() ); private final SimpleObjectProperty< ImageView[] > imageViews = new SimpleObjectProperty<>(); @@ -48,6 +49,13 @@ public class ProjectionModel< T extends RealType< T > & NativeType< T > > private final SimpleIntegerProperty numberOfChannels = new SimpleIntegerProperty(); private final SimpleObjectProperty<ArrayList< ColorTable >> colors = new SimpleObjectProperty<>(); + + + public SimpleStringProperty inputNameProperty() + { + return inputName; + } + public SimpleObjectProperty< ArrayList< ReferenceSurface< T > > > getReferenceSurfaces() { return referenceSurfaces; -- GitLab