Java Code Examples for fiji.util.gui.GenericDialogPlus#getNextBoolean()

The following examples show how to use fiji.util.gui.GenericDialogPlus#getNextBoolean() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Load_Tile_Configuration.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void run(String arg)
{
	// load SpimData
	final LoadParseQueryXML result = new LoadParseQueryXML();
	if ( !result.queryXML( "to load a TileConfiguration for", false, false, false, false, false ) )
		return;
	final SpimData2 data = result.getData();

	// ask for parameters
	final GenericDialogPlus gd = new GenericDialogPlus( "" );
	gd.addFileField( "TileConfiguration file", defaultTCFile );
	gd.addCheckbox( "Use_pixel_units", true );
	gd.addCheckbox( "Keep_metadata_rotation", true );

	gd.showDialog();

	if ( gd.wasCanceled() )
		return;

	defaultTCFile = gd.getNextString();
	final boolean pixelUnits = gd.getNextBoolean();
	final boolean metadataRotate = gd.getNextBoolean();

	// apply
	final Map< ViewId, Translation3D > tcParsed = TileConfigurationHelpers.parseTileConfiguration( new File( defaultTCFile ) );
	final Map< ViewId, Translation3D > transformsForData = TileConfigurationHelpers.getTransformsForData( tcParsed, pixelUnits, data );
	TileConfigurationHelpers.applyToData( transformsForData, pixelUnits, metadataRotate, data );

	// save result
	SpimData2.saveXML( data, result.getXMLFileName(), result.getClusterExtension() );
}
 
Example 2
Source File: Resave_TIFF.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public static Parameters getParameters()
{
	final GenericDialogPlus gd = new GenericDialogPlus( "Resave dataset as TIFF" );

	if ( defaultPath == null )
		defaultPath = LoadParseQueryXML.defaultXMLfilename;

	PluginHelper.addSaveAsFileField( gd, "Select new XML", defaultPath, 80 );
	
	gd.addChoice( "ImgLib2_data_container", StackList.imglib2Container, StackList.imglib2Container[ defaultContainer ] );
	gd.addCheckbox( "Lossless compression of TIFF files (ZIP)", defaultCompress );
	gd.addMessage( "Use ArrayImg if -ALL- input views are smaller than ~2048x2048x500 px (2^31 px), or if the\n" +
				   "program throws an OutOfMemory exception while processing.  CellImg is slower, but more\n" +
			       "memory efficient and supports much larger file sizes only limited by the RAM of the machine.", 
			       new Font( Font.SANS_SERIF, Font.ITALIC, 11 ) );

	gd.showDialog();
	
	if ( gd.wasCanceled() )
		return null;

	final Parameters params = new Parameters();
	
	params.xmlFile = gd.getNextString();
	
	if ( !params.xmlFile.endsWith( ".xml" ) )
		params.xmlFile += ".xml";

	params.compress = defaultCompress = gd.getNextBoolean();

	defaultPath = LoadParseQueryXML.defaultXMLfilename = params.xmlFile;

	if ( ( defaultContainer = gd.getNextChoiceIndex() ) == 0 )
		params.imgFactory = new ArrayImgFactory< FloatType >();
	else
		params.imgFactory = new CellImgFactory< FloatType >();

	return params;
}
 
