Search in sources :

Example 26 with TextField

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

the class BenchmarkFilterAnalysis method showScoreDialog.

private boolean showScoreDialog() {
    final ExtendedGenericDialog gd = new ExtendedGenericDialog(TITLE);
    addSimulationData(gd);
    // Get the last scored filter or default to the best filter
    createScoreFilter(false);
    gd.addSlider("Fail_count", 0, 20, settings.scoreFailCount);
    computeDoublets = BenchmarkSpotFit.getComputeDoublets();
    if (computeDoublets) {
        gd.addSlider("Residuals_threshold", 0.01, 1, settings.scoreResidualsThreshold);
    }
    gd.addNumericField("Duplicate_distance", settings.scoreDuplicateDistance, 2);
    gd.addTextAreas(uk.ac.sussex.gdsc.core.utils.XmlUtils.convertQuotes(scoreFilter.toXml()), null, 6, 60);
    gd.addCheckbox("Reset_filter", false);
    gd.addCheckbox("Show_summary", settings.showSummaryTable);
    gd.addCheckbox("Clear_tables", settings.clearTables);
    gd.addCheckbox("Save_best_filter", settings.saveBestFilter);
    gd.addCheckbox("Save_template", settings.saveTemplate);
    gd.addCheckbox("Calculate_sensitivity", settings.calculateSensitivity);
    gd.addSlider("Delta", 0.01, 1, settings.delta);
    if (!simulationParameters.fixedDepth) {
        gd.addCheckbox("Depth_recall_analysis", settings.depthRecallAnalysis);
    }
    gd.addCheckbox("Score_analysis", settings.scoreAnalysis);
    gd.addChoice("Component_analysis", Settings.COMPONENT_ANALYSIS_OPTIONS, settings.componentAnalysis);
    gd.addStringField("Title", settings.resultsTitle, 20);
    final String[] labels = { "Show_TP", "Show_FP", "Show_FN" };
    gd.addCheckboxGroup(1, 3, labels, new boolean[] { settings.showTP, settings.showFP, settings.showFN });
    // Dialog to have a reset checkbox. This reverts back to the default.
    if (ImageJUtils.isShowGenericDialog()) {
        final Checkbox cb = (Checkbox) (gd.getCheckboxes().get(0));
        final Vector<TextField> v = gd.getNumericFields();
        final TextArea ta = gd.getTextArea1();
        cb.addItemListener(event -> {
            if (cb.getState()) {
                createScoreFilter(true);
                int index = 0;
                v.get(index++).setText(Integer.toString(settings.scoreFailCount));
                if (computeDoublets) {
                    v.get(index++).setText(Double.toString(settings.scoreResidualsThreshold));
                }
                v.get(index++).setText(Double.toString(settings.scoreDuplicateDistance));
                ta.setText(uk.ac.sussex.gdsc.core.utils.XmlUtils.convertQuotes(scoreFilter.toXml()));
            }
        });
    }
    gd.addHelp(HelpUrls.getUrl("score-filter"));
    gd.showDialog();
    if (gd.wasCanceled()) {
        return false;
    }
    settings.scoreFailCount = (int) Math.abs(gd.getNextNumber());
    if (computeDoublets) {
        settings.scoreResidualsThreshold = Math.abs(gd.getNextNumber());
    }
    settings.scoreDuplicateDistance = Math.abs(gd.getNextNumber());
    final String xml = gd.getNextText();
    boolean reset = gd.getNextBoolean();
    if (!reset) {
        // Try and parse the filter
        try {
            scoreFilter = (DirectFilter) Filter.fromXml(xml);
        } catch (final Exception ex) {
            // Invalid so reset
            reset = true;
        }
    }
    createScoreFilter(reset);
    settings.showSummaryTable = gd.getNextBoolean();
    settings.clearTables = gd.getNextBoolean();
    settings.saveBestFilter = gd.getNextBoolean();
    settings.saveTemplate = gd.getNextBoolean();
    settings.calculateSensitivity = gd.getNextBoolean();
    settings.delta = gd.getNextNumber();
    if (!simulationParameters.fixedDepth) {
        settings.depthRecallAnalysis = gd.getNextBoolean();
    }
    settings.scoreAnalysis = gd.getNextBoolean();
    settings.componentAnalysis = gd.getNextChoiceIndex();
    settings.resultsTitle = gd.getNextString();
    settings.showTP = gd.getNextBoolean();
    settings.showFP = gd.getNextBoolean();
    settings.showFN = gd.getNextBoolean();
    settings.save();
    if (gd.invalidNumber()) {
        return false;
    }
    resultsPrefix = spotFitResults.resultPrefix + "\t" + settings.resultsTitle + "\t";
    createResultsPrefix2(settings.scoreFailCount, settings.scoreResidualsThreshold, settings.scoreDuplicateDistance);
    // Check there is one output
    if (!settings.showSummaryTable && !settings.calculateSensitivity && !settings.saveBestFilter && !settings.saveTemplate) {
        IJ.error(TITLE, "No output selected");
        return false;
    }
    // Check arguments
    try {
        ParameterUtils.isAboveZero("Delta", settings.delta);
        ParameterUtils.isBelow("Delta", settings.delta, 1);
    } catch (final IllegalArgumentException ex) {
        IJ.error(TITLE, ex.getMessage());
        return false;
    }
    return selectTableColumns();
}
Also used : TextArea(java.awt.TextArea) Checkbox(java.awt.Checkbox) TextField(java.awt.TextField) ExtendedGenericDialog(uk.ac.sussex.gdsc.core.ij.gui.ExtendedGenericDialog) ConcurrentRuntimeException(org.apache.commons.lang3.concurrent.ConcurrentRuntimeException)

Example 27 with TextField

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

the class SpotAnalysis method createFrame.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void createFrame() {
    final Panel mainPanel = new Panel();
    add(mainPanel);
    inputChoice = new Choice();
    mainPanel.add(createChoicePanel(inputChoice, ""));
    widthTextField = new TextField();
    mainPanel.add(createTextPanel(widthTextField, "PSF width", "1.2"));
    blurTextField = new TextField();
    mainPanel.add(createTextPanel(blurTextField, "Blur (relative to width)", "1"));
    gainTextField = new TextField();
    mainPanel.add(createTextPanel(gainTextField, "Gain", "37.7"));
    exposureTextField = new TextField();
    mainPanel.add(createTextPanel(exposureTextField, "ms/Frame", "20"));
    smoothingTextField = new TextField();
    mainPanel.add(createTextPanel(smoothingTextField, "Smoothing", "0.25"));
    profileButton = new Button("Profile");
    profileButton.addActionListener(this);
    addButton = new Button("Add");
    addButton.addActionListener(this);
    deleteButton = new Button("Remove");
    deleteButton.addActionListener(this);
    saveButton = new Button("Save");
    saveButton.addActionListener(this);
    saveTracesButton = new Button("Save Traces");
    saveTracesButton.addActionListener(this);
    currentLabel = new Label();
    mainPanel.add(createLabelPanel(currentLabel, "", ""));
    rawFittedLabel = new Label();
    mainPanel.add(createLabelPanel(rawFittedLabel, "", ""));
    blurFittedLabel = new Label();
    mainPanel.add(createLabelPanel(blurFittedLabel, "", ""));
    final JPanel buttonPanel = new JPanel();
    final FlowLayout l = new FlowLayout();
    l.setVgap(0);
    buttonPanel.setLayout(l);
    buttonPanel.add(profileButton, BorderLayout.CENTER);
    buttonPanel.add(addButton, BorderLayout.CENTER);
    buttonPanel.add(deleteButton, BorderLayout.CENTER);
    buttonPanel.add(saveButton, BorderLayout.CENTER);
    buttonPanel.add(saveTracesButton, BorderLayout.CENTER);
    mainPanel.add(buttonPanel);
    listModel = new DefaultListModel();
    onFramesList = new JList(listModel);
    onFramesList.setVisibleRowCount(15);
    onFramesList.addListSelectionListener(this);
    final JScrollPane scrollPane = new JScrollPane(onFramesList);
    mainPanel.add(scrollPane);
    final GridBagLayout mainGrid = new GridBagLayout();
    int y = 0;
    final GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 1;
    c.insets = new Insets(2, 2, 2, 2);
    for (final Component comp : mainPanel.getComponents()) {
        c.gridy = y++;
        mainGrid.setConstraints(comp, c);
    }
    mainPanel.setLayout(mainGrid);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Choice(java.awt.Choice) FlowLayout(java.awt.FlowLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Label(java.awt.Label) DefaultListModel(javax.swing.DefaultListModel) Point(java.awt.Point) Panel(java.awt.Panel) JPanel(javax.swing.JPanel) Button(java.awt.Button) TextField(java.awt.TextField) Component(java.awt.Component) JList(javax.swing.JList)

Example 28 with TextField

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

the class Configuration method showDialog.

/**
	 * Show the current properties
	 */
@SuppressWarnings("unchecked")
public void showDialog() {
    configurationChanged = false;
    String filename = SettingsManager.getSettingsFilename();
    GlobalSettings settings = SettingsManager.loadSettings(filename);
    FitEngineConfiguration config = settings.getFitEngineConfiguration();
    FitConfiguration fitConfig = config.getFitConfiguration();
    Calibration calibration = settings.getCalibration();
    GenericDialog gd = new GenericDialog(TITLE);
    gd.addHelp(About.HELP_URL);
    gd.addMessage("Configuration settings for the single-molecule localisation microscopy plugins");
    gd.addStringField("Config_file", filename, 40);
    gd.addNumericField("Calibration (nm/px)", calibration.getNmPerPixel(), 2);
    gd.addNumericField("Gain", calibration.getGain(), 2);
    gd.addCheckbox("EM-CCD", calibration.isEmCCD());
    gd.addNumericField("Exposure_time (ms)", calibration.getExposureTime(), 2);
    gd.addMessage("--- Gaussian parameters ---");
    gd.addNumericField("Initial_StdDev0", fitConfig.getInitialPeakStdDev0(), 3);
    gd.addNumericField("Initial_StdDev1", fitConfig.getInitialPeakStdDev1(), 3);
    gd.addNumericField("Initial_Angle", fitConfig.getInitialAngle(), 3);
    gd.addMessage("--- Maxima identification ---");
    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());
    gd.addMessage("--- Gaussian fitting ---");
    Component splitLabel = gd.getMessage();
    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()]);
    // Parameters specific to each Fit solver are collected in a second dialog 
    gd.addNumericField("Fail_limit", config.getFailuresLimit(), 0);
    gd.addCheckbox("Include_neighbours", config.isIncludeNeighbours());
    gd.addSlider("Neighbour_height", 0.01, 1, config.getNeighbourHeightThreshold());
    gd.addSlider("Residuals_threshold", 0.01, 1, config.getResidualsThreshold());
    gd.addSlider("Duplicate_distance", 0, 1.5, fitConfig.getDuplicateDistance());
    gd.addMessage("--- Peak filtering ---\nDiscard fits that shift; are too low; or expand/contract");
    gd.addCheckbox("Smart_filter", fitConfig.isSmartFilter());
    gd.addCheckbox("Disable_simple_filter", fitConfig.isDisableSimpleFilter());
    gd.addSlider("Shift_factor", 0.01, 2, fitConfig.getCoordinateShiftFactor());
    gd.addNumericField("Signal_strength", fitConfig.getSignalStrength(), 2);
    gd.addNumericField("Min_photons", fitConfig.getMinPhotons(), 0);
    gd.addSlider("Min_width_factor", 0, 0.99, fitConfig.getMinWidthFactor());
    gd.addSlider("Width_factor", 1.01, 5, fitConfig.getWidthFactor());
    gd.addNumericField("Precision_threshold", fitConfig.getPrecisionThreshold(), 2);
    // Add a mouse listener to the config file field
    if (Utils.isShowGenericDialog()) {
        Vector<TextField> texts = (Vector<TextField>) gd.getStringFields();
        Vector<TextField> numerics = (Vector<TextField>) gd.getNumericFields();
        Vector<Checkbox> checkboxes = (Vector<Checkbox>) gd.getCheckboxes();
        Vector<Choice> choices = (Vector<Choice>) gd.getChoices();
        int n = 0;
        int t = 0;
        int b = 0;
        int ch = 0;
        textConfigFile = texts.get(t++);
        textConfigFile.addMouseListener(this);
        textConfigFile.addTextListener(this);
        // TODO: add a value changed listener to detect when typing a new file
        textNmPerPixel = numerics.get(n++);
        textGain = numerics.get(n++);
        textEMCCD = checkboxes.get(b++);
        textExposure = numerics.get(n++);
        textInitialPeakStdDev0 = numerics.get(n++);
        textInitialPeakStdDev1 = numerics.get(n++);
        textInitialAngleD = 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++);
        textFailuresLimit = numerics.get(n++);
        textIncludeNeighbours = checkboxes.get(b++);
        textNeighbourHeightThreshold = numerics.get(n++);
        textResidualsThreshold = numerics.get(n++);
        textDuplicateDistance = numerics.get(n++);
        textSmartFilter = checkboxes.get(b++);
        textDisableSimpleFilter = checkboxes.get(b++);
        textCoordinateShiftFactor = numerics.get(n++);
        textSignalStrength = numerics.get(n++);
        textMinPhotons = numerics.get(n++);
        textMinWidthFactor = numerics.get(n++);
        textWidthFactor = numerics.get(n++);
        textPrecisionThreshold = numerics.get(n++);
        updateFilterInput();
        textSmartFilter.addItemListener(this);
        textDisableSimpleFilter.addItemListener(this);
    }
    if (gd.getLayout() != null) {
        GridBagLayout grid = (GridBagLayout) gd.getLayout();
        int xOffset = 0, yOffset = 0;
        int lastY = -1, rowCount = 0;
        for (Component comp : gd.getComponents()) {
            // Check if this should be the second major column
            if (comp == splitLabel) {
                xOffset += 2;
                yOffset -= rowCount;
            }
            // Reposition the field
            GridBagConstraints c = grid.getConstraints(comp);
            if (lastY != c.gridy)
                rowCount++;
            lastY = c.gridy;
            c.gridx = c.gridx + xOffset;
            c.gridy = c.gridy + yOffset;
            c.insets.left = c.insets.left + 10 * xOffset;
            c.insets.top = 0;
            c.insets.bottom = 0;
            grid.setConstraints(comp, c);
        }
        if (IJ.isLinux())
            gd.setBackground(new Color(238, 238, 238));
    }
    gd.showDialog();
    if (gd.wasCanceled())
        return;
    filename = gd.getNextString();
    calibration.setNmPerPixel(gd.getNextNumber());
    calibration.setGain(gd.getNextNumber());
    calibration.setEmCCD(gd.getNextBoolean());
    calibration.setExposureTime(gd.getNextNumber());
    fitConfig.setInitialPeakStdDev0(gd.getNextNumber());
    fitConfig.setInitialPeakStdDev1(gd.getNextNumber());
    fitConfig.setInitialAngleD(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());
    config.setFailuresLimit((int) gd.getNextNumber());
    config.setIncludeNeighbours(gd.getNextBoolean());
    config.setNeighbourHeightThreshold(gd.getNextNumber());
    config.setResidualsThreshold(gd.getNextNumber());
    fitConfig.setDuplicateDistance(gd.getNextNumber());
    fitConfig.setSmartFilter(gd.getNextBoolean());
    fitConfig.setDisableSimpleFilter(gd.getNextBoolean());
    fitConfig.setCoordinateShiftFactor(gd.getNextNumber());
    fitConfig.setSignalStrength(gd.getNextNumber());
    fitConfig.setMinPhotons(gd.getNextNumber());
    fitConfig.setMinWidthFactor(gd.getNextNumber());
    fitConfig.setWidthFactor(gd.getNextNumber());
    fitConfig.setPrecisionThreshold(gd.getNextNumber());
    // Check arguments
    try {
        Parameters.isAboveZero("nm per pixel", calibration.getNmPerPixel());
        Parameters.isAboveZero("Gain", calibration.getGain());
        Parameters.isAboveZero("Exposure time", calibration.getExposureTime());
        Parameters.isAboveZero("Initial SD0", fitConfig.getInitialPeakStdDev0());
        Parameters.isAboveZero("Initial SD1", fitConfig.getInitialPeakStdDev1());
        Parameters.isPositive("Initial angle", fitConfig.getInitialAngleD());
        Parameters.isAboveZero("Search_width", config.getSearch());
        Parameters.isAboveZero("Fitting_width", config.getFitting());
        Parameters.isPositive("Failures limit", config.getFailuresLimit());
        Parameters.isPositive("Neighbour height threshold", config.getNeighbourHeightThreshold());
        Parameters.isPositive("Residuals threshold", config.getResidualsThreshold());
        Parameters.isPositive("Duplicate distance", fitConfig.getDuplicateDistance());
        Parameters.isPositive("Coordinate Shift factor", fitConfig.getCoordinateShiftFactor());
        Parameters.isPositive("Signal strength", fitConfig.getSignalStrength());
        Parameters.isPositive("Min photons", fitConfig.getMinPhotons());
        Parameters.isPositive("Min width factor", fitConfig.getMinWidthFactor());
        Parameters.isPositive("Width factor", fitConfig.getWidthFactor());
        Parameters.isPositive("Precision threshold", fitConfig.getPrecisionThreshold());
    } catch (IllegalArgumentException e) {
        IJ.error(TITLE, e.getMessage());
        return;
    }
    if (gd.invalidNumber())
        return;
    configurationChanged = SettingsManager.saveSettings(settings, filename);
    if (configurationChanged)
        SettingsManager.saveSettingsFilename(filename);
    if (!PeakFit.configureSmartFilter(settings, filename))
        return;
    if (!PeakFit.configureDataFilter(settings, filename, false))
        return;
    PeakFit.configureFitSolver(settings, filename, false);
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) Choice(java.awt.Choice) GridBagLayout(java.awt.GridBagLayout) FitEngineConfiguration(gdsc.smlm.engine.FitEngineConfiguration) Color(java.awt.Color) SystemColor(java.awt.SystemColor) GlobalSettings(gdsc.smlm.ij.settings.GlobalSettings) Calibration(gdsc.smlm.results.Calibration) FitConfiguration(gdsc.smlm.fitting.FitConfiguration) Checkbox(java.awt.Checkbox) GenericDialog(ij.gui.GenericDialog) TextField(java.awt.TextField) Component(java.awt.Component) Vector(java.util.Vector)

Example 29 with TextField

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

the class ConnectionDialog method create.

private void create() {
    Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    setLayout(new BorderLayout());
    Panel p = new Panel(new BorderLayout());
    Panel pLabel;
    Panel pText;
    Panel pButton;
    Panel pClearButton;
    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
        pLabel = new Panel(new GridLayout(8, 1, 10, 10));
        pText = new Panel(new GridLayout(8, 1, 10, 10));
        pButton = new Panel(new GridLayout(1, 2, 10, 10));
        pClearButton = new Panel(new GridLayout(8, 1, 10, 10));
    } else {
        pLabel = new Panel(new GridLayout(8, 1));
        pText = new Panel(new GridLayout(8, 1));
        pButton = new Panel(new GridLayout(1, 2));
        pClearButton = new Panel(new GridLayout(8, 1));
    }
    p.add("West", pLabel);
    p.add("Center", pText);
    p.add("South", pButton);
    p.add("North", createLabel(""));
    p.add("East", pClearButton);
    p.setBackground(SystemColor.control);
    pText.setBackground(SystemColor.control);
    pLabel.setBackground(SystemColor.control);
    pButton.setBackground(SystemColor.control);
    pLabel.add(createLabel("Recent:"));
    recent = new Choice();
    try {
        settings = ConnectionDialogCommon.loadRecentConnectionSettings();
    } catch (java.io.IOException ioe) {
        ioe.printStackTrace();
    }
    recent.add(ConnectionDialogCommon.emptySettingName);
    Enumeration en = settings.elements();
    while (en.hasMoreElements()) {
        recent.add(((ConnectionSetting) en.nextElement()).getName());
    }
    recent.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            String s = (String) e.getItem();
            ConnectionSetting setting = (ConnectionSetting) settings.get(s);
            if (setting != null) {
                mName.setText(setting.getName());
                mDriver.setText(setting.getDriver());
                mURL.setText(setting.getUrl());
                mUser.setText(setting.getUser());
                mPassword.setText(setting.getPassword());
            }
        }
    });
    pText.add(recent);
    Button b;
    b = new Button("Clr");
    b.setActionCommand("Clear");
    b.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            ConnectionDialogCommon.deleteRecentConnectionSettings();
            settings = new Hashtable();
            recent.removeAll();
            recent.add(ConnectionDialogCommon.emptySettingName);
            mName.setText(null);
        }
    });
    pClearButton.add(b);
    pLabel.add(createLabel("Setting Name:"));
    mName = new TextField("");
    pText.add(mName);
    pLabel.add(createLabel("Type:"));
    types = new Choice();
    connTypes = ConnectionDialogCommon.getTypes();
    for (int i = 0; i < connTypes.length; i++) {
        types.add(connTypes[i][0]);
    }
    types.addItemListener(this);
    pText.add(types);
    pLabel.add(createLabel("Driver:"));
    mDriver = new TextField(connTypes[0][1]);
    pText.add(mDriver);
    pLabel.add(createLabel("URL:"));
    mURL = new TextField(connTypes[0][2]);
    mURL.addActionListener(this);
    pText.add(mURL);
    pLabel.add(createLabel("User:"));
    mUser = new TextField("SA");
    mUser.addActionListener(this);
    pText.add(mUser);
    pLabel.add(createLabel("Password:"));
    mPassword = new TextField("");
    mPassword.addActionListener(this);
    mPassword.setEchoChar('*');
    pText.add(mPassword);
    b = new Button("Ok");
    b.setActionCommand("ConnectOk");
    b.addActionListener(this);
    pButton.add(b);
    b = new Button("Cancel");
    b.setActionCommand("ConnectCancel");
    b.addActionListener(this);
    pButton.add(b);
    add("East", createLabel(""));
    add("West", createLabel(""));
    mError = new Label("");
    Panel pMessage = createBorderPanel(mError);
    add("South", pMessage);
    add("North", createLabel(""));
    add("Center", p);
    doLayout();
    pack();
    Dimension size = getSize();
    // (ulrivo): full size on screen with less than 640 width
    if (d.width >= 640) {
        setLocation((d.width - size.width) / 2, (d.height - size.height) / 2);
    } else {
        setLocation(0, 0);
        setSize(d);
    }
    show();
}
Also used : ItemEvent(java.awt.event.ItemEvent) Choice(java.awt.Choice) Enumeration(java.util.Enumeration) ActionEvent(java.awt.event.ActionEvent) Hashtable(java.util.Hashtable) Label(java.awt.Label) Dimension(java.awt.Dimension) Panel(java.awt.Panel) GridLayout(java.awt.GridLayout) BorderLayout(java.awt.BorderLayout) ActionListener(java.awt.event.ActionListener) Button(java.awt.Button) TextField(java.awt.TextField) ItemListener(java.awt.event.ItemListener)

Example 30 with TextField

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;
}
Also used : ItemEvent(java.awt.event.ItemEvent) TextArea(java.awt.TextArea) IOException(java.io.IOException) Checkbox(java.awt.Checkbox) GenericDialog(ij.gui.GenericDialog) NonBlockingGenericDialog(ij.gui.NonBlockingGenericDialog) TextField(java.awt.TextField) ItemListener(java.awt.event.ItemListener)

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