Search in sources :

Example 6 with Choice

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

the class DoubletAnalysis method itemStateChanged.

/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.event.ItemListener#itemStateChanged(java.awt.event.ItemEvent)
	 */
public void itemStateChanged(ItemEvent e) {
    if (e.getSource() instanceof Choice) {
        // Update the settings from the template
        Choice choice = (Choice) e.getSource();
        String templateName = choice.getSelectedItem();
        // Get the configuration template
        GlobalSettings template = ConfigurationTemplate.getTemplate(templateName);
        if (textCoordinateShiftFactor != null) {
            if (template != null) {
                if (template.isFitEngineConfiguration()) {
                    FitConfiguration fitConfig = template.getFitEngineConfiguration().getFitConfiguration();
                    cbSmartFilter.setState(fitConfig.isSmartFilter());
                    textCoordinateShiftFactor.setText("" + fitConfig.getCoordinateShiftFactor());
                    textSignalStrength.setText("" + fitConfig.getSignalStrength());
                    textMinPhotons.setText("" + fitConfig.getMinPhotons());
                    textMinWidthFactor.setText("" + fitConfig.getMinWidthFactor());
                    textWidthFactor.setText("" + fitConfig.getWidthFactor());
                    textPrecisionThreshold.setText("" + fitConfig.getPrecisionThreshold());
                    cbLocalBackground.setState(fitConfig.isPrecisionUsingBackground());
                }
            } else {
                // Reset 
                cbSmartFilter.setState(false);
                textCoordinateShiftFactor.setText("0");
                textSignalStrength.setText("0");
                textMinPhotons.setText("0");
                textMinWidthFactor.setText("0");
                textWidthFactor.setText("0");
                textPrecisionThreshold.setText("0");
                cbLocalBackground.setState(false);
            }
        } else {
            if (template != null) {
                if (template.isFitEngineConfiguration()) {
                    boolean custom = ConfigurationTemplate.isCustomTemplate(templateName);
                    FitEngineConfiguration config2 = template.getFitEngineConfiguration();
                    FitConfiguration fitConfig2 = config2.getFitConfiguration();
                    if (custom && fitConfig2.getInitialPeakStdDev0() > 0)
                        textInitialPeakStdDev0.setText("" + fitConfig2.getInitialPeakStdDev0());
                    textDataFilterType.select(config2.getDataFilterType().ordinal());
                    textDataFilter.select(config2.getDataFilter(0).ordinal());
                    textSmooth.setText("" + config2.getSmooth(0));
                    textSearch.setText("" + config2.getSearch());
                    textBorder.setText("" + config2.getBorder());
                    textFitting.setText("" + config2.getFitting());
                    textFitSolver.select(fitConfig2.getFitSolver().ordinal());
                    textFitFunction.select(fitConfig2.getFitFunction().ordinal());
                    // Copy settings not in the dialog for the fit solver
                    fitConfig.setMaxIterations(fitConfig2.getMaxIterations());
                    fitConfig.setMaxFunctionEvaluations(fitConfig2.getMaxFunctionEvaluations());
                    // MLE settings
                    fitConfig.setModelCamera(fitConfig2.isModelCamera());
                    fitConfig.setSearchMethod(fitConfig2.getSearchMethod());
                    fitConfig.setRelativeThreshold(fitConfig2.getRelativeThreshold());
                    fitConfig.setAbsoluteThreshold(fitConfig2.getAbsoluteThreshold());
                    fitConfig.setGradientLineMinimisation(fitConfig2.isGradientLineMinimisation());
                    // LSE settings
                    fitConfig.setFitCriteria(fitConfig2.getFitCriteria());
                    fitConfig.setSignificantDigits(fitConfig2.getSignificantDigits());
                    fitConfig.setDelta(fitConfig2.getDelta());
                    fitConfig.setLambda(fitConfig2.getLambda());
                }
            } else {
            // Ignore
            }
        }
    } else if (e.getSource() instanceof Checkbox) {
        Checkbox checkbox = (Checkbox) e.getSource();
        if (!checkbox.getState())
            return;
        if (textCoordinateShiftFactor != null) {
            if (!updateFilterConfiguration(filterFitConfig))
                return;
            cbSmartFilter.setState(filterFitConfig.isSmartFilter());
            textCoordinateShiftFactor.setText("" + filterFitConfig.getCoordinateShiftFactor());
            textSignalStrength.setText("" + filterFitConfig.getSignalStrength());
            textMinPhotons.setText("" + filterFitConfig.getMinPhotons());
            textMinWidthFactor.setText("" + filterFitConfig.getMinWidthFactor());
            textWidthFactor.setText("" + filterFitConfig.getWidthFactor());
            textPrecisionThreshold.setText("" + filterFitConfig.getPrecisionThreshold());
            cbLocalBackground.setState(filterFitConfig.isPrecisionUsingBackground());
        } else {
            if (!updateFitConfiguration(config))
                return;
            textInitialPeakStdDev0.setText("" + fitConfig.getInitialPeakStdDev0());
            textDataFilterType.select(config.getDataFilterType().ordinal());
            textDataFilter.select(config.getDataFilter(0).ordinal());
            textSmooth.setText("" + config.getSmooth(0));
            textSearch.setText("" + config.getSearch());
            textBorder.setText("" + config.getBorder());
            textFitting.setText("" + config.getFitting());
            textFitSolver.select(fitConfig.getFitSolver().ordinal());
            textFitFunction.select(fitConfig.getFitFunction().ordinal());
            textMatchDistance.setText("" + matchDistance);
            textLowerDistance.setText("" + lowerDistance);
            textSignalFactor.setText("" + signalFactor);
            textLowerFactor.setText("" + lowerSignalFactor);
        }
    }
}
Also used : Choice(java.awt.Choice) FitConfiguration(gdsc.smlm.fitting.FitConfiguration) FitEngineConfiguration(gdsc.smlm.engine.FitEngineConfiguration) Checkbox(java.awt.Checkbox) GlobalSettings(gdsc.smlm.ij.settings.GlobalSettings)

