File: WandToolOptions.java

package info (click to toggle)
imagej 1.46a-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,248 kB
  • sloc: java: 89,778; sh: 311; xml: 51; makefile: 6
file content (45 lines) | stat: -rw-r--r-- 1,202 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package ij.plugin;
import ij.*;
import ij.gui.*;
import ij.process.*;
import ij.io.*;
import ij.plugin.filter.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Vector;

/** This plugin implements the Edit/Options/Wand Tool command. */
public class WandToolOptions implements PlugIn {
	private static final String[] modes = {"Legacy", "4-connected", "8-connected"};
	private static String mode = modes[0];
	private static double tolerance;

 	public void run(String arg) {
 		ImagePlus imp = WindowManager.getCurrentImage();
 		boolean showCheckbox = imp!=null && imp.getBitDepth()!=24 && WindowManager.getFrame("Threshold")==null;
		GenericDialog gd = new GenericDialog("Wand Tool");
		gd.addChoice("Mode: ", modes, mode);
		gd.addNumericField("Tolerance: ", tolerance, 1);
		if (showCheckbox)
			gd.addCheckbox("Enable Thresholding", false);
		gd.showDialog();
		if (gd.wasCanceled()) return;
		mode = gd.getNextChoice();
		tolerance = gd.getNextNumber();
		if (showCheckbox) {
			if (gd.getNextBoolean()) {
				imp.killRoi();
				IJ.run("Threshold...");
			}
		}
	}
	
	public static String getMode() {
		return mode;
	}

	public static double getTolerance() {
		return tolerance;
	}

}