Example 3
Source File: DHM.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
protected DHMMetaData queryDirectoryAndRatio()
{
	GenericDialogPlus gd = new GenericDialogPlus( "Specify Holographic Acquistion Directory" );

	gd.addDirectoryField( "Holographic_Acquisition main directory", defaultDir, 50 );

	gd.addMessage( "" );
	gd.addMessage( "Camera pixel size (e.g. 3.45um) / Magnification (e.g. 20):" );
	gd.addNumericField( "Pixel_distance_x", defaulCalX, 5 );
	gd.addNumericField( "Pixel_distance_y", defaulCalY, 5 );
	gd.addMessage( "Depth between planes (e.g. 0.5mm) / Magnification^2 (e.g. 20^2) * 1000 (mm to um):" );
	gd.addNumericField( "Pixel_distance_z", defaulCalZ, 5 );
	gd.addStringField( "Pixel_unit", defaulCalUnit );
	gd.addMessage( "" );
	gd.addCheckbox( "Open_all planes to ensure they have the same dimensions (takes time!)", defaultOpenAll );
	gd.showDialog();

	if ( gd.wasCanceled() )
		return null;

	return new DHMMetaData(
			new File( defaultDir = gd.getNextString() ),
			defaulCalX = gd.getNextNumber(),
			defaulCalY = gd.getNextNumber(),
			defaulCalZ = gd.getNextNumber(),
			defaulCalUnit = gd.getNextString(),
			defaultOpenAll = gd.getNextBoolean() );
}
 
Example 4
Source File: Stitching_Grid.java    From Stitching with GNU General Public License v2.0 4 votes vote down vote up
protected ArrayList< ImageCollectionElement > getAllFilesInDirectory( final String directory, final boolean confirmFiles )
{
	// get all files from the directory
	final File dir = new File( directory );
	if ( !dir.isDirectory() )
	{
		Log.error( "'" + directory + "' is not a directory. stop.");
		return null;
	}
	
	final String[] imageFiles = dir.list();
	final ArrayList<String> files = new ArrayList<String>();
	for ( final String fileName : imageFiles )
	{
		File file = new File( dir, fileName );
		
		if ( file.isFile() && !file.isHidden() && !fileName.endsWith( ".txt" ) && !fileName.endsWith( ".TXT" ) )
		{
			Log.info( file.getPath() );
			files.add( fileName );
		}
	}
	
	Log.info( "Found " + files.size() + " files (we ignore hidden and .txt files)." );
	
	if ( files.size() < 2 )
	{
		Log.error( "Only " + files.size() + " files found in '" + dir.getPath() + "', you need at least 2 - stop." );
		return null ;
	}
	
	final boolean[] useFile = new boolean[ files.size() ];
	for ( int i = 0; i < files.size(); ++i )
		useFile[ i ] = true;
	
	if ( confirmFiles )
	{
		final GenericDialogPlus gd = new GenericDialogPlus( "Confirm files" );
		
		for ( final String name : files )
			gd.addCheckbox( name, true );
		
		gd.showDialog();
		
		if ( gd.wasCanceled() )
			return null;
		
		for ( int i = 0; i < files.size(); ++i )
			useFile[ i ] = gd.getNextBoolean();
	}

	final ArrayList< ImageCollectionElement > elements = new ArrayList< ImageCollectionElement >();

	for ( int i = 0; i < files.size(); ++i )
		if ( useFile [ i ] )
			elements.add( new ImageCollectionElement( new File( directory, files.get( i ) ), i ) );
	
	if ( elements.size() < 2 )
	{
		Log.error( "Only " + elements.size() + " files selected, you need at least 2 - stop." );
		return null ;			
	}
	
	return elements;
}
 
Example 5
Source File: Stitch_Multiple_Series_File.java    From Stitching with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run(String arg0)
{
	GenericDialogPlus gd = new GenericDialogPlus( "Stitch Multiple Series File" );
	
	gd.addFileField( "File", fileNameStatic, 50 );		
	gd.addCheckbox( "Compute_overlap (or trust coordinates in the file)", computeOverlapStatic );
	gd.addCheckbox( "Ignore_Calibration", ignoreCalibrationStatic );
	gd.addSlider( "Increase_overlap [%]", 0, 100, overlapStatic );
	gd.addCheckbox( "Invert_X coordinates", invertXStatic );
	gd.addCheckbox( "Invert_Y coordinates", invertYStatic );
	gd.addCheckbox("Ignore_Z_stage position", ignoreZStageStatic);
	             
	gd.addChoice( "Fusion_Method", methodListCollection, fusionMethodStatic );
	gd.addNumericField( "Fusion alpha", alphaStatic, 2 );
	gd.addNumericField( "Regression Threshold", thresholdRStatic, 2 );
	gd.addNumericField( "Max/Avg Displacement Threshold", thresholdDisplacementRelativeStatic, 2 );		
	gd.addNumericField( "Absolute Avg Displacement Threshold", thresholdDisplacementAbsoluteStatic, 2 );		
	gd.addCheckbox("Create_only_preview", previewOnlyStatic);
	gd.addMessage( "" );
	gd.addMessage( "This Plugin is developed by Stephan Preibisch\n" + myURL );

	MultiLineLabel text = (MultiLineLabel) gd.getMessage();
	addHyperLinkListener(text, myURL);

	gd.showDialog();
	if (gd.wasCanceled()) 
		return;

	String fileName = gd.getNextString();
	fileNameStatic = fileName;

	boolean computeOverlap = gd.getNextBoolean();
	computeOverlapStatic = computeOverlap;

	boolean ignoreCalibration = gd.getNextBoolean();
	ignoreCalibrationStatic = ignoreCalibration;
	
	double overlap = gd.getNextNumber();
	overlapStatic = overlap;

	boolean invertX = gd.getNextBoolean();
	invertXStatic = invertX;

	boolean invertY = gd.getNextBoolean();
	invertYStatic = invertY;

	boolean ignoreZStage = gd.getNextBoolean();
	ignoreZStageStatic = ignoreZStage;

	String fusionMethod = gd.getNextChoice();
	fusionMethodStatic = fusionMethod;
	
	this.alpha = gd.getNextNumber();
	alphaStatic = alpha;
	
	this.thresholdR = gd.getNextNumber();
	thresholdRStatic = thresholdR;
	
	this.thresholdDisplacementRelative = gd.getNextNumber();
	thresholdDisplacementRelativeStatic = thresholdDisplacementRelative;
	
	this.thresholdDisplacementAbsolute = gd.getNextNumber();
	thresholdDisplacementAbsoluteStatic = thresholdDisplacementAbsolute;
	
	boolean previewOnly = gd.getNextBoolean();
	previewOnlyStatic = previewOnly;

	ArrayList<ImageInformation> imageInformationList = parseMultiSeriesFile( fileName, overlap,  ignoreCalibration, invertX, invertY, ignoreZStage );
	
	if ( imageInformationList == null )
		return;
	
	for ( ImageInformation iI : imageInformationList )
	{
		Log.info( iI.imageName );
		
		String offset = "";
		for ( int d = 0; d < iI.offset.length; ++d )
			offset += iI.offset[ d ] + ", ";
		
		Log.info( offset );
	}

	final GridLayout gridLayout = new GridLayout();

	gridLayout.imageInformationList = imageInformationList;
	gridLayout.fusionMethod = fusionMethod;
	gridLayout.alpha = this.alpha;
	gridLayout.thresholdR = this.thresholdR;
	gridLayout.thresholdDisplacementRelative = this.thresholdDisplacementRelative;
	gridLayout.thresholdDisplacementAbsolute = this.thresholdDisplacementAbsolute;
	gridLayout.dim = imageInformationList.get( 0 ).dim;
	gridLayout.rgbOrder = rgbTypes[0];

	new Stitch_Image_Collection().work( gridLayout, previewOnly, computeOverlap, fileName + ".txt", true );
}
 
