ij.gui.NonBlockingGenericDialog Java Examples

The following examples show how to use ij.gui.NonBlockingGenericDialog. 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: SnippetCreator.java    From Scripts with GNU General Public License v3.0 6 votes vote down vote up
private boolean showDialog() {
	gd = new NonBlockingGenericDialog("New Snippet");
	addButtons(gd);
	gd.setInsets(0, 0, 0);
	gd.addTextAreas(sContents, null, 20, 80);
	ta = gd.getTextArea1();
	ta.setFont(new Font("Monospaced", Font.PLAIN, 12));
	gd.addStringField("Filename:", sFilename, 16);
	gd.addChoice("Language:", S_TYPES, S_TYPES[sType]);
	gd.setInsets(-85, 245, 0);
	gd.addMessage(" \n "); // placeholder for info messages
	gd.addHelp(Utils.getDocURL());
	gd.setHelpLabel("Online Help");
	gd.setOKLabel("  Create and Open  ");
	gd.addDialogListener(this);
	gd.showDialog();

	sContents = gd.getNextText();
	return !gd.wasCanceled();
}
 
Example #2
Source File: InteractiveMorphologicalReconstruction.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
public int showDialog(
		ImagePlus imp,
		String command,
		final PlugInFilterRunner pfr )
{
	// Store user data
	this.imagePlus = imp;
	this.baseImage = imp.getProcessor().duplicate();
	this.pfr = pfr;

	/** ROI listener to update plugin when new ROIs are added */
	this.listener = new RoiListener() {
		@Override
		public void roiModified(ImagePlus imp, int id) {

			if( imp == imagePlus )
			{
				// set preview to false to restart plugin filter runner
				gd.getPreviewCheckbox().setState( false );

				pfr.dialogItemChanged( gd,
						new ActionEvent( gd.getPreviewCheckbox(),
								ActionEvent.ACTION_PERFORMED, "Preview" ) );
			}
		}
	};
	Roi.addRoiListener( listener );

	// select point tool for manual introduction of markers
	Toolbar.getInstance().setTool( Toolbar.POINT );

	// create the dialog
	gd = new NonBlockingGenericDialog( "Interactive Morphological "
			+ "Reconstruction");

	gd.addChoice("Type of Reconstruction",
			Operation.getAllLabels(),
			operation.label );
	gd.addChoice("Connectivity",
			Conn2D.getAllLabels(),
			connectivity.label );
	gd.addPreviewCheckbox( pfr );
	gd.addDialogListener(this);
	previewing = true;
	gd.addHelp( "http://imagej.net/MorphoLibJ" );
	gd.showDialog();
	previewing = false;

	if (gd.wasCanceled())
		return DONE;

	// set up current parameters
	operation = Operation.fromLabel(gd.getNextChoice());
	connectivity = Conn2D.fromLabel(gd.getNextChoice());

	return flags;
}
 
Example #3
Source File: InteractiveGeodesicDistanceMap.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
public int showDialog(
		ImagePlus imp,
		String command,
		final PlugInFilterRunner pfr )
{
	if( !BinaryImages.isBinaryImage( imp ) )
	{
		IJ.error( "Interactive Geodesic Distance Map", "Input image is not"
				+ " binary (8-bit with only 0 or 255 values)" );
		return DONE;
	}

	// Store user data
	this.imagePlus = imp;
	this.baseImage = imp.getProcessor().duplicate();
	this.pfr = pfr;

	/** ROI listener to update plugin when new ROIs are added */
	this.listener = new RoiListener() {
		@Override
		public void roiModified( ImagePlus imp, int id ) {

			if( imp == imagePlus )
			{
				// set preview to false to restart plugin filter runner
				gd.getPreviewCheckbox().setState( false );

				pfr.dialogItemChanged( gd,
						new ActionEvent( gd.getPreviewCheckbox(),
								ActionEvent.ACTION_PERFORMED, "Preview" ) );
			}
		}
	};
	Roi.addRoiListener( listener );

	// select point tool for manual introduction of markers
	Toolbar.getInstance().setTool( Toolbar.POINT );

	// create the dialog
	gd = new NonBlockingGenericDialog( "Interactive Geodesic "
					+ "Distance Map" );
	// Set Chessknight weights as default
	gd.addChoice( "Distances", ChamferWeights.getAllLabels(),
			weights.toString() );
	String[] outputTypes = new String[] { "32 bits", "16 bits" };
	gd.addChoice( "Output Type", outputTypes,
			outputTypes[ resultAsFloat ? 0:1 ] );
	gd.addCheckbox( "Normalize weights", normalize );
	gd.addPreviewCheckbox( pfr );
	gd.addDialogListener(this);
	previewing = true;
	gd.addHelp( "http://imagej.net/MorphoLibJ#Utilities_for_binary_images" );
	gd.showDialog();
	previewing = false;

	if (gd.wasCanceled())
		return DONE;

	// identify which weights should be used
	weights = ChamferWeights.fromLabel(
			gd.getNextChoice());
	resultAsFloat = gd.getNextChoiceIndex() == 0;
	normalize = gd.getNextBoolean();

	return flags;
}
 
Example #4
Source File: InteractiveMorphologicalReconstruction3D.java    From MorphoLibJ with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Apply the current filter settings to process the given image.
 */
public void run( String arg )
{
	ImagePlus image = WindowManager.getCurrentImage();
	if ( image == null || image.getImageStackSize() < 2 )
	{
		IJ.error( "Interactive Geodesic Reconstruction 3D",
				"Need at least one 3D image to work" );
		return;
	}

	// select point tool for manual introduction of markers
	Toolbar.getInstance().setTool( Toolbar.POINT );

	// create the dialog
	gd = new NonBlockingGenericDialog( "Interactive Geodesic "
			+ "Reconstruction 3D" );

	gd.addChoice("Type of Reconstruction",
			Operation.getAllLabels(),
			operation.label);
	gd.addChoice("Connectivity",
			Conn3D.getAllLabels(),
			connectivity.label);
	gd.addHelp( "http://imagej.net/MorphoLibJ" );
	gd.showDialog();

	if (gd.wasCanceled())
		return;

	// set up current parameters
	operation = Operation.fromLabel( gd.getNextChoice() );
	connectivity = Conn3D.fromLabel( gd.getNextChoice() );

	long t0 = System.currentTimeMillis();

	// Compute geodesic reconstruction
	final ImagePlus result = process( image, image.getRoi() );

	if( null == result )
		return;

	if (result.getBitDepth() != 24)
	{
		Images3D.optimizeDisplayRange( result );
	}
	
	// Display the result image
	result.setSlice( image.getCurrentSlice() );
	result.show();

	long t1 = System.currentTimeMillis();
	IJUtils.showElapsedTime( operation.toString(), t1 - t0, image );
}