Search in sources :

Example 41 with JFormattedTextField

use of javax.swing.JFormattedTextField in project EnrichmentMapApp by BaderLab.

the class CutoffPropertiesPanel method createFilterEdgesPanel.

private JPanel createFilterEdgesPanel() {
    JPanel panel = new JPanel();
    panel.setBorder(LookAndFeelUtil.createTitledBorder("Similarity Filtering (Edges)"));
    JLabel cutoffLabel = new JLabel("Cutoff:");
    JLabel metricLabel = new JLabel("Metric:");
    SwingUtil.makeSmall(cutoffLabel, metricLabel);
    SimilarityMetric defaultMetric = propertyManager.getDefaultSimilarityMetric();
    double defaultCutoff = propertyManager.getDefaultCutOff(defaultMetric);
    similarityCutoffText = new JFormattedTextField(getFormatterFactory(false));
    similarityCutoffText.setValue(defaultCutoff);
    cutoffMetricCombo = new JComboBox<>();
    cutoffMetricCombo.addItem(new ComboItem<>(SimilarityMetric.JACCARD, "Jaccard"));
    cutoffMetricCombo.addItem(new ComboItem<>(SimilarityMetric.OVERLAP, "Overlap"));
    cutoffMetricCombo.addItem(new ComboItem<>(SimilarityMetric.COMBINED, "Jaccard+Overlap Combined"));
    SwingUtil.makeSmall(similarityCutoffText, cutoffMetricCombo);
    ActionListener sliderUpdate = e -> {
        SimilarityMetric type = getSimilarityMetric();
        similarityCutoffText.setValue(cutoffValues.get(type));
        combinedConstantSlider.setVisible(type == SimilarityMetric.COMBINED);
    };
    double combinedConstant = propertyManager.getDefaultCombinedConstant();
    int tick = (int) (combinedConstant * 100.0);
    combinedConstantSlider = new CombinedConstantSlider(tick);
    combinedConstantSlider.setOpaque(false);
    // default
    cutoffMetricCombo.setSelectedItem(ComboItem.of(defaultMetric));
    cutoffMetricCombo.addActionListener(sliderUpdate);
    similarityCutoffText.addPropertyChangeListener("value", e -> {
        double value = ((Number) e.getNewValue()).doubleValue();
        cutoffValues.put(getSimilarityMetric(), value);
    });
    sliderUpdate.actionPerformed(null);
    final GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);
    layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup().addComponent(cutoffLabel).addComponent(metricLabel)).addGroup(layout.createParallelGroup().addComponent(similarityCutoffText, PREFERRED_SIZE, 100, PREFERRED_SIZE).addComponent(cutoffMetricCombo, PREFERRED_SIZE, PREFERRED_SIZE, PREFERRED_SIZE).addComponent(combinedConstantSlider, PREFERRED_SIZE, PREFERRED_SIZE, PREFERRED_SIZE)).addGap(0, 0, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(cutoffLabel).addComponent(similarityCutoffText)).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(metricLabel).addComponent(cutoffMetricCombo)).addComponent(combinedConstantSlider, PREFERRED_SIZE, PREFERRED_SIZE, PREFERRED_SIZE).addGap(0, 0, Short.MAX_VALUE));
    if (LookAndFeelUtil.isAquaLAF())
        panel.setOpaque(false);
    return panel;
}
Also used : ActionListener(java.awt.event.ActionListener) Inject(com.google.inject.Inject) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection) NumberFormat(java.text.NumberFormat) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) NESFilter(org.baderlab.csplugins.enrichmentmap.model.EnrichmentResultFilterParams.NESFilter) ComboItem(org.baderlab.csplugins.enrichmentmap.view.util.ComboItem) InternationalFormatter(javax.swing.text.InternationalFormatter) Map(java.util.Map) JComboBox(javax.swing.JComboBox) AbstractFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory) JFormattedTextField(javax.swing.JFormattedTextField) EnumMap(java.util.EnumMap) DecimalFormat(java.text.DecimalFormat) PREFERRED_SIZE(javax.swing.GroupLayout.PREFERRED_SIZE) Alignment(javax.swing.GroupLayout.Alignment) LookAndFeelUtil(org.cytoscape.util.swing.LookAndFeelUtil) JLabel(javax.swing.JLabel) SwingUtil(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil) GroupLayout(javax.swing.GroupLayout) JCheckBox(javax.swing.JCheckBox) AbstractFormatter(javax.swing.JFormattedTextField.AbstractFormatter) Optional(java.util.Optional) PropertyManager(org.baderlab.csplugins.enrichmentmap.PropertyManager) JPanel(javax.swing.JPanel) JPanel(javax.swing.JPanel) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) ActionListener(java.awt.event.ActionListener) GroupLayout(javax.swing.GroupLayout)

