Java Code Examples for ij.gui.GenericDialog#addCheckboxGroup()

The following examples show how to use ij.gui.GenericDialog#addCheckboxGroup() . 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: Graph.java    From TrakEM2 with GNU General Public License v3.0 6 votes vote down vote up
/** Shows a dialog to pick which classes is one interested in. */
static public final void extractAndShowGraph(final LayerSet ls) {
	GenericDialog gd = new GenericDialog("Graph elements");
	Class<Displayable>[] c = new Class[]{AreaList.class, AreaTree.class, Ball.class, Connector.class, Patch.class, Pipe.class, Polyline.class, Profile.class, DLabel.class, Treeline.class};
	String[] types = new String[]{"AreaList", "AreaTree", "Ball", "Connector", "Image", "Pipe", "Polyline", "Profile", "Text", "Treeline"};
	boolean[] states = new boolean[]{true, true, false, false, false, false, true, true, false, true};
	assert(c.length == types.length && types.length == states.length);
	for (int i=0; i<c.length; i++) {
		if (ZDisplayable.class.isAssignableFrom(c[i])) {
			if (!ls.contains(c[i])) states[i] = false;
		} else if (!ls.containsDisplayable(c[i])) states[i] = false;
	}
	gd.addCheckboxGroup(types.length, 1, types, states, new String[]{"Include only:"});
	gd.showDialog();
	if (gd.wasCanceled()) return;
	HashSet<Class<Displayable>> only = new HashSet<Class<Displayable>>();
	for (int i=0; i<types.length; i++) {
		if (gd.getNextBoolean()) only.add(c[i]);
	}
	Graph.extractAndShowGraph(ls, only);
}
 
Example 2
Source File: SkeletonPlugin.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
private boolean showDialog() {

		gd = new GenericDialog("Render Paths as Topographic Skeletons");
		final String[] pwScopes = { "Render all paths", "Render only selected paths" };
		gd.addRadioButtonGroup("Path selection:", pwScopes, 2, 1, pwScopes[useOnlySelectedPaths ? 1 : 0]);
		final String[] roiScopes = { "None", "Render only segments contained by ROI" };
		gd.addRadioButtonGroup("ROI filtering:", roiScopes, 2, 1, roiScopes[restrictByRoi ? 1 : 0]);

		// Assemble SWC choices
		final ArrayList<String> swcTypeNames = Path.getSWCtypeNames();
		final int nTypes = swcTypeNames.size();
		final String[] typeNames = swcTypeNames.toArray(new String[nTypes]);
		final boolean[] typeChoices = new boolean[nTypes];
		for (int i = 0; i < nTypes; i++)
			typeChoices[i] = typeNames[i].contains("dendrite");
		final String[] swcScopes = { "None", "Include only the following SWC types:" };
		gd.addRadioButtonGroup("SWC filtering:", swcScopes, 2, 1, swcScopes[restrictBySWCType ? 1 : 0]);
		gd.setInsets(0, 40, 0);
		gd.addCheckboxGroup(nTypes / 2, 2, typeNames, typeChoices);

		final String[] analysisScopes = { "None", "Obtain summary", "Run \"Analyze Skeleton\" plugin" };
		gd.addRadioButtonGroup("Analysis of rendered paths:", analysisScopes, 3, 1, analysisScopes[0]);
		gd.addDialogListener(this);
		dialogItemChanged(gd, null);
		gd.showDialog();
		if (gd.wasCanceled())
			return false;
		else if (gd.wasOKed()) {
			return dialogItemChanged(gd, null);
		}
		return false;

	}
 
Example 3
Source File: SNTPrefs.java    From SNT with GNU General Public License v3.0 4 votes vote down vote up
protected void promptForOptions() {

		final int startupOptions = 7;
		final int pluginOptions = 2;

		final String[] startupLabels = new String[startupOptions];
		final int[] startupItems = new int[startupOptions];
		final boolean[] startupStates = new boolean[startupOptions];
		int idx = 0;

		startupItems[idx] = ENFORCE_LUT;
		startupLabels[idx] = "Enforce non-inverted grayscale LUT";
		startupStates[idx++] = snt.forceGrayscale;

		startupItems[idx] = USE_THREE_PANE;
		startupLabels[idx] = "Use_three-pane view";
		startupStates[idx++] = !snt.getSinglePane();

		startupItems[idx] = USE_3D_VIEWER;
		startupLabels[idx] = "Use_3D Viewer";
		startupStates[idx++] = snt.use3DViewer;

		startupItems[idx] = LOOK_FOR_TUBES;
		startupLabels[idx] = "Load_Tubeness \".tubes.tif\" pre-processed file (if present)";
		startupStates[idx++] = snt.look4tubesFile;

		startupItems[idx] = LOOK_FOR_OOF;
		startupLabels[idx] = "Load_Tubular_Geodesics \".oof.ext\" pre-processed file (if present)";
		startupStates[idx++] = snt.look4oofFile;

		startupItems[idx] = LOOK_FOR_TRACES;
		startupLabels[idx] = "Load_default \".traces\" file (if present)";
		startupStates[idx++] = snt.look4tracesFile;

		startupItems[idx] = STORE_WIN_LOCATIONS;
		startupLabels[idx] = "Remember window locations across restarts";
		startupStates[idx++] = isSaveWinLocations();

		final String[] pluginLabels = new String[pluginOptions];
		final int[] pluginItems = new int[pluginOptions];
		final boolean[] pluginStates = new boolean[pluginOptions];
		idx = 0;

		pluginItems[idx] = COMPRESSED_XML;
		pluginLabels[idx] = "Use compression when saving traces";
		pluginStates[idx++] = snt.useCompressedXML;

		pluginItems[idx] = DEBUG;
		pluginLabels[idx] = "Enable_debug mode";
		pluginStates[idx++] = SimpleNeuriteTracer.verbose;

		final GenericDialog gd = new GenericDialog("SNT v" + SNT.VERSION + " Preferences");
		final Font font = new Font("SansSerif", Font.BOLD, 12);
		gd.setInsets(0, 0, 0);
		gd.addMessage("Startup Options:", font);
		gd.setInsets(0, 0, 0);
		gd.addCheckboxGroup(startupOptions, 1, startupLabels, startupStates);
		gd.setInsets(20, 0, 0);
		gd.addMessage("Advanced Options:", font);
		gd.setInsets(0, 0, 0);
		gd.addCheckboxGroup(pluginOptions, 1, pluginLabels, pluginStates);

		gd.enableYesNoCancel("OK", "Revert to Defaults");
		gd.showDialog();
		if (gd.wasCanceled()) {
			return;
		} else if (gd.wasOKed()) {

			for (int i = 0; i < startupOptions; i++) {
				if (gd.getNextBoolean())
					currentBooleans |= startupItems[i];
				else
					currentBooleans &= ~startupItems[i];
			}
			for (int i = 0; i < pluginOptions; i++) {
				if (gd.getNextBoolean())
					currentBooleans |= pluginItems[i];
				else
					currentBooleans &= ~pluginItems[i];
			}
			Prefs.set(BOOLEANS, currentBooleans);

		} else {
			resetOptions();
		}

		Prefs.savePreferences();
		loadPluginPrefs();

	}