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;
}
};
}
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;
}
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)));
}
Aggregations