Example 42 with JFormattedTextField

use of javax.swing.JFormattedTextField in project EnrichmentMapApp by BaderLab.

the class CutoffPropertiesPanel method createFilterNodesPanel.

private JPanel createFilterNodesPanel() {
    JPanel panel = new JPanel();
    panel.setBorder(LookAndFeelUtil.createTitledBorder("Gene-Set Filtering (Nodes)"));
    pvalueLabel = new JLabel("p-value cutoff:");
    JLabel qvalueLabel = new JLabel("FDR q-value cutoff:");
    nesFilterLabel = new JLabel("NES:");
    shouldFilterMinLabel = new JLabel("Filter by minimum experiments:");
    minExperimentsLabel = new JLabel("Minimum experiments:");
    SwingUtil.makeSmall(qvalueLabel, pvalueLabel, minExperimentsLabel, shouldFilterMinLabel, nesFilterLabel);
    AbstractFormatterFactory formatterFactory = getFormatterFactory(false);
    pvalueText = new JFormattedTextField(formatterFactory);
    qvalueText = new JFormattedTextField(formatterFactory);
    shouldFilterMinCheckbox = new JCheckBox("");
    minExperimentsText = new JFormattedTextField(NumberFormat.getIntegerInstance());
    pvalueText.setValue(propertyManager.getDefaultPvalue());
    qvalueText.setValue(propertyManager.getDefaultQvalue());
    minExperimentsText.setValue(3);
    nesFilterCombo = new JComboBox<>();
    nesFilterCombo.addItem(new ComboItem<>(NESFilter.ALL, "All"));
    nesFilterCombo.addItem(new ComboItem<>(NESFilter.POSITIVE, "Positive"));
    nesFilterCombo.addItem(new ComboItem<>(NESFilter.NEGATIVE, "Negative"));
    nesFilterCombo.setSelectedItem(ComboItem.of(NESFilter.ALL));
    minExperimentsLabel.setEnabled(false);
    minExperimentsText.setEnabled(false);
    showAdvancedOptions(false);
    shouldFilterMinCheckbox.addActionListener(e -> {
        boolean enable = shouldFilterMinCheckbox.isSelected();
        minExperimentsLabel.setEnabled(enable);
        minExperimentsText.setEnabled(enable);
    });
    SwingUtil.makeSmall(pvalueText, qvalueText, shouldFilterMinCheckbox, nesFilterCombo, minExperimentsText);
    final GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);
    layout.setHorizontalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.TRAILING).addComponent(qvalueLabel).addComponent(pvalueLabel).addComponent(nesFilterLabel).addComponent(shouldFilterMinLabel).addComponent(minExperimentsLabel)).addGroup(layout.createParallelGroup(Alignment.LEADING).addComponent(qvalueText, PREFERRED_SIZE, 100, PREFERRED_SIZE).addComponent(pvalueText, PREFERRED_SIZE, 100, PREFERRED_SIZE).addComponent(nesFilterCombo).addComponent(shouldFilterMinCheckbox).addComponent(minExperimentsText, PREFERRED_SIZE, 100, PREFERRED_SIZE)).addGap(0, 0, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(qvalueLabel).addComponent(qvalueText)).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(pvalueLabel).addComponent(pvalueText)).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(nesFilterLabel).addComponent(nesFilterCombo)).addGroup(layout.createParallelGroup(Alignment.CENTER).addComponent(shouldFilterMinLabel).addComponent(shouldFilterMinCheckbox)).addGroup(layout.createParallelGroup(Alignment.BASELINE).addComponent(minExperimentsLabel).addComponent(minExperimentsText)).addGap(0, 0, Short.MAX_VALUE));
    if (LookAndFeelUtil.isAquaLAF())
        panel.setOpaque(false);
    return panel;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) JFormattedTextField(javax.swing.JFormattedTextField) GroupLayout(javax.swing.GroupLayout) JLabel(javax.swing.JLabel) AbstractFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory)

