Skip to content
Snippets Groups Projects
Commit dc73e7b1 authored by Céline  TREBEAU's avatar Céline TREBEAU
Browse files

- Addition of a null item at the end of the combo box displaying the files....

- Addition of a null item at the end of the combo box displaying the files. the null item is  selected when  an invalid file has been chosen by the user.
parent 2cbc5942
No related branches found
No related tags found
1 merge request!39Resolve "Selection of a new input image issue after loading a wrong image"
Pipeline #153954 failed
...@@ -33,6 +33,7 @@ import fr.pasteur.ida.zellige.gui.LogAppender; ...@@ -33,6 +33,7 @@ import fr.pasteur.ida.zellige.gui.LogAppender;
import fr.pasteur.ida.zellige.gui.MainAppFrame; import fr.pasteur.ida.zellige.gui.MainAppFrame;
import fr.pasteur.ida.zellige.gui.exception.NoA3DStackException; import fr.pasteur.ida.zellige.gui.exception.NoA3DStackException;
import fr.pasteur.ida.zellige.gui.exception.NoInputException; import fr.pasteur.ida.zellige.gui.exception.NoInputException;
import fr.pasteur.ida.zellige.gui.exception.TimeLapseException;
import fr.pasteur.ida.zellige.gui.model.ConstructionModel; import fr.pasteur.ida.zellige.gui.model.ConstructionModel;
import fr.pasteur.ida.zellige.gui.model.MainModel; import fr.pasteur.ida.zellige.gui.model.MainModel;
import fr.pasteur.ida.zellige.gui.model.ProjectionModel; import fr.pasteur.ida.zellige.gui.model.ProjectionModel;
...@@ -106,6 +107,7 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme ...@@ -106,6 +107,7 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
alert.setTitle( "Error alert" ); alert.setTitle( "Error alert" );
alert.setHeaderText( exception.getMessage() ); alert.setHeaderText( exception.getMessage() );
alert.showAndWait(); alert.showAndWait();
// throw new RuntimeException(exception);
} }
@Override @Override
...@@ -118,14 +120,18 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme ...@@ -118,14 +120,18 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
activeDatasets.getSelectionModel().selectedItemProperty().addListener( ( observableValue, oldValue, newValue ) -> activeDatasets.getSelectionModel().selectedItemProperty().addListener( ( observableValue, oldValue, newValue ) ->
{ {
LOGGER.debug( "selectedItemProperty : old value = {}, new value = {} ", oldValue, newValue );
if(newValue!= null && isValid( newValue ))
{
LOGGER.debug( "selectedItemProperty : old value = {}, new value = {} ", oldValue, newValue ); setCurrentDataset( newValue );
}
if ( newValue != null ) else
{ {
setCurrentDataset( newValue ); activeDatasets.getSelectionModel().selectLast();
} }
} ); } );
currentDataset.addListener( ( observableValue, dataset, t1 ) -> currentDataset.addListener( ( observableValue, dataset, t1 ) ->
{ {
if ( t1 != null ) if ( t1 != null )
...@@ -186,7 +192,6 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme ...@@ -186,7 +192,6 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
} }
} ); } );
// Update of the program status using LOG.INFO outputs // Update of the program status using LOG.INFO outputs
LogAppender.logMsgProperty().addListener( ( observable, oldValue, newValue ) -> LogAppender.logMsgProperty().addListener( ( observable, oldValue, newValue ) ->
Platform.runLater( Platform.runLater(
...@@ -199,6 +204,9 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme ...@@ -199,6 +204,9 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
LOGGER.debug( "Init Extraction" ); LOGGER.debug( "Init Extraction" );
Dataset dataset = mainAppFrame.getImage().getActiveDataset(); Dataset dataset = mainAppFrame.getImage().getActiveDataset();
LOGGER.debug( dataset.getImgPlus().firstElement().getClass().toGenericString() );
LOGGER.debug( "Function getFrames() :{}", dataset.getFrames() );
LOGGER.debug( "Properties :{}", dataset.getImgPlus().getProperties() );
if ( dataset == null ) if ( dataset == null )
{ {
showError( new NoInputException() ); showError( new NoInputException() );
...@@ -208,52 +216,6 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme ...@@ -208,52 +216,6 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
LOGGER.debug( "Init Extraction completed" ); LOGGER.debug( "Init Extraction completed" );
} }
/* LOG INFO
// long[] dims = new long[ currentDataset.numDimensions() ];
// currentDataset.dimensions( dims );
// mainAppFrame.getLogService().info( "Zellige received the image: " + currentDataset.getName() );
// mainAppFrame.getLogService().info( "Size: " + Util.printInterval( currentDataset ) );
// mainAppFrame.getLogService().info( "Type: " + currentDataset.firstElement().getClass().toGenericString() );
// mainAppFrame.getLogService().info( "Dimensionality: " + currentDataset.numDimensions() + "D" );
// for ( int d = 0; d < currentDataset.numDimensions(); d++ )
// {
// mainAppFrame.getLogService().info( " - dimension " + d + ": [" + currentDataset.axis( d ).type() + "], 1 unit = " + currentDataset.averageScale( d ) + " " + currentDataset.axis( d ).unit() );
// }
// // Fixed parameters
// String filter = "GaussianBlur";
// double filterParameter = 2;
// // End of fixed parameters.
// int connexity = 4;
//
// double startingOsSize1 = constructionController.getSt1();
// int overlap1 = constructionController.getR1();
// double connexityRate1 = constructionController.getC1();
// double startingOsSize2 = constructionController.getSt2();
// int overlap2 = constructionController.getR2();
// double connexityRate2 = constructionController.getC2();
// double surfaceMinSizeFactor = constructionController.getSurfaceSize();
// int delta = projectionController.getDelta();
// String method = projectionController.getMethod();
// /* Print parameters.*/
/* mainAppFrame.getLogService().info( "Input : " + currentDataset.getName() );
// mainAppFrame.getLogService().info( "filter : " + filter );
// mainAppFrame.getLogService().info( "filterParameter : " + filterParameter );
// mainAppFrame.getLogService().info( "amplitude : " + getAmplitude() );
// mainAppFrame.getLogService().info( "threshold : " + getOtsu() );
// mainAppFrame.getLogService().info( "connexity : " + connexity );
// mainAppFrame.getLogService().info( "islandSize : " + getIsland() );
// mainAppFrame.getLogService().info( "sigmaXY : " + getSigmaXY() );
// mainAppFrame.getLogService().info( "sigmaZ : " + getSigmaZ() );
// mainAppFrame.getLogService().info( "startingOsSize1 : " + startingOsSize1 );
// mainAppFrame.getLogService().info( "overlap1 : " + overlap1 );
// mainAppFrame.getLogService().info( "connexityRate1 : " + connexityRate1 );
// mainAppFrame.getLogService().info( "startingOsSize2 : " + startingOsSize2 );
// mainAppFrame.getLogService().info( "overlap2 : " + overlap2 );
// mainAppFrame.getLogService().info( "connexityRate2 : " + connexityRate2 );
// mainAppFrame.getLogService().info( "surfaceMinimumSizeFactor : " + surfaceMinSizeFactor );
// mainAppFrame.getLogService().info( "delta : " + delta + "\n" );
// /* End of Print parameters.*/
public void run2() public void run2()
{ {
...@@ -274,7 +236,6 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme ...@@ -274,7 +236,6 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
selectionController.getSelectionModel().runPixelSelection(); selectionController.getSelectionModel().runPixelSelection();
} }
LOGGER.debug( "###########################################---NEW RUN---###########################################" ); LOGGER.debug( "###########################################---NEW RUN---###########################################" );
// ZelligeParameters.serialize( new ZelligeParameters( model ) );
} }
private void runPretreatment( Dataset dataset ) private void runPretreatment( Dataset dataset )
...@@ -292,7 +253,9 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme ...@@ -292,7 +253,9 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
{ {
LOGGER.debug( "Datasets displayed successfully" ); LOGGER.debug( "Datasets displayed successfully" );
ObservableList< Dataset > list = FXCollections.observableArrayList( displayTask.getValue() ); ObservableList< Dataset > list = FXCollections.observableArrayList( displayTask.getValue() );
list.add( null );
activeDatasets.setItems( list ); activeDatasets.setItems( list );
LOGGER.debug( "item selected : list size = " + list.size() ); LOGGER.debug( "item selected : list size = " + list.size() );
if ( list.isEmpty() ) if ( list.isEmpty() )
{ {
...@@ -307,21 +270,11 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme ...@@ -307,21 +270,11 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
public void setCurrentDataset( Dataset dataset ) public void setCurrentDataset( Dataset dataset )
{ {
if ( dataset != currentDataset.getValue() )
{
if ( dataset.numDimensions() != 3 )
{
LOGGER.debug( "show error!!!" );
showError( new NoA3DStackException() );
}
else
{
currentDataset.setValue( dataset ); currentDataset.setValue( dataset );
Img< T > input = ( ImgPlus< T > ) dataset.getImgPlus(); Img< T > input = ( ImgPlus< T > ) dataset.getImgPlus();
constructionController.getConstructionModel().setInput( input ); constructionController.getConstructionModel().setInput( input );
constructionController.getConstructionModel().setFactory( input.factory() ); constructionController.getConstructionModel().setFactory( input.factory() );
}
}
} }
public void computeClassifiedImages() public void computeClassifiedImages()
...@@ -419,6 +372,26 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme ...@@ -419,6 +372,26 @@ public class MainController< T extends RealType< T > & NativeType< T > > impleme
projectionController.setParameters( parameters ); projectionController.setParameters( parameters );
} }
private boolean isValid(Dataset dataset)
{
int numZ = ( int ) dataset.getDepth();
int numFrames = ( int ) dataset.getFrames();
LOGGER.debug( "NUmber of dimensions: {}", dataset.numDimensions() );
LOGGER.debug( "NUmber of channels: {}", dataset.getChannels() );
LOGGER.debug( "Number of frames: {}", dataset.getFrames() );
if ( numFrames > 1 )
{
LOGGER.debug( "TimeLapseException" );
showError( new TimeLapseException() );
return false;
}
if ( numZ == 1 )
{
LOGGER.debug( "NoA3DStackException" );
showError( new NoA3DStackException() );
return false;
}
return true;
}
} }
package fr.pasteur.ida.zellige.gui.exception;
public class TimeLapseException extends Exception
{
@Override
public String getMessage()
{
return "Zellige doesn't handle time-lapse images for now !";
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment