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