use of java.awt.Checkbox in project GDSC-SMLM by aherbert.
the class BatchPeakFit method showDialog.
/**
* Ask for parameters
*
* @return True if not cancelled
*/
private boolean showDialog() {
GenericDialog gd = new GenericDialog(TITLE);
gd.addHelp(About.HELP_URL);
gd.addStringField("Config_filename", configFilename);
gd.addCheckbox("Create_config_file", false);
if (Utils.isShowGenericDialog()) {
configFilenameText = (TextField) gd.getStringFields().get(0);
configFilenameText.setColumns(30);
configFilenameText.addMouseListener(this);
Checkbox cb = (Checkbox) gd.getCheckboxes().get(0);
cb.addItemListener(this);
}
gd.showDialog();
if (gd.wasCanceled())
return false;
configFilename = gd.getNextString().trim();
return true;
}
use of java.awt.Checkbox in project GDSC-SMLM by aherbert.
the class BatchPeakFit method itemStateChanged.
/*
* (non-Javadoc)
*
* @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
*/
public void itemStateChanged(ItemEvent e) {
// When the checkbox is clicked, create a default configuration file and update the
// GenericDialog with the file location.
Checkbox cb = (Checkbox) e.getSource();
if (cb.getState()) {
cb.setState(false);
Document doc = getDefaultSettingsXmlDocument();
if (doc == null)
return;
try {
// Look for nodes that are part of the fit configuration
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
XPathExpression expr = xpath.compile("//gdsc.smlm.engine.FitEngineConfiguration//*");
// For each node, add the name and value to the BatchParameters
BatchSettings batchSettings = new BatchSettings();
batchSettings.resultsDirectory = System.getProperty("java.io.tmpdir");
batchSettings.images.add("/path/to/image.tif");
Object result = expr.evaluate(doc, XPathConstants.NODESET);
NodeList nodes = (NodeList) result;
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (// Only nodes with a single text entry
node.getChildNodes().getLength() == 1) {
batchSettings.parameters.add(new ParameterSettings(node.getNodeName(), node.getTextContent()));
}
}
// Save the settings file
String[] path = Utils.decodePath(configFilenameText.getText());
OpenDialog chooser = new OpenDialog("Settings_file", path[0], path[1]);
if (chooser.getFileName() != null) {
String newFilename = chooser.getDirectory() + chooser.getFileName();
if (!newFilename.endsWith(".xml"))
newFilename += ".xml";
FileOutputStream fs = null;
try {
fs = new FileOutputStream(newFilename);
xs.toXML(batchSettings, fs);
} finally {
if (fs != null) {
fs.close();
}
}
// Update dialog filename
configFilenameText.setText(newFilename);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
use of java.awt.Checkbox in project GDSC-SMLM by aherbert.
the class BenchmarkFilterAnalysis method showScoreDialog.
private boolean showScoreDialog() {
GenericDialog gd = new GenericDialog(TITLE);
gd.addHelp(About.HELP_URL);
addSimulationData(gd);
// Get the last scored filter or default to the best filter
getScoreFilter();
gd.addSlider("Fail_count", 0, 20, scoreFailCount);
if (BenchmarkSpotFit.computeDoublets)
gd.addSlider("Residuals_threshold", 0.01, 1, scoreResidualsThreshold);
gd.addNumericField("Duplicate_distance", scoreDuplicateDistance, 2);
gd.addTextAreas(XmlUtils.convertQuotes(scoreFilter.toXML()), null, 6, 60);
gd.addCheckbox("Reset_filter", false);
//gd.addCheckbox("Show_table", showResultsTable);
gd.addCheckbox("Show_summary", showSummaryTable);
gd.addCheckbox("Clear_tables", clearTables);
//gd.addSlider("Summary_top_n", 0, 20, summaryTopN);
gd.addCheckbox("Save_best_filter", saveBestFilter);
gd.addCheckbox("Save_template", saveTemplate);
gd.addCheckbox("Calculate_sensitivity", calculateSensitivity);
gd.addSlider("Delta", 0.01, 1, delta);
if (!simulationParameters.fixedDepth)
gd.addCheckbox("Depth_recall_analysis", depthRecallAnalysis);
gd.addCheckbox("Score_analysis", scoreAnalysis);
gd.addChoice("Component_analysis", COMPONENT_ANALYSIS, COMPONENT_ANALYSIS[componentAnalysis]);
gd.addStringField("Title", resultsTitle, 20);
String[] labels = { "Show_TP", "Show_FP", "Show_FN" };
gd.addCheckboxGroup(1, 3, labels, new boolean[] { showTP, showFP, showFN });
// Dialog to have a reset checkbox. This reverts back to the default.
if (Utils.isShowGenericDialog()) {
final Checkbox cb = (Checkbox) (gd.getCheckboxes().get(0));
@SuppressWarnings("unchecked") final Vector<TextField> v = gd.getNumericFields();
final TextArea ta = gd.getTextArea1();
cb.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (cb.getState()) {
scoreFilter = null;
getScoreFilter();
int i = 0;
v.get(i++).setText(Integer.toString(scoreFailCount));
if (BenchmarkSpotFit.computeDoublets)
v.get(i++).setText(Double.toString(scoreResidualsThreshold));
v.get(i++).setText(Double.toString(scoreDuplicateDistance));
ta.setText(XmlUtils.convertQuotes(scoreFilter.toXML()));
}
}
});
}
gd.showDialog();
if (gd.wasCanceled())
return false;
scoreFailCount = (int) Math.abs(gd.getNextNumber());
if (BenchmarkSpotFit.computeDoublets)
scoreResidualsThreshold = Math.abs(gd.getNextNumber());
scoreDuplicateDistance = Math.abs(gd.getNextNumber());
String xml = gd.getNextText();
try {
scoreFilter = (DirectFilter) DirectFilter.fromXML(xml);
} catch (Exception e) {
scoreFilter = null;
getScoreFilter();
}
boolean reset = gd.getNextBoolean();
if (reset) {
scoreFilter = null;
getScoreFilter();
}
//showResultsTable = gd.getNextBoolean();
showSummaryTable = gd.getNextBoolean();
clearTables = gd.getNextBoolean();
//summaryTopN = (int) Math.abs(gd.getNextNumber());
saveBestFilter = gd.getNextBoolean();
saveTemplate = gd.getNextBoolean();
calculateSensitivity = gd.getNextBoolean();
delta = gd.getNextNumber();
if (!simulationParameters.fixedDepth)
depthRecallAnalysis = gd.getNextBoolean();
scoreAnalysis = gd.getNextBoolean();
componentAnalysis = gd.getNextChoiceIndex();
resultsTitle = gd.getNextString();
showTP = gd.getNextBoolean();
showFP = gd.getNextBoolean();
showFN = gd.getNextBoolean();
if (gd.invalidNumber())
return false;
resultsPrefix = BenchmarkSpotFit.resultPrefix + "\t" + resultsTitle + "\t";
createResultsPrefix2(scoreFailCount, scoreResidualsThreshold, scoreDuplicateDistance);
// Check there is one output
if (!showSummaryTable && !calculateSensitivity && !saveBestFilter && !saveTemplate) {
IJ.error(TITLE, "No output selected");
return false;
}
// Check arguments
try {
Parameters.isAboveZero("Delta", delta);
Parameters.isBelow("Delta", delta, 1);
} catch (IllegalArgumentException e) {
IJ.error(TITLE, e.getMessage());
return false;
}
if (!selectTableColumns())
return false;
return true;
}
use of java.awt.Checkbox in project GDSC-SMLM by aherbert.
the class FreeFilterResults method showDialog.
private boolean showDialog() {
ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
gd.addHelp(About.HELP_URL);
gd.addMessage("Select a dataset to filter");
ResultsManager.addInput(gd, inputOption, InputSource.MEMORY);
GlobalSettings gs = SettingsManager.loadSettings();
filterSettings = gs.getFilterSettings();
String text;
try {
text = XmlUtils.prettyPrintXml(filterSettings.freeFilter);
} catch (Exception e) {
text = filterSettings.freeFilter;
}
gd.addTextAreas(text, null, 20, 80);
gd.addCheckbox("Show_demo_filters", false);
if (Utils.isShowGenericDialog()) {
Checkbox cb = (Checkbox) gd.getCheckboxes().get(0);
cb.addItemListener(this);
}
gd.showDialog();
if (gd.wasCanceled())
return false;
inputOption = ResultsManager.getInputSource(gd);
filterSettings.freeFilter = gd.getNextText();
boolean demoFilters = gd.getNextBoolean();
if (demoFilters) {
logDemoFilters(TITLE);
return false;
}
return SettingsManager.saveSettings(gs);
}
use of java.awt.Checkbox in project GDSC-SMLM by aherbert.
the class FreeFilterResults method itemStateChanged.
public void itemStateChanged(ItemEvent e) {
// When the checkbox is clicked, output the list of available filters to the ImageJ log
Checkbox cb = (Checkbox) e.getSource();
if (cb.getState()) {
cb.setState(false);
logDemoFilters(TITLE);
}
}
Aggregations