Example 6
Source File: Stitch_Image_Collection.java    From Stitching with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run(String arg0)
{
	GenericDialogPlus gd = new GenericDialogPlus("Stitch Image Collection");
	
	//gd.addStringField("Layout file", fileNameStatic, 50);
	gd.addFileField("Layout file", fileNameStatic, 50);		
	gd.addCheckbox("compute_overlap (otherwise use the coordinates given in the layout file)", computeOverlapStatic );
	gd.addChoice("Channels_for_Registration", colorList, handleRGBStatic);
	gd.addChoice("rgb_order", rgbTypes, rgbOrderStatic);
	gd.addChoice("Fusion_Method", methodListCollection, methodListCollection[LIN_BLEND]);
	gd.addNumericField("Fusion alpha", alphaStatic, 2);
	gd.addNumericField("Regression Threshold", thresholdRStatic, 2);
	gd.addNumericField("Max/Avg Displacement Threshold", thresholdDisplacementRelativeStatic, 2);		
	gd.addNumericField("Absolute Avg Displacement Threshold", thresholdDisplacementAbsoluteStatic, 2);		
	gd.addCheckbox("Create_only_Preview", previewOnlyStatic);
	gd.addMessage("");
	gd.addMessage("This Plugin is developed by Stephan Preibisch\n" + myURL);

	MultiLineLabel text = (MultiLineLabel) gd.getMessage();
	addHyperLinkListener(text, myURL);

	gd.showDialog();
	if (gd.wasCanceled()) return;

	String fileName = gd.getNextString();
	fileNameStatic = fileName;

	boolean computeOverlap = gd.getNextBoolean();
	computeOverlapStatic = computeOverlap;

	String handleRGB = gd.getNextChoice();
	handleRGBStatic = handleRGB;
	
	this.rgbOrder = gd.getNextChoice();
	rgbOrderStatic = rgbOrder;
	
	String fusionMethod = gd.getNextChoice();
	fusionMethodStatic = fusionMethod;
	
	this.alpha = gd.getNextNumber();
	alphaStatic = alpha;
	
	this.thresholdR = gd.getNextNumber();
	thresholdRStatic = thresholdR;
	
	this.thresholdDisplacementRelative = gd.getNextNumber();
	thresholdDisplacementRelativeStatic = thresholdDisplacementRelative;
	
	this.thresholdDisplacementAbsolute = gd.getNextNumber();
	thresholdDisplacementAbsoluteStatic = thresholdDisplacementAbsolute;
	
	boolean previewOnly = gd.getNextBoolean();
	previewOnlyStatic = previewOnly;
	
	work(fileName, previewOnly, computeOverlap, fusionMethod, handleRGB, true);		
}
 
Example 7
Source File: Stitch_Many_Images.java    From Stitching with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Manages the dialog for stitching a collection of images defined by a Tileconfiguration file
 */
public void stitchCollection()
{
	final GenericDialogPlus gd = new GenericDialogPlus("Stitch Image Collection");
	
	//gd.addStringField("Layout file", fileNameStatic, 50);
	gd.addFileField( "Layout file", fileNameStatic, 50 );		
	gd.addCheckbox( "compute_overlap (otherwise use the coordinates given in the layout file)", computeOverlapStatic );
	gd.addChoice( "Channels_for_Registration", colorList, handleRGBStatic );
	gd.addChoice( "rgb_order", rgbTypes, rgbOrderStatic );
	gd.addChoice( "Fusion_Method", methodListCollection, methodListCollection[LIN_BLEND] );
	gd.addNumericField( "Fusion alpha", alphaStatic, 2 );
	gd.addNumericField( "Regression Threshold", thresholdRStatic, 2 );
	gd.addNumericField( "Max/Avg Displacement Threshold", thresholdDisplacementRelativeStatic, 2 );		
	gd.addNumericField( "Absolute Avg Displacement Threshold", thresholdDisplacementAbsoluteStatic, 2 );		
	gd.addCheckbox( "Create_only_Preview", previewOnlyStatic );
	gd.addMessage( "");
	gd.addMessage( "This Plugin is developed by Stephan Preibisch\n" + myURL );

	MultiLineLabel text = (MultiLineLabel) gd.getMessage();
	addHyperLinkListener(text, myURL);

	gd.showDialog();
	if (gd.wasCanceled()) return;

	String fileName = gd.getNextString();
	fileNameStatic = fileName;

	boolean computeOverlap = gd.getNextBoolean();
	computeOverlapStatic = computeOverlap;

	String handleRGB = gd.getNextChoice();
	handleRGBStatic = handleRGB;
	
	String rgbOrder = gd.getNextChoice();
	rgbOrderStatic = rgbOrder;
	
	String fusionMethod = gd.getNextChoice();
	fusionMethodStatic = fusionMethod;
	
	double alpha = gd.getNextNumber();
	alphaStatic = alpha;
	
	double thresholdR = gd.getNextNumber();
	thresholdRStatic = thresholdR;
	
	double thresholdDisplacementRelative = gd.getNextNumber();
	thresholdDisplacementRelativeStatic = thresholdDisplacementRelative;
	
	double thresholdDisplacementAbsolute = gd.getNextNumber();
	thresholdDisplacementAbsoluteStatic = thresholdDisplacementAbsolute;
	
	boolean previewOnly = gd.getNextBoolean();
	previewOnlyStatic = previewOnly;	
	
	runStitching();
}
 
Example 8
Source File: Downsampler.java    From Stitching with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Displays a dialog to harvest user input, allowing scaling from a
 * specified image width and height.
 * 
 * @param imgWidth Base image width
 * @param imgHeight Base image height
 */
public void getInput(int imgWidth, int imgHeight) {
	originalWidth = imgWidth;
	originalHeight = imgHeight;
	final GenericDialogPlus gdDownSample = new GenericDialogPlus("Downsample");
	String[] methods = ImageProcessor.getInterpolationMethods();

	gdDownSample.addNumericField("x scale", 1, 1);
	gdDownSample.addNumericField("y scale", 1, 1);
	gdDownSample.addNumericField("width (pixels)", imgWidth, 0);
	gdDownSample.addNumericField("height (pixels)", imgHeight, 0);
	gdDownSample.addChoice("Interpolation:", methods,
		methods[methods.length - 1]);
	gdDownSample.addCheckbox("Average when downsizing", true);
	Vector<?> fields = gdDownSample.getNumericFields();
	xField = (TextComponent) fields.get(0);
	yField = (TextComponent) fields.get(1);
	widthField = (TextComponent) fields.get(2);
	heightField = (TextComponent) fields.get(3);

	xField.addTextListener(textListener);
	xField.addFocusListener(focusListener);
	yField.addTextListener(textListener);
	yField.addFocusListener(focusListener);
	widthField.addTextListener(textListener);
	widthField.addFocusListener(focusListener);
	heightField.addTextListener(textListener);
	heightField.addFocusListener(focusListener);
	gdDownSample.showDialog();

	if (gdDownSample.wasOKed()) {
		xScale = gdDownSample.getNextNumber();
		yScale = gdDownSample.getNextNumber();
		double width = gdDownSample.getNextNumber();
		double height = gdDownSample.getNextNumber();
		String method = gdDownSample.getNextChoice();
		String average = gdDownSample.getNextBoolean() ? " average" : "";
		params =
			"width=" + width + " height=" +
				height + average + " interpolation=" + method;
	}
}
 