Example 7 with Choice

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

the class SpotAnalysis method createFrame.

@SuppressWarnings({ "rawtypes", "unchecked" })
private void createFrame() {
    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, "", ""));
    JPanel buttonPanel = new JPanel();
    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);
    //mainPanel.add(onFramesList);
    JScrollPane scrollPane = new JScrollPane(onFramesList);
    scrollPane.getVerticalScrollBarPolicy();
    mainPanel.add(scrollPane);
    GridBagLayout mainGrid = new GridBagLayout();
    int y = 0;
    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 (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 8 with Choice

use of java.awt.Choice 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 9 with Choice

use of java.awt.Choice 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)

Example 10 with Choice

use of java.awt.Choice 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)

Aggregations

Choice (java.awt.Choice)13 TextField (java.awt.TextField)10 Checkbox (java.awt.Checkbox)8 GlobalSettings (gdsc.smlm.ij.settings.GlobalSettings)6 Label (java.awt.Label)5 Panel (java.awt.Panel)5 Vector (java.util.Vector)5 Button (java.awt.Button)4 Component (java.awt.Component)4 GridBagConstraints (java.awt.GridBagConstraints)4 GridBagLayout (java.awt.GridBagLayout)4 ExtendedGenericDialog (ij.gui.ExtendedGenericDialog)3 GenericDialog (ij.gui.GenericDialog)3 BorderLayout (java.awt.BorderLayout)3 BasePoint (gdsc.core.match.BasePoint)2 FitEngineConfiguration (gdsc.smlm.engine.FitEngineConfiguration)2 FitConfiguration (gdsc.smlm.fitting.FitConfiguration)2 PeakResultPoint (gdsc.smlm.ij.plugins.ResultsMatchCalculator.PeakResultPoint)2 Color (java.awt.Color)2 Dimension (java.awt.Dimension)2