Search in sources :

Example 1 with AbstractFormatterFactory

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

the class CutoffPropertiesPanel method getFormatterFactory.

private static AbstractFormatterFactory getFormatterFactory(boolean scientific) {
    return new AbstractFormatterFactory() {

        @Override
        public AbstractFormatter getFormatter(JFormattedTextField tf) {
            NumberFormat format = scientific ? new DecimalFormat("0.######E00") : new DecimalFormat();
            format.setMinimumFractionDigits(scientific ? 0 : 1);
            format.setMaximumFractionDigits(12);
            InternationalFormatter formatter = new InternationalFormatter(format);
            formatter.setAllowsInvalid(true);
            return formatter;
        }
    };
}
Also used : DecimalFormat(java.text.DecimalFormat) InternationalFormatter(javax.swing.text.InternationalFormatter) JFormattedTextField(javax.swing.JFormattedTextField) AbstractFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory) NumberFormat(java.text.NumberFormat)

Example 2 with AbstractFormatterFactory

use of javax.swing.JFormattedTextField.AbstractFormatterFactory 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 3 with AbstractFormatterFactory

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

the class CutoffPropertiesPanel method createContents.

@AfterInjection
public void createContents() {
    cutoffValues = new EnumMap<>(SimilarityMetric.class);
    cutoffValues.put(SimilarityMetric.JACCARD, propertyManager.getDefaultCutOff(SimilarityMetric.JACCARD));
    cutoffValues.put(SimilarityMetric.OVERLAP, propertyManager.getDefaultCutOff(SimilarityMetric.OVERLAP));
    cutoffValues.put(SimilarityMetric.COMBINED, propertyManager.getDefaultCutOff(SimilarityMetric.COMBINED));
    setBorder(LookAndFeelUtil.createPanelBorder());
    JPanel filterNodesPanel = createFilterNodesPanel();
    JPanel filterEdgesPanel = createFilterEdgesPanel();
    notationCheckBox = new JCheckBox("Scientific Notation");
    notationCheckBox.addActionListener(e -> {
        boolean scientific = notationCheckBox.isSelected();
        AbstractFormatterFactory factory = getFormatterFactory(scientific);
        pvalueText.setFormatterFactory(factory);
        qvalueText.setFormatterFactory(factory);
        similarityCutoffText.setFormatterFactory(factory);
    });
    advancedCheckBox = new JCheckBox("Show Advanced Options");
    advancedCheckBox.addActionListener(e -> showAdvancedOptions(advancedCheckBox.isSelected()));
    SwingUtil.makeSmall(notationCheckBox, advancedCheckBox);
    final GroupLayout layout = new GroupLayout(this);
    setLayout(layout);
    layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);
    layout.setHorizontalGroup(layout.createParallelGroup().addGroup(layout.createSequentialGroup().addComponent(filterNodesPanel).addComponent(filterEdgesPanel)).addGroup(layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addComponent(notationCheckBox).addGap(10).addComponent(advancedCheckBox)));
    layout.setVerticalGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup().addComponent(filterNodesPanel).addComponent(filterEdgesPanel)).addGroup(layout.createParallelGroup().addComponent(notationCheckBox).addComponent(advancedCheckBox)));
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) GroupLayout(javax.swing.GroupLayout) SimilarityMetric(org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric) AbstractFormatterFactory(javax.swing.JFormattedTextField.AbstractFormatterFactory) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection)

Aggregations

AbstractFormatterFactory (javax.swing.JFormattedTextField.AbstractFormatterFactory)3 GroupLayout (javax.swing.GroupLayout)2 JCheckBox (javax.swing.JCheckBox)2 JFormattedTextField (javax.swing.JFormattedTextField)2 JPanel (javax.swing.JPanel)2 DecimalFormat (java.text.DecimalFormat)1 NumberFormat (java.text.NumberFormat)1 JLabel (javax.swing.JLabel)1 InternationalFormatter (javax.swing.text.InternationalFormatter)1 AfterInjection (org.baderlab.csplugins.enrichmentmap.AfterInjection)1 SimilarityMetric (org.baderlab.csplugins.enrichmentmap.model.EMCreationParameters.SimilarityMetric)1