use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class FIRE method showInputDialog.
private boolean showInputDialog() {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addMessage("Compute the resolution using Fourier Ring Correlation");
gd.addHelp(About.HELP_URL);
// Build a list of all images with a region ROI
List<String> titles = new LinkedList<String>();
if (WindowManager.getWindowCount() > 0) {
for (int imageID : WindowManager.getIDList()) {
ImagePlus imp = WindowManager.getImage(imageID);
if (imp != null && imp.getRoi() != null && imp.getRoi().isArea())
titles.add(imp.getTitle());
}
}
ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
ResultsManager.addInput(gd, "Input2", inputOption2, InputSource.NONE, InputSource.MEMORY);
if (!titles.isEmpty())
gd.addCheckbox((titles.size() == 1) ? "Use_ROI" : "Choose_ROI", chooseRoi);
gd.showDialog();
if (gd.wasCanceled())
return false;
inputOption = ResultsManager.getInputSource(gd);
inputOption2 = ResultsManager.getInputSource(gd);
if (!titles.isEmpty())
chooseRoi = gd.getNextBoolean();
if (!titles.isEmpty() && chooseRoi) {
if (titles.size() == 1) {
roiImage = titles.get(0);
Recorder.recordOption("Image", roiImage);
} else {
String[] items = titles.toArray(new String[titles.size()]);
gd = new ExtendedGenericDialog(TITLE);
gd.addMessage("Select the source image for the ROI");
gd.addChoice("Image", items, roiImage);
gd.showDialog();
if (gd.wasCanceled())
return false;
roiImage = gd.getNextChoice();
}
ImagePlus imp = WindowManager.getImage(roiImage);
roiBounds = imp.getRoi().getBounds();
roiImageWidth = imp.getWidth();
roiImageHeight = imp.getHeight();
} else {
roiBounds = null;
}
return true;
}
use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class FilterResults method run.
/*
* (non-Javadoc)
*
* @see ij.plugin.PlugIn#run(java.lang.String)
*/
public void run(String arg) {
SMLMUsageTracker.recordPlugin(this.getClass(), arg);
if (MemoryPeakResults.isMemoryEmpty()) {
IJ.error(TITLE, "There are no fitting results in memory");
return;
}
// Show a dialog allowing the results set to be filtered
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addMessage("Select a dataset to filter");
ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
gd.showDialog();
if (gd.wasCanceled())
return;
inputOption = ResultsManager.getInputSource(gd);
results = ResultsManager.loadInputResults(inputOption, false);
if (results == null || results.size() == 0) {
IJ.error(TITLE, "No results could be loaded");
IJ.showStatus("");
return;
}
analyseResults();
if (!showDialog())
return;
filterResults();
}
use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class Test_Plugin method run.
/*
* (non-Javadoc)
*
* @see ij.plugin.PlugIn#run(java.lang.String)
*/
@Override
public void run(String arg) {
// The parameters that have options must be available statically for the OptionListener
final String[] textFields = { "Some text", "More text" };
final String[] optionFields = { "", "", "" };
ExtendedGenericDialog gd = new ExtendedGenericDialog("Test");
gd.addChoice("Select1", new String[] { "One", "Two" }, optionFields[0]);
final Choice c2 = gd.addAndGetChoice("Select2", new String[] { "Three", "Four" }, optionFields[1]);
gd.addAndGetButton("Options", new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// This makes it model
ExtendedGenericDialog gd2 = new ExtendedGenericDialog("Test2", null);
gd2.addMessage(c2.getSelectedItem());
gd2.showDialog(true);
gd2.getNextChoice();
}
});
gd.addStringField("Another", textFields[0]);
gd.addStringField("Testing", textFields[1], 15, new OptionListener<TextField>() {
@Override
public void collectOptions(TextField field) {
IJ.log(field.getText());
}
@Override
public void collectOptions() {
IJ.log(textFields[1]);
}
});
gd.addFilenameField("File", "", 30);
gd.addDirectoryField("Dir", "", 30);
gd.addChoice("Select3", new String[] { "Five", "Six" }, optionFields[2], new OptionListener<Choice>() {
@Override
public void collectOptions(Choice field) {
IJ.log(field.getSelectedItem());
}
@Override
public void collectOptions() {
IJ.log(optionFields[2]);
}
});
gd.showDialog();
optionFields[0] = gd.getNextChoice();
optionFields[1] = gd.getNextChoice();
textFields[0] = gd.getNextString();
textFields[1] = gd.getNextString();
optionFields[2] = gd.getNextChoice();
gd.collectOptions();
}
use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class CropResults method showDialog.
private boolean showDialog() {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(About.HELP_URL);
// TODO - add option to crop using the bounding rectangle of an ROI on an open image.
// See PC-PALM Molecules.
// Build a list of all images with a region ROI
TurboList<String> titles = new TurboList<String>(WindowManager.getWindowCount());
if (WindowManager.getWindowCount() > 0) {
for (int imageID : WindowManager.getIDList()) {
ImagePlus imp = WindowManager.getImage(imageID);
if (imp != null && imp.getRoi() != null && imp.getRoi().isArea())
titles.add(imp.getTitle());
}
}
Rectangle bounds = results.getBounds(true);
gd.addMessage(String.format("x=%d,y=%d,w=%d,h=%d", bounds.x, bounds.y, bounds.width, bounds.height));
gd.addNumericField("Border", border, 2);
gd.addCheckbox("Select_region", selectRegion);
gd.addNumericField("X", x, 2);
gd.addNumericField("Y", y, 2);
gd.addNumericField("Width", width, 2);
gd.addNumericField("Height", height, 2);
if (!titles.isEmpty()) {
gd.addCheckbox("Use_ROI", useRoi);
String[] items = titles.toArray(new String[titles.size()]);
gd.addChoice("Image", items, roiImage);
}
gd.addCheckbox("Overwrite", overwrite);
gd.showDialog();
if (gd.wasCanceled())
return false;
border = Math.max(0, gd.getNextNumber());
selectRegion = gd.getNextBoolean();
x = gd.getNextNumber();
y = gd.getNextNumber();
width = Math.max(0, gd.getNextNumber());
height = Math.max(0, gd.getNextNumber());
if (!titles.isEmpty()) {
myUseRoi = useRoi = gd.getNextBoolean();
roiImage = gd.getNextChoice();
}
overwrite = gd.getNextBoolean();
return true;
}
use of ij.gui.ExtendedGenericDialog in project GDSC-SMLM by aherbert.
the class DarkTimeAnalysis method showDialog.
private boolean showDialog() {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(About.HELP_URL);
gd.addMessage("Compute the cumulative dark-time histogram");
ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
gd.addChoice("Method", METHOD, METHOD[method]);
gd.addSlider("Search_distance (nm)", 5, 150, searchDistance);
gd.addNumericField("Max_dark_time (seconds)", maxDarkTime, 2);
gd.addSlider("Percentile", 0, 100, percentile);
gd.addSlider("Histogram_bins", -1, 100, nBins);
gd.showDialog();
if (gd.wasCanceled())
return false;
inputOption = gd.getNextChoice();
method = gd.getNextChoiceIndex();
searchDistance = gd.getNextNumber();
maxDarkTime = gd.getNextNumber();
percentile = gd.getNextNumber();
nBins = (int) gd.getNextNumber();
// Check arguments
try {
Parameters.isAboveZero("Search distance", searchDistance);
Parameters.isPositive("Percentile", percentile);
} catch (IllegalArgumentException e) {
IJ.error(TITLE, e.getMessage());
return false;
}
return true;
}
Aggregations