Example 43 with JFormattedTextField

use of javax.swing.JFormattedTextField in project EnrichmentMapApp by BaderLab.

the class PostAnalysisWeightPanel method createRankTestSelectPanel.

@SuppressWarnings("unchecked")
private JPanel createRankTestSelectPanel() {
    JLabel testLabel = new JLabel(LABEL_TEST);
    JLabel cuttofLabel = new JLabel(LABEL_CUTOFF);
    JLabel dataSetLabel = new JLabel("Data Set:");
    DecimalFormat decFormat = new DecimalFormat();
    decFormat.setParseIntegerOnly(false);
    rankTestTextField = new JFormattedTextField(decFormat);
    rankTestTextField.setColumns(6);
    rankTestTextField.setHorizontalAlignment(JTextField.RIGHT);
    rankTestTextField.addPropertyChangeListener("value", e -> {
        StringBuilder message = new StringBuilder("The value you have entered is invalid.\n");
        Number number = (Number) rankTestTextField.getValue();
        PostAnalysisFilterType filterType = getFilterType();
        Optional<Double> value = PostAnalysisInputPanel.validateAndGetFilterValue(number, filterType, message);
        double def = filterType == PostAnalysisFilterType.HYPERGEOM ? HYPERGOM_DEFAULT : filterType.defaultValue;
        savedFilterValues.put(filterType, value.orElse(def));
        if (!value.isPresent()) {
            rankTestTextField.setValue(def);
            CySwingApplication application = serviceRegistrar.getService(CySwingApplication.class);
            JOptionPane.showMessageDialog(application.getJFrame(), message.toString(), "Parameter out of bounds", JOptionPane.WARNING_MESSAGE);
        }
    });
    rankingEnablementRenderer = new EnablementComboBoxRenderer<>();
    rankTestCombo = new JComboBox<>();
    rankTestCombo.setRenderer(rankingEnablementRenderer);
    rankTestCombo.addItem(PostAnalysisFilterType.MANN_WHIT_TWO_SIDED);
    rankTestCombo.addItem(PostAnalysisFilterType.MANN_WHIT_GREATER);
    rankTestCombo.addItem(PostAnalysisFilterType.MANN_WHIT_LESS);
    rankTestCombo.addItem(PostAnalysisFilterType.HYPERGEOM);
    rankTestCombo.addItem(PostAnalysisFilterType.NUMBER);
    rankTestCombo.addItem(PostAnalysisFilterType.PERCENT);
    rankTestCombo.addItem(PostAnalysisFilterType.SPECIFIC);
    rankTestCombo.addActionListener(e -> {
        PostAnalysisFilterType filterType = (PostAnalysisFilterType) rankTestCombo.getSelectedItem();
        rankTestTextField.setValue(savedFilterValues.get(filterType));
        CardLayout cardLayout = (CardLayout) cardPanel.getLayout();
        if (filterType.isMannWhitney() && map.getAllRanks().isEmpty())
            cardLayout.show(cardPanel, "warn");
        else
            cardLayout.show(cardPanel, filterType.name());
    });
    datasetCombo = new JComboBox<>();
    // Dataset model is already initialized
    datasetModel = new DefaultComboBoxModel<>();
    datasetCombo.setModel(datasetModel);
    datasetCombo.addActionListener(e -> {
        updateUniverseSize(getDataSet());
    });
    makeSmall(testLabel, cuttofLabel, rankTestCombo, rankTestTextField);
    makeSmall(dataSetLabel, datasetCombo);
    JPanel panel = new JPanel();
    final GroupLayout layout = new GroupLayout(panel);
    panel.setLayout(layout);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(!LookAndFeelUtil.isAquaLAF());
    layout.setHorizontalGroup(layout.createParallelGroup(Alignment.CENTER, true).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.TRAILING, true).addComponent(testLabel).addComponent(cuttofLabel).addComponent(dataSetLabel)).addGroup(layout.createParallelGroup(Alignment.LEADING, true).addComponent(rankTestCombo, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE).addComponent(rankTestTextField, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE).addComponent(datasetCombo, DEFAULT_SIZE, DEFAULT_SIZE, Short.MAX_VALUE))));
    layout.setVerticalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(testLabel).addComponent(rankTestCombo, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(cuttofLabel).addComponent(rankTestTextField, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)).addPreferredGap(ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(Alignment.CENTER, false).addComponent(dataSetLabel).addComponent(datasetCombo, PREFERRED_SIZE, DEFAULT_SIZE, PREFERRED_SIZE)));
    if (LookAndFeelUtil.isAquaLAF())
        panel.setOpaque(false);
    return panel;
}
Also used : CardLayout(java.awt.CardLayout) JPanel(javax.swing.JPanel) PostAnalysisFilterType(org.baderlab.csplugins.enrichmentmap.model.PostAnalysisFilterType) CySwingApplication(org.cytoscape.application.swing.CySwingApplication) DecimalFormat(java.text.DecimalFormat) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout)

