- Timestamp:
- 2016-01-24T11:25:55+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/projection/CodeProjectionChoice.java
r9078 r9609 67 67 68 68 /** 69 * Comparator that compares the number part of the code numerically.70 */71 private static class CodeComparator implements Comparator<String>, Serializable {72 private static final long serialVersionUID = 1L;73 private final Pattern codePattern = Pattern.compile("([a-zA-Z]+):(\\d+)");74 75 @Override76 public int compare(String c1, String c2) {77 Matcher matcher1 = codePattern.matcher(c1);78 Matcher matcher2 = codePattern.matcher(c2);79 if (matcher1.matches()) {80 if (matcher2.matches()) {81 int cmp1 = matcher1.group(1).compareTo(matcher2.group(1));82 if (cmp1 != 0) return cmp1;83 int num1 = Integer.parseInt(matcher1.group(2));84 int num2 = Integer.parseInt(matcher2.group(2));85 return Integer.compare(num1, num2);86 } else87 return -1;88 } else if (matcher2.matches())89 return 1;90 return c1.compareTo(c2);91 }92 }93 94 /**95 69 * List model for the filtered view on the list of all codes. 96 70 */ … … 186 160 } 187 161 162 /** 163 * Comparator that compares the number part of the code numerically. 164 */ 165 public static class CodeComparator implements Comparator<String>, Serializable { 166 private static final long serialVersionUID = 1L; 167 private final Pattern codePattern = Pattern.compile("([a-zA-Z]+):(\\d+)"); 168 169 @Override 170 public int compare(String c1, String c2) { 171 Matcher matcher1 = codePattern.matcher(c1); 172 Matcher matcher2 = codePattern.matcher(c2); 173 if (matcher1.matches()) { 174 if (matcher2.matches()) { 175 int cmp1 = matcher1.group(1).compareTo(matcher2.group(1)); 176 if (cmp1 != 0) return cmp1; 177 int num1 = Integer.parseInt(matcher1.group(2)); 178 int num2 = Integer.parseInt(matcher2.group(2)); 179 return Integer.compare(num1, num2); 180 } else 181 return -1; 182 } else if (matcher2.matches()) 183 return 1; 184 return c1.compareTo(c2); 185 } 186 } 187 188 188 @Override 189 189 public Projection getProjection() {
Note:
See TracChangeset
for help on using the changeset viewer.