Search in sources :

Example 31 with TextField

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();
}
Also used : Choice(java.awt.Choice) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) TextField(java.awt.TextField) ExtendedGenericDialog(ij.gui.ExtendedGenericDialog)

Example 32 with TextField

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;
}
Also used : Choice(java.awt.Choice) Checkbox(java.awt.Checkbox) GenericDialog(ij.gui.GenericDialog) TextField(java.awt.TextField) Vector(java.util.Vector) PeakResultPoint(gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint) BasePoint(gdsc.core.match.BasePoint)

Example 33 with TextField

use of java.awt.TextField in project GDSC-SMLM by aherbert.

the class DoubletAnalysis method showDialog.

/**
	 * Show dialog.
	 *
	 * @return true, if successful
	 */
@SuppressWarnings("unchecked")
private boolean showDialog() {
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    final double sa = getSa();
    gd.addMessage(String.format("Fits the benchmark image created by CreateData plugin.\nPSF width = %s, adjusted = %s", Utils.rounded(simulationParameters.s / simulationParameters.a), Utils.rounded(sa)));
    // For each new benchmark width, reset the PSF width to the square pixel adjustment
    if (lastId != simulationParameters.id) {
        double w = sa;
        matchDistance = w * Gaussian2DFunction.SD_TO_HWHM_FACTOR;
        lowerDistance = 0.5 * matchDistance;
        fitConfig.setInitialPeakStdDev(w);
        cal.setNmPerPixel(simulationParameters.a);
        cal.setGain(simulationParameters.gain);
        cal.setAmplification(simulationParameters.amplification);
        cal.setExposureTime(100);
        cal.setReadNoise(simulationParameters.readNoise);
        cal.setBias(simulationParameters.bias);
        cal.setEmCCD(simulationParameters.emCCD);
        fitConfig.setGain(cal.getGain());
        fitConfig.setBias(cal.getBias());
        fitConfig.setReadNoise(cal.getReadNoise());
        fitConfig.setAmplification(cal.getAmplification());
    }
    // Support for using templates
    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", useBenchmarkSettings);
    // Collect options for fitting
    gd.addNumericField("Initial_StdDev", fitConfig.getInitialPeakStdDev0(), 3);
    String[] filterTypes = SettingsManager.getNames((Object[]) DataFilterType.values());
    gd.addChoice("Spot_filter_type", filterTypes, filterTypes[config.getDataFilterType().ordinal()]);
    String[] filterNames = SettingsManager.getNames((Object[]) DataFilter.values());
    gd.addChoice("Spot_filter", filterNames, filterNames[config.getDataFilter(0).ordinal()]);
    gd.addSlider("Smoothing", 0, 2.5, config.getSmooth(0));
    gd.addSlider("Search_width", 0.5, 2.5, config.getSearch());
    gd.addSlider("Border", 0.5, 2.5, config.getBorder());
    gd.addSlider("Fitting_width", 2, 4.5, config.getFitting());
    String[] solverNames = SettingsManager.getNames((Object[]) FitSolver.values());
    gd.addChoice("Fit_solver", solverNames, solverNames[fitConfig.getFitSolver().ordinal()]);
    String[] functionNames = SettingsManager.getNames((Object[]) FitFunction.values());
    gd.addChoice("Fit_function", functionNames, functionNames[fitConfig.getFitFunction().ordinal()]);
    gd.addSlider("Iteration_increase", 1, 4.5, iterationIncrease);
    gd.addCheckbox("Ignore_with_neighbours", ignoreWithNeighbours);
    gd.addCheckbox("Show_overlay", showOverlay);
    gd.addCheckbox("Show_histograms", showHistograms);
    gd.addCheckbox("Show_results", showResults);
    gd.addCheckbox("Show_Jaccard_Plot", showJaccardPlot);
    gd.addCheckbox("Use_max_residuals", useMaxResiduals);
    gd.addNumericField("Match_distance", matchDistance, 2);
    gd.addNumericField("Lower_distance", lowerDistance, 2);
    gd.addNumericField("Signal_factor", signalFactor, 2);
    gd.addNumericField("Lower_factor", lowerSignalFactor, 2);
    gd.addChoice("Matching", MATCHING, MATCHING[matching]);
    // Add a mouse listener to the config file field
    if (Utils.isShowGenericDialog()) {
        Vector<TextField> numerics = (Vector<TextField>) gd.getNumericFields();
        Vector<Choice> choices = (Vector<Choice>) gd.getChoices();
        int n = 0;
        int ch = 0;
        choices.get(ch++).addItemListener(this);
        Checkbox b = (Checkbox) gd.getCheckboxes().get(0);
        b.addItemListener(this);
        textInitialPeakStdDev0 = numerics.get(n++);
        textDataFilterType = choices.get(ch++);
        textDataFilter = choices.get(ch++);
        textSmooth = numerics.get(n++);
        textSearch = numerics.get(n++);
        textBorder = numerics.get(n++);
        textFitting = numerics.get(n++);
        textFitSolver = choices.get(ch++);
        textFitFunction = choices.get(ch++);
        // Iteration increase
        n++;
        textMatchDistance = numerics.get(n++);
        textLowerDistance = numerics.get(n++);
        textSignalFactor = numerics.get(n++);
        textLowerFactor = numerics.get(n++);
    }
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    // Ignore the template
    gd.getNextChoice();
    useBenchmarkSettings = gd.getNextBoolean();
    fitConfig.setInitialPeakStdDev(gd.getNextNumber());
    config.setDataFilterType(gd.getNextChoiceIndex());
    config.setDataFilter(gd.getNextChoiceIndex(), Math.abs(gd.getNextNumber()), 0);
    config.setSearch(gd.getNextNumber());
    config.setBorder(gd.getNextNumber());
    config.setFitting(gd.getNextNumber());
    fitConfig.setFitSolver(gd.getNextChoiceIndex());
    fitConfig.setFitFunction(gd.getNextChoiceIndex());
    // Avoid stupidness. Note: We are mostly ignoring the validation result and 
    // checking the results for the doublets manually.
    // Realistically we cannot fit lower than this
    fitConfig.setMinPhotons(15);
    // Set the width factors to help establish bounds for bounded fitters
    fitConfig.setMinWidthFactor(1.0 / 10);
    fitConfig.setWidthFactor(10);
    iterationIncrease = gd.getNextNumber();
    ignoreWithNeighbours = gd.getNextBoolean();
    showOverlay = gd.getNextBoolean();
    showHistograms = gd.getNextBoolean();
    showResults = gd.getNextBoolean();
    showJaccardPlot = gd.getNextBoolean();
    useMaxResiduals = gd.getNextBoolean();
    matchDistance = Math.abs(gd.getNextNumber());
    lowerDistance = Math.abs(gd.getNextNumber());
    signalFactor = Math.abs(gd.getNextNumber());
    lowerSignalFactor = Math.abs(gd.getNextNumber());
    matching = gd.getNextChoiceIndex();
    if (gd.invalidNumber())
        return false;
    if (lowerDistance > matchDistance)
        lowerDistance = matchDistance;
    if (lowerSignalFactor > signalFactor)
        lowerSignalFactor = signalFactor;
    if (useBenchmarkSettings) {
        if (!updateFitConfiguration(config))
            return false;
    }
    GlobalSettings settings = new GlobalSettings();
    settings.setFitEngineConfiguration(config);
    settings.setCalibration(cal);
    boolean configure = true;
    if (useBenchmarkSettings) {
        // Only configure the fit solver if not in a macro
        configure = Macro.getOptions() == null;
    }
    if (configure && !PeakFit.configureFitSolver(settings, null, false))
        return false;
    lastId = simulationParameters.id;
    if (showHistograms) {
        gd = new GenericDialog(TITLE);
        gd.addMessage("Select the histograms to display");
        for (int i = 0; i < NAMES.length; i++) gd.addCheckbox(NAMES[i].replace(' ', '_'), displayHistograms[i]);
        for (int i = 0; i < NAMES2.length; i++) gd.addCheckbox(NAMES2[i].replace(' ', '_'), displayHistograms[i + NAMES.length]);
        gd.showDialog();
        if (gd.wasCanceled())
            return false;
        for (int i = 0; i < displayHistograms.length; i++) displayHistograms[i] = gd.getNextBoolean();
    }
    return true;
}
Also used : Choice(java.awt.Choice) GlobalSettings(gdsc.smlm.ij.settings.GlobalSettings) PeakResultPoint(gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint) BasePoint(gdsc.core.match.BasePoint) Checkbox(java.awt.Checkbox) GenericDialog(ij.gui.GenericDialog) TextField(java.awt.TextField) Vector(java.util.Vector)