Example 44 with JFormattedTextField

use of javax.swing.JFormattedTextField in project intellij-community by JetBrains.

the class SingleIntegerFieldOptionsPanel method createIntegerFieldTrackingValue.

public static JFormattedTextField createIntegerFieldTrackingValue(@NotNull InspectionProfileEntry owner, @NotNull String property, int integerFieldColumns) {
    JFormattedTextField valueField = new JFormattedTextField();
    valueField.setColumns(integerFieldColumns);
    setupIntegerFieldTrackingValue(valueField, owner, property);
    return valueField;
}
Also used : JFormattedTextField(javax.swing.JFormattedTextField)

Example 45 with JFormattedTextField

use of javax.swing.JFormattedTextField in project pcgen by PCGen.

the class Utils method buildIntegerField.

/**
	 * <p>Builds a formatted text field with specified min and max</p>
	 * 
	 * @param min minimum value
	 * @param max maximum value
	 * @return JFormattedTextField
	 */
public static JFormattedTextField buildIntegerField(int min, int max) {
    java.text.NumberFormat numberFormat = java.text.NumberFormat.getIntegerInstance();
    NumberFormatter formatter = new NumberFormatter(numberFormat);
    formatter.setMinimum(min);
    formatter.setMaximum(max);
    final JFormattedTextField returnValue = new JFormattedTextField(formatter);
    returnValue.setColumns(3);
    returnValue.addPropertyChangeListener(new PropertyChangeListener() {

        Border m_originalBorder = returnValue.getBorder();

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName() != null && evt.getPropertyName().equals("editValid")) {
                if (evt.getNewValue() != null && evt.getNewValue() instanceof Boolean) {
                    if (((Boolean) evt.getNewValue()).booleanValue()) {
                        returnValue.setBorder(m_originalBorder);
                    } else {
                        returnValue.setBorder(BorderFactory.createLineBorder(Color.red));
                    }
                }
            }
        }
    });
    return returnValue;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) JFormattedTextField(javax.swing.JFormattedTextField) Border(javax.swing.border.Border) NumberFormatter(javax.swing.text.NumberFormatter)

Aggregations

JFormattedTextField (javax.swing.JFormattedTextField)55 JLabel (javax.swing.JLabel)17 JPanel (javax.swing.JPanel)16 ParseException (java.text.ParseException)10 DecimalFormat (java.text.DecimalFormat)9 JButton (javax.swing.JButton)9 ActionListener (java.awt.event.ActionListener)8 NumberFormatter (javax.swing.text.NumberFormatter)8 ActionEvent (java.awt.event.ActionEvent)7 PropertyChangeEvent (java.beans.PropertyChangeEvent)7 JComboBox (javax.swing.JComboBox)7 Dimension (java.awt.Dimension)6 PropertyChangeListener (java.beans.PropertyChangeListener)6 GroupLayout (javax.swing.GroupLayout)6 Component (java.awt.Component)5 GridBagConstraints (java.awt.GridBagConstraints)5 GridBagLayout (java.awt.GridBagLayout)5 JCheckBox (javax.swing.JCheckBox)5 JScrollPane (javax.swing.JScrollPane)5 JSpinner (javax.swing.JSpinner)5