use of java.awt.TextField in project voltdb by VoltDB.
the class Transfer method actionPerformed.
/**
* Method declaration
*
*
* @param ev
*/
public void actionPerformed(ActionEvent ev) {
if (ev.getSource() instanceof TextField) {
saveTable();
return;
}
String s = ev.getActionCommand();
MenuItem i = new MenuItem();
if (s == null) {
if (ev.getSource() instanceof MenuItem) {
i = (MenuItem) ev.getSource();
s = i.getLabel();
}
}
if (s == null) {
}
if (s.equals("Start Transfer") || s.equals("ReStart Transfer")) {
bStart.setLabel("ReStart Transfer");
bStart.invalidate();
CurrentTransfer = 0;
CurrentAlter = 0;
transfer();
} else if (s.equals("Continue Transfer")) {
transfer();
} else if (s.equals("Start Dump") || s.equals("Start Restore")) {
CurrentTransfer = 0;
CurrentAlter = 0;
transfer();
} else if (s.equals("Quit")) {
exit();
} else if (s.indexOf("Select Schema") >= 0) {
String[] selection = lTable.getSelectedItems();
if ((selection == null) || (selection.length == 0)) {
return;
}
if (iSelectionStep == Transfer.SELECT_SOURCE_SCHEMA) {
sSourceSchemas = selection;
} else {
sDestSchema = selection[0];
}
if (iTransferMode == TRFM_DUMP) {
iSelectionStep = Transfer.SELECT_SOURCE_TABLES;
} else {
iSelectionStep++;
}
ProcessNextStep();
} else if (s.indexOf("Select Catalog") >= 0) {
String selection = lTable.getSelectedItem();
if ((selection == null) || (selection.equals(""))) {
return;
}
if (iSelectionStep == Transfer.SELECT_SOURCE_CATALOG) {
sSourceCatalog = selection;
sSourceSchemas = null;
} else {
sDestCatalog = selection;
sDestSchema = null;
try {
targetDb.setCatalog(sDestCatalog);
} catch (Exception ex) {
trace("Catalog " + sDestCatalog + " could not be selected in the target database");
sDestCatalog = null;
}
}
iSelectionStep++;
ProcessNextStep();
} else if (s.equals("Insert 10 rows only")) {
iMaxRows = 10;
} else if (s.equals("Insert 1000 rows only")) {
iMaxRows = 1000;
} else if (s.equals("Insert all rows")) {
iMaxRows = 0;
} else if (s.equals("Load Settings...")) {
FileDialog f = new FileDialog(fMain, "Load Settings", FileDialog.LOAD);
f.show();
String file = f.getDirectory() + f.getFile();
if (file != null) {
LoadPrefs(file);
displayTable(tCurrent);
}
} else if (s.equals("Save Settings...")) {
FileDialog f = new FileDialog(fMain, "Save Settings", FileDialog.SAVE);
f.show();
String file = f.getDirectory() + f.getFile();
if (file != null) {
SavePrefs(file);
}
} else if (s.equals("Exit")) {
windowClosing(null);
}
}
use of java.awt.TextField in project voltdb by VoltDB.
the class Transfer method initGUI.
/**
* Method declaration
*
*/
private void initGUI() {
Font fFont = new Font("Dialog", Font.PLAIN, 12);
setLayout(new BorderLayout());
Panel p = new Panel();
p.setBackground(SystemColor.control);
p.setLayout(new GridLayout(16, 1));
tSourceTable = new TextField();
tSourceTable.setEnabled(false);
tDestTable = new TextField();
tDestTable.addActionListener(this);
tDestDrop = new TextField();
tDestDrop.addActionListener(this);
tDestCreate = new TextField();
tDestCreate.addActionListener(this);
tDestDelete = new TextField();
tDestDelete.addActionListener(this);
tDestCreateIndex = new TextField();
tDestCreateIndex.addActionListener(this);
tDestDropIndex = new TextField();
tDestDropIndex.addActionListener(this);
tSourceSelect = new TextField();
tSourceSelect.addActionListener(this);
tDestInsert = new TextField();
tDestInsert.addActionListener(this);
tDestAlter = new TextField();
tDestAlter.addActionListener(this);
cTransfer = new Checkbox("Transfer to destination table", true);
cTransfer.addItemListener(this);
cDrop = new Checkbox("Drop destination table (ignore error)", true);
cDrop.addItemListener(this);
cCreate = new Checkbox("Create destination table", true);
cCreate.addItemListener(this);
cDropIndex = new Checkbox("Drop destination index (ignore error)", true);
cDropIndex.addItemListener(this);
cIdxForced = new Checkbox("force Idx_ prefix for indexes names", false);
cIdxForced.addItemListener(this);
cCreateIndex = new Checkbox("Create destination index", true);
cCreateIndex.addItemListener(this);
cDelete = new Checkbox("Delete rows in destination table", true);
cDelete.addItemListener(this);
cInsert = new Checkbox("Insert into destination", true);
cInsert.addItemListener(this);
cFKForced = new Checkbox("force FK_ prefix for foreign key names", false);
cFKForced.addItemListener(this);
cAlter = new Checkbox("Alter destination table", true);
cAlter.addItemListener(this);
p.add(createLabel("Source table"));
p.add(tSourceTable);
p.add(cTransfer);
p.add(tDestTable);
p.add(cDrop);
p.add(tDestDrop);
p.add(cCreate);
p.add(tDestCreate);
p.add(cDropIndex);
p.add(tDestDropIndex);
p.add(cCreateIndex);
p.add(tDestCreateIndex);
p.add(cDelete);
p.add(tDestDelete);
p.add(cAlter);
p.add(tDestAlter);
p.add(createLabel("Select source records"));
p.add(tSourceSelect);
p.add(cInsert);
p.add(tDestInsert);
p.add(createLabel(""));
p.add(createLabel(""));
p.add(cIdxForced);
p.add(cFKForced);
p.add(createLabel(""));
p.add(createLabel(""));
if (iTransferMode == TRFM_TRANSFER) {
bStart = new Button("Start Transfer");
bContinue = new Button("Continue Transfer");
bContinue.setEnabled(false);
} else if (iTransferMode == Transfer.TRFM_DUMP) {
bStart = new Button("Start Dump");
} else if (iTransferMode == Transfer.TRFM_RESTORE) {
bStart = new Button("Start Restore");
}
bStart.addActionListener(this);
p.add(bStart);
if (iTransferMode == TRFM_TRANSFER) {
bContinue.addActionListener(this);
p.add(bContinue);
}
bStart.setEnabled(false);
fMain.add("Center", createBorderPanel(p));
lTable = new java.awt.List(10);
lTable.addItemListener(this);
fMain.add("West", createBorderPanel(lTable));
tMessage = new TextField();
Panel pMessage = createBorderPanel(tMessage);
fMain.add("South", pMessage);
}
use of java.awt.TextField 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.TextField 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 java.awt.TextField in project GDSC-SMLM by aherbert.
the class DoubletAnalysis method showAnalysisDialog.
/**
* Show dialog.
*
* @return true, if successful
*/
@SuppressWarnings("unchecked")
private boolean showAnalysisDialog() {
GenericDialog gd = new GenericDialog(TITLE);
gd.addHelp(About.HELP_URL);
StringBuilder sb = new StringBuilder("Filters the doublet fits and reports the performance increase\n");
// Show the fitting settings that will effect filters, i.e. fit standard deviation, fit width
sb.append("SD0 = ").append(Utils.rounded(fitConfig.getInitialPeakStdDev0())).append("\n");
sb.append("SD1 = ").append(Utils.rounded(fitConfig.getInitialPeakStdDev1())).append("\n");
sb.append("Fit Width = ").append(config.getRelativeFitting()).append("\n");
gd.addMessage(sb.toString());
// Collect options for filtering
gd.addChoice("Selection_Criteria", SELECTION_CRITERIA, SELECTION_CRITERIA[selectionCriteria]);
// Copy the settings used when fitting
filterFitConfig.setInitialPeakStdDev0(fitConfig.getInitialPeakStdDev0());
filterFitConfig.setInitialPeakStdDev1(fitConfig.getInitialPeakStdDev1());
filterFitConfig.setModelCamera(fitConfig.isModelCamera());
filterFitConfig.setNmPerPixel(cal.getNmPerPixel());
filterFitConfig.setGain(cal.getGain());
filterFitConfig.setBias(cal.getBias());
filterFitConfig.setReadNoise(cal.getReadNoise());
filterFitConfig.setAmplification(cal.getAmplification());
filterFitConfig.setEmCCD(cal.isEmCCD());
filterFitConfig.setFitSolver(fitConfig.getFitSolver());
String[] templates = ConfigurationTemplate.getTemplateNames(true);
gd.addChoice("Template", templates, templates[0]);
// Allow the settings from the benchmark analysis to be used
gd.addCheckbox("Benchmark_settings", analysisUseBenchmarkSettings);
gd.addCheckbox("Smart_filter", fitConfig.isSmartFilter());
gd.addSlider("Shift_factor", 0.01, 2, filterFitConfig.getCoordinateShiftFactor());
gd.addNumericField("Signal_strength", filterFitConfig.getSignalStrength(), 2);
gd.addNumericField("Min_photons", filterFitConfig.getMinPhotons(), 0);
gd.addSlider("Min_width_factor", 0, 0.99, filterFitConfig.getMinWidthFactor());
gd.addSlider("Max_width_factor", 1.01, 5, filterFitConfig.getWidthFactor());
gd.addNumericField("Precision", filterFitConfig.getPrecisionThreshold(), 2);
gd.addCheckbox("Local_background", filterFitConfig.isPrecisionUsingBackground());
gd.addNumericField("Drift_angle", analysisDriftAngle, 2);
gd.addNumericField("Min_gap", minGap, 2);
// Collect display options
gd.addCheckbox("Show_results", analysisShowResults);
gd.addCheckbox("Show_Jaccard_Plot", showJaccardPlot);
gd.addCheckbox("Use_max_residuals", useMaxResiduals);
gd.addCheckbox("Logging", analysisLogging);
gd.addStringField("Title", analysisTitle);
gd.addCheckbox("Save_template", saveTemplate);
// Add a mouse listener to the config file field
if (Utils.isShowGenericDialog()) {
Vector<TextField> numerics = (Vector<TextField>) gd.getNumericFields();
Vector<Checkbox> checkboxes = (Vector<Checkbox>) gd.getCheckboxes();
Vector<Choice> choices = (Vector<Choice>) gd.getChoices();
int n = 0;
choices.get(1).addItemListener(this);
checkboxes.get(0).addItemListener(this);
cbSmartFilter = checkboxes.get(1);
textCoordinateShiftFactor = numerics.get(n++);
textSignalStrength = numerics.get(n++);
textMinPhotons = numerics.get(n++);
textMinWidthFactor = numerics.get(n++);
textWidthFactor = numerics.get(n++);
textPrecisionThreshold = numerics.get(n++);
cbLocalBackground = checkboxes.get(2);
}
gd.showDialog();
if (gd.wasCanceled())
return false;
if (gd.invalidNumber())
return false;
selectionCriteria = gd.getNextChoiceIndex();
// Ignore the template
gd.getNextChoice();
analysisUseBenchmarkSettings = gd.getNextBoolean();
fitConfig.setSmartFilter(gd.getNextBoolean());
filterFitConfig.setCoordinateShiftFactor(gd.getNextNumber());
filterFitConfig.setSignalStrength(gd.getNextNumber());
filterFitConfig.setMinPhotons(gd.getNextNumber());
filterFitConfig.setMinWidthFactor(gd.getNextNumber());
filterFitConfig.setWidthFactor(gd.getNextNumber());
filterFitConfig.setPrecisionThreshold(gd.getNextNumber());
filterFitConfig.setPrecisionUsingBackground(gd.getNextBoolean());
analysisDriftAngle = gd.getNextNumber();
minGap = gd.getNextNumber();
analysisShowResults = gd.getNextBoolean();
showJaccardPlot = gd.getNextBoolean();
useMaxResiduals = gd.getNextBoolean();
analysisLogging = gd.getNextBoolean();
analysisTitle = gd.getNextString();
saveTemplate = gd.getNextBoolean();
if (gd.invalidNumber())
return false;
if (analysisUseBenchmarkSettings) {
if (!updateFilterConfiguration(filterFitConfig))
return false;
}
return true;
}
Aggregations