|
12 | 12 | import java.awt.GridBagLayout;
|
13 | 13 | import java.awt.event.ActionListener;
|
14 | 14 | import java.text.DecimalFormat;
|
| 15 | +import java.text.ParseException; |
15 | 16 | import java.util.ArrayList;
|
16 | 17 | import java.util.Arrays;
|
17 | 18 | import java.util.Collections;
|
@@ -67,6 +68,9 @@ public class PAWeightPanel extends JPanel {
|
67 | 68 |
|
68 | 69 | private static final double HYPERGOM_DEFAULT = 0.25;
|
69 | 70 |
|
| 71 | + private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat(); |
| 72 | + |
| 73 | + |
70 | 74 | @Inject private IconManager iconManager;
|
71 | 75 |
|
72 | 76 | private final EnrichmentMap map;
|
@@ -212,19 +216,18 @@ private JPanel createRankTestSelectPanel() {
|
212 | 216 | JLabel cuttofLabel = new JLabel(LABEL_CUTOFF);
|
213 | 217 | JLabel dataSetLabel = new JLabel("Data Set:");
|
214 | 218 |
|
215 |
| - DecimalFormat decFormat = new DecimalFormat(); |
216 |
| - decFormat.setParseIntegerOnly(false); |
217 |
| - rankTestTextField = new JFormattedTextField(decFormat); |
| 219 | + DECIMAL_FORMAT.setParseIntegerOnly(false); |
| 220 | + rankTestTextField = new JFormattedTextField(DECIMAL_FORMAT); |
218 | 221 | rankTestTextField.setColumns(6);
|
219 | 222 | rankTestTextField.setHorizontalAlignment(JTextField.RIGHT);
|
220 | 223 | rankTestTextField.addPropertyChangeListener("value", e -> {
|
221 | 224 | String text = rankTestTextField.getText();
|
222 | 225 | try {
|
223 |
| - double val = Double.parseDouble(text); |
| 226 | + double val = DECIMAL_FORMAT.parse(text).doubleValue(); |
224 | 227 | PostAnalysisFilterType filterType = getFilterType();
|
225 | 228 | savedFilterValues.put(filterType, val);
|
226 | 229 | showWarning(filterType.isValid(val) ? null : filterType.getErrorMessage());
|
227 |
| - } catch(NumberFormatException ex) { |
| 230 | + } catch(ParseException ex) { |
228 | 231 | showWarning("Not a number");
|
229 | 232 | }
|
230 | 233 |
|
@@ -648,7 +651,13 @@ public FilterMetricSet getResults() {
|
648 | 651 |
|
649 | 652 | public FilterMetric createFilterMetric(String datasetName) {
|
650 | 653 | String text = rankTestTextField.getText();
|
651 |
| - double value = Double.parseDouble(text); |
| 654 | + double value; |
| 655 | + try { |
| 656 | + value = DECIMAL_FORMAT.parse(text).doubleValue(); |
| 657 | + } catch (ParseException e) { |
| 658 | + return null; |
| 659 | + } |
| 660 | + |
652 | 661 | PostAnalysisFilterType type = getFilterType();
|
653 | 662 |
|
654 | 663 | switch(type) {
|
|
0 commit comments