Example 34 with TextField

use of java.awt.TextField in project GDSC-SMLM by aherbert.

the class CreateData method showLoadDialog.

/**
	 * Show a dialog allowing the parameters for a benchmark simulation to be loaded
	 * 
	 * @return True if the parameters were collected
	 */
private boolean showLoadDialog() {
    GenericDialog gd = new GenericDialog(TITLE);
    String[] images = Utils.getImageList(Utils.GREY_SCALE);
    gd.addChoice("Image", images, benchmarkImage);
    gd.addStringField("Results_file", benchmarkFile);
    gd.addCheckbox("Preprocessed_results", benchmarkAuto);
    if (Utils.isShowGenericDialog()) {
        // Add a listener to allow selection of the file
        @SuppressWarnings("unchecked") Vector<TextField> texts = (Vector<TextField>) gd.getStringFields();
        TextField textFile = texts.get(0);
        textFile.addMouseListener(this);
    }
    gd.showDialog();
    if (gd.wasCanceled())
        return false;
    benchmarkImage = gd.getNextChoice();
    benchmarkFile = gd.getNextString();
    benchmarkAuto = gd.getNextBoolean();
    return true;
}
Also used : GenericDialog(ij.gui.GenericDialog) TextField(java.awt.TextField) Vector(java.util.Vector)

