diff --git a/src/main/java/fr/pasteur/ida/zellige/command/Zellige.java b/src/main/java/fr/pasteur/ida/zellige/command/Zellige.java index d4c9034be7525bf16353a0418fc6bbe37bfe0dc3..a4575deca8b5a62bddacbdcdc8c40fda60021cc6 100644 --- a/src/main/java/fr/pasteur/ida/zellige/command/Zellige.java +++ b/src/main/java/fr/pasteur/ida/zellige/command/Zellige.java @@ -30,37 +30,18 @@ package fr.pasteur.ida.zellige.command; import fr.pasteur.ida.zellige.gui.MainAppFrame; -import net.imagej.DatasetService; import net.imagej.ImageJ; -import net.imagej.display.ImageDisplayService; -import org.scijava.command.Command; -import org.scijava.log.LogService; -import org.scijava.plugin.Parameter; +import org.scijava.command.ContextCommand; import org.scijava.plugin.Plugin; import java.io.File; import java.io.IOException; import java.nio.file.FileSystems; -@Plugin( type = Command.class, menuPath = "Plugins>Zellige>" ) -public class Zellige implements Command +@Plugin( type = Zellige.class, menuPath = "Plugins>Zellige>" ) +public class Zellige extends ContextCommand { - @Parameter - private ImageJ ij; - - @Parameter - private LogService logService; - - @Parameter - private ImageDisplayService imageDisplayService; - - @Parameter - private ImageDisplayService image; - - @Parameter - DatasetService datasetService; - public static void main( String[] args ) throws IOException { @@ -94,8 +75,8 @@ public class Zellige implements Command { // Launch JavaFX interface - MainAppFrame app = new MainAppFrame( ij, image, logService ); - app.setTitle( "Zellige V1.0.1" ); + MainAppFrame app = new MainAppFrame( context() ); + app.setTitle( "Zellige v1.0.1" ); app.init(); } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/MainAppFrame.java b/src/main/java/fr/pasteur/ida/zellige/gui/MainAppFrame.java index ad564e5568a4e46c44dd87df7908192436d2cf2b..e1803dd3cb0165420b5e977111c0fc433f2488e0 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/MainAppFrame.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/MainAppFrame.java @@ -40,6 +40,7 @@ import net.imagej.ImageJ; import net.imagej.display.ImageDisplayService; import net.imglib2.type.NativeType; import net.imglib2.type.numeric.RealType; +import org.scijava.Context; import org.scijava.log.LogService; import org.scijava.plugin.Parameter; import org.slf4j.Logger; @@ -57,7 +58,7 @@ public class MainAppFrame extends JFrame { private final static Logger LOGGER = LoggerFactory.getLogger( MainAppFrame.class ); - private final ImageJ ij; + private ImageJ ij; private final ImageDisplayService image; @Parameter private final LogService logService; @@ -99,11 +100,13 @@ public class MainAppFrame extends JFrame logbackLogger.addAppender( appender ); } - public MainAppFrame( ImageJ ij, ImageDisplayService image, LogService logService ) + public MainAppFrame( Context context ) { - this.ij = ij; - this.image = image; - this.logService = logService; +// this.ij = context.; + this.image = context.getService( ImageDisplayService.class ); + ; + this.logService = context.getService( LogService.class ); + ; this.setIconImages( ICONS ); } diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/MainController.java b/src/main/java/fr/pasteur/ida/zellige/gui/MainController.java index 57367c7cb6e9c232f05caafd6a6a941e5eb19df9..2e952628d712181118145f420a14f8abe5148f58 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/MainController.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/MainController.java @@ -459,7 +459,7 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme public void saveParameters() throws IOException { SimpleDateFormat dtf = new SimpleDateFormat( "yyyyMMdd_HHmmss" ); - FileChooser fileChooser = chooseAFile( dtf.format( new Date() ), "Sava Parameters...", "ZelligeParameters", "*.zellige.param.json" ); + FileChooser fileChooser = chooseAFile( dtf.format( new Date() ) + "_zellige_param", "Sava Parameters...", "ZelligeParameters", "*.json" ); File file = fileChooser.showSaveDialog( null ); if ( file != null ) { diff --git a/src/main/java/fr/pasteur/ida/zellige/gui/SelectionController.java b/src/main/java/fr/pasteur/ida/zellige/gui/SelectionController.java index d06203683cfd578e29e307159924a957704d5363..35059ae32d45cfe1b392007e5bc81612f70dc7af 100644 --- a/src/main/java/fr/pasteur/ida/zellige/gui/SelectionController.java +++ b/src/main/java/fr/pasteur/ida/zellige/gui/SelectionController.java @@ -87,7 +87,7 @@ public class SelectionController implements Initializable amplitude.sliderProperty().addListener( ( observableValue, number, newValue ) -> { - if ( amplitude.hasChanged( newValue ) ) + if ( amplitude.hasChanged( newValue ) && selectionModel.selectedAmplitudeProperty().getValue() != null ) { disableGUI.setValue( true ); selectionModel.runAmplitudeTask(); @@ -98,7 +98,7 @@ public class SelectionController implements Initializable /* Otsu slider initialization */ otsu.sliderProperty().addListener( ( observableValue, number, newValue ) -> { - if ( otsu.hasChanged( newValue ) ) + if ( otsu.hasChanged( newValue ) && selectionModel.selectedOtsuProperty().getValue() != null ) { disableGUI.setValue( true ); selectionModel.runOtsuTask();