Example 9
Source File: Stitch_Image_Grid.java    From Stitching with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run(String arg0)
{
	GenericDialogPlus gd = new GenericDialogPlus("Stitch Image Grid");
	GridLayout gridLayout = new GridLayout();
	
	gd.addNumericField("grid_size_x", gridSizeXStatic, 0);
	gd.addNumericField("grid_size_y", gridSizeYStatic, 0);
	//gd.addChoice("order_of_storage", arrangement, arrangmentStatic );
	
	gd.addSlider("overlap [%]", 0, 100, overlapStatic);
	gd.addDirectoryField("directory", directoryStatic, 50);
	gd.addStringField("file_names", fileNamesStatic, 50);
	gd.addChoice("rgb_order", rgbTypes, rgbOrderStatic);
	gd.addStringField("Output_file_name", tileConfStatic, 50);
	gd.addCheckbox("Save_Only_Tile_Configuration", writeOnlyTileConfStatic);
	gd.addNumericField("start_x", startXStatic, 0);
	gd.addNumericField("start_y", startYStatic, 0);
	gd.addNumericField("start_i", startIStatic, 0);
	gd.addChoice("channels_for_registration", colorList, handleRGBStatic);
	gd.addChoice("fusion_method", methodListCollection, fusionMethodStatic);
	gd.addNumericField("fusion_alpha", alphaStatic, 2);
	gd.addNumericField("regression_threshold", thresholdRStatic, 2);
	gd.addNumericField("max/avg_displacement_threshold", thresholdDisplacementRelativeStatic, 2);		
	gd.addNumericField("absolute_displacement_threshold", thresholdDisplacementAbsoluteStatic, 2);		
	gd.addCheckbox("create_only_preview", previewOnlyStatic);
	gd.addCheckbox("compute_overlap (otherwise use the coordinates given in the layout file)", computeOverlapStatic );
	gd.addMessage("");
	gd.addMessage("This Plugin is developed by Stephan Preibisch\n" + myURL);

	MultiLineLabel text = (MultiLineLabel) gd.getMessage();
	addHyperLinkListener(text, myURL);

	gd.showDialog();
	if (gd.wasCanceled()) return;
	
	gridLayout.sizeX = (int)Math.round(gd.getNextNumber());
	gridLayout.sizeY = (int)Math.round(gd.getNextNumber());
	gridSizeXStatic = gridLayout.sizeX;
	gridSizeYStatic = gridLayout.sizeY;

	//gridLayout.arrangement = gd.getNextChoice();
	//arrangmentStatic = gridLayout.arrangement;
	
	double overlap = gd.getNextNumber()/100;
	overlapStatic = overlap*100;
	
	String directory = gd.getNextString();
	directoryStatic = directory;
	
	String filenames = gd.getNextString();
	fileNamesStatic = filenames;
	
	gridLayout.rgbOrder = gd.getNextChoice();
	rgbOrderStatic = gridLayout.rgbOrder;
	
	String output = gd.getNextString();
	tileConfStatic = output;
	
	boolean writeOnlyOutput = gd.getNextBoolean();
	writeOnlyTileConfStatic = writeOnlyOutput;
	
	int startX = (int)Math.round(gd.getNextNumber());
	startXStatic = startX;
	
	int startY = (int)Math.round(gd.getNextNumber());
	startYStatic = startY;
	
	int startI = (int)Math.round(gd.getNextNumber());
	startIStatic = startI;
	
	String handleRGB = gd.getNextChoice();
	handleRGBStatic = handleRGB;
	
	String fusionMethod = gd.getNextChoice();
	fusionMethodStatic = fusionMethod;
	
	gridLayout.alpha = gd.getNextNumber();
	alphaStatic = gridLayout.alpha;
	
	gridLayout.thresholdR = gd.getNextNumber();
	thresholdRStatic = gridLayout.thresholdR;
	
	gridLayout.thresholdDisplacementRelative = gd.getNextNumber();
	thresholdDisplacementRelativeStatic = gridLayout.thresholdDisplacementRelative;
	
	gridLayout.thresholdDisplacementAbsolute = gd.getNextNumber();
	thresholdDisplacementAbsoluteStatic = gridLayout.thresholdDisplacementAbsolute;
	
	boolean previewOnly = gd.getNextBoolean();
	previewOnlyStatic = previewOnly;
	
	boolean computeOverlap = gd.getNextBoolean();
	computeOverlapStatic = computeOverlap;
	
	stitchImageGrid(filenames, directory, gridLayout, handleRGB, 
			fusionMethod, output, overlap, startX, startY, startI, 
			writeOnlyOutput, previewOnly, computeOverlap);

}