Example 35 with TextField

use of java.awt.TextField in project voltdb by VoltDB.

the class ZaurusConnectionDialog method create.

/**
     * Method declaration
     *
     */
void create(Insets defInsets) {
    setLayout(new BorderLayout());
    addKeyListener(this);
    Panel p = new Panel(new GridLayout(6, 2, 10, 10));
    p.addKeyListener(this);
    p.setBackground(SystemColor.control);
    p.add(createLabel("Type:"));
    Choice types = new Choice();
    types.addItemListener(this);
    types.addKeyListener(this);
    for (int i = 0; i < sJDBCTypes.length; i++) {
        types.add(sJDBCTypes[i][0]);
    }
    p.add(types);
    p.add(createLabel("Driver:"));
    mDriver = new TextField("org.hsqldb_voltpatches.jdbcDriver");
    mDriver.addKeyListener(this);
    p.add(mDriver);
    p.add(createLabel("URL:"));
    mURL = new TextField("jdbc:hsqldb:mem:.");
    mURL.addKeyListener(this);
    p.add(mURL);
    p.add(createLabel("User:"));
    mUser = new TextField("SA");
    mUser.addKeyListener(this);
    p.add(mUser);
    p.add(createLabel("Password:"));
    mPassword = new TextField("");
    mPassword.addKeyListener(this);
    mPassword.setEchoChar('*');
    p.add(mPassword);
    Button b;
    b = new Button("Cancel");
    b.setActionCommand("ConnectCancel");
    b.addActionListener(this);
    b.addKeyListener(this);
    p.add(b);
    b = new Button("Ok");
    b.setActionCommand("ConnectOk");
    b.addActionListener(this);
    b.addKeyListener(this);
    p.add(b);
    setLayout(new BorderLayout());
    add("East", createLabel(" "));
    add("West", createLabel(" "));
    mError = new Label("");
    Panel pMessage = createBorderPanel(mError);
    pMessage.addKeyListener(this);
    add("South", pMessage);
    add("North", createLabel(""));
    add("Center", p);
    doLayout();
    pack();
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = getSize();
    if (d.width > 640) {
        setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else if (defInsets.top > 0 && defInsets.left > 0) {
        setLocation(defInsets.bottom, defInsets.right);
        setSize(defInsets.top, defInsets.left);
    // full size on screen with less than 640 width
    } else {
        setLocation(0, 0);
        setSize(d);
    }
    show();
}
Also used : Panel(java.awt.Panel) GridLayout(java.awt.GridLayout) Choice(java.awt.Choice) BorderLayout(java.awt.BorderLayout) Button(java.awt.Button) Label(java.awt.Label) TextField(java.awt.TextField) Dimension(java.awt.Dimension)

Aggregations

TextField (java.awt.TextField)56 Checkbox (java.awt.Checkbox)21 Choice (java.awt.Choice)21 Label (java.awt.Label)18 Panel (java.awt.Panel)17 Button (java.awt.Button)13 GenericDialog (ij.gui.GenericDialog)11 GridBagConstraints (java.awt.GridBagConstraints)11 GridBagLayout (java.awt.GridBagLayout)11 ExtendedGenericDialog (uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog)10 Color (java.awt.Color)9 Component (java.awt.Component)8 Vector (java.util.Vector)8 BorderLayout (java.awt.BorderLayout)6 FlowLayout (java.awt.FlowLayout)6 Dimension (java.awt.Dimension)5 Frame (java.awt.Frame)5 Insets (java.awt.Insets)5 Point (java.awt.Point)5 JPanel (javax.swing.JPanel)5