Changeset 8510 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2015-06-20T23:42:21+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 126 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/APIDataSet.java
r8365 r8510 217 217 * @throws CyclicUploadDependencyException if a cyclic dependency is detected 218 218 */ 219 public void adjustRelationUploadOrder() throws CyclicUploadDependencyException{ 219 public void adjustRelationUploadOrder() throws CyclicUploadDependencyException { 220 220 List<OsmPrimitive> newToAdd = new LinkedList<>(); 221 221 newToAdd.addAll(Utils.filteredCollection(toAdd, Node.class)); … … 283 283 public final void build(Collection<Relation> relations) { 284 284 this.relations = new HashSet<>(); 285 for(Relation relation: relations) { 285 for (Relation relation: relations) { 286 286 if (newOrUndeleted ? !relation.isNewOrUndeleted() : !relation.isDeleted()) { 287 287 continue; … … 290 290 for (RelationMember m: relation.getMembers()) { 291 291 if (m.isRelation() && (newOrUndeleted ? m.getMember().isNewOrUndeleted() : m.getMember().isDeleted())) { 292 addDependency(relation, (Relation)m.getMember()); 292 addDependency(relation, (Relation) m.getMember()); 293 293 } 294 294 } … … 309 309 } 310 310 311 protected void visit(Stack<Relation> path, Relation current) throws CyclicUploadDependencyException{ 311 protected void visit(Stack<Relation> path, Relation current) throws CyclicUploadDependencyException { 312 312 if (path.contains(current)) { 313 313 path.push(current); … … 318 318 visited.add(current); 319 319 for (Relation dependent : getChildren(current)) { 320 visit(path,dependent); 320 visit(path, dependent); 321 321 } 322 322 uploadOrder.add(current); -
trunk/src/org/openstreetmap/josm/data/Bounds.java
r8509 r8510 179 179 MessageFormat.format("Exactly four doubles expected in string, got {0}: {1}", components.length, asString)); 180 180 double[] values = new double[4]; 181 for (int i =0; i<4; i++) {181 for (int i = 0; i < 4; i++) { 182 182 try { 183 183 values[i] = Double.parseDouble(components[i]); 184 } catch(NumberFormatException e) { 184 } catch (NumberFormatException e) { 185 185 throw new IllegalArgumentException(MessageFormat.format("Illegal double value ''{0}''", components[i]), e); 186 186 } … … 281 281 double lat = (minLat + maxLat) / 2; 282 282 double lon = (minLon + maxLon - 360.0) / 2; 283 if (lon < -180.0){ 283 if (lon < -180.0) { 284 284 lon += 360.0; 285 285 } -
trunk/src/org/openstreetmap/josm/data/CustomConfigurator.java
r8509 r8510 93 93 */ 94 94 public static void readXML(final File file, final Preferences prefs) { 95 synchronized(CustomConfigurator.class) { 96 busy =true;95 synchronized (CustomConfigurator.class) { 96 busy = true; 97 97 } 98 98 new XMLCommandProcessor(prefs).openAndReadXML(file); 99 synchronized(CustomConfigurator.class) { 99 synchronized (CustomConfigurator.class) { 100 100 CustomConfigurator.class.notifyAll(); 101 busy =false;101 busy = false; 102 102 } 103 103 } … … 159 159 */ 160 160 public static void messageBox(String type, String text) { 161 if (type ==null || type.isEmpty()) type="plain";161 if (type == null || type.isEmpty()) type = "plain"; 162 162 163 163 switch (type.charAt(0)) { … … 186 186 JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, 2); 187 187 } 188 if (answer ==null) return -1; else return answer;188 if (answer == null) return -1; else return answer; 189 189 } 190 190 191 191 public static String askForText(String text) { 192 192 String s = JOptionPane.showInputDialog(Main.parent, text, tr("Enter text"), JOptionPane.QUESTION_MESSAGE); 193 if (s !=null && !(s=s.trim()).isEmpty()) {193 if (s != null && !(s = s.trim()).isEmpty()) { 194 194 return s; 195 195 } else { … … 253 253 Main.warn("Error getting preferences to save:" +ex.getMessage()); 254 254 } 255 if (root ==null) return;255 if (root == null) return; 256 256 try { 257 257 … … 260 260 261 261 Element prefElem = exportDocument.createElement("preferences"); 262 prefElem.setAttribute("operation", append ?"append":"replace");262 prefElem.setAttribute("operation", append ? "append" : "replace"); 263 263 newRoot.appendChild(prefElem); 264 264 … … 287 287 public static void deleteFile(String path, String base) { 288 288 String dir = getDirectoryByAbbr(base); 289 if (dir ==null) {289 if (dir == null) { 290 290 log("Error: Can not find base, use base=cache, base=prefs or base=plugins attribute."); 291 291 return; … … 321 321 } 322 322 323 private static boolean busy =false;323 private static boolean busy = false; 324 324 325 325 public static void pluginOperation(String install, String uninstall, String delete) { … … 387 387 new File(Main.pref.getPluginsDirectory(), pi.name+".jar").deleteOnExit(); 388 388 } 389 Main.pref.putCollection("plugins",pls); 389 Main.pref.putCollection("plugins", pls); 390 390 } 391 391 }); … … 423 423 424 424 private Preferences mainPrefs; 425 private Map<String,Element> tasksMap = new HashMap<>(); 425 private Map<String, Element> tasksMap = new HashMap<>(); 426 426 427 427 private boolean lastV; // last If condition result … … 433 433 try { 434 434 String fileDir = file.getParentFile().getAbsolutePath(); 435 if (fileDir !=null) engine.eval("scriptDir='"+normalizeDirName(fileDir) +"';");435 if (fileDir != null) engine.eval("scriptDir='"+normalizeDirName(fileDir) +"';"); 436 436 try (InputStream is = new BufferedInputStream(new FileInputStream(file))) { 437 437 openAndReadXML(is); … … 599 599 String base = evalVars(item.getAttribute("base")); 600 600 String dir = getDirectoryByAbbr(base); 601 if (dir ==null) {601 if (dir == null) { 602 602 log("Error: Can not find directory to place file, use base=cache, base=prefs or base=plugins attribute."); 603 603 return; … … 624 624 String text = evalVars(elem.getAttribute("text")); 625 625 String locText = evalVars(elem.getAttribute(LanguageInfo.getJOSMLocaleCode()+".text")); 626 if (locText !=null && !locText.isEmpty()) text=locText;626 if (locText != null && !locText.isEmpty()) text = locText; 627 627 628 628 String type = evalVars(elem.getAttribute("type")); … … 633 633 String text = evalVars(elem.getAttribute("text")); 634 634 String locText = evalVars(elem.getAttribute(LanguageInfo.getJOSMLocaleCode()+".text")); 635 if (!locText.isEmpty()) text =locText;635 if (!locText.isEmpty()) text = locText; 636 636 String var = elem.getAttribute("var"); 637 if (var.isEmpty()) var ="result";637 if (var.isEmpty()) var = "result"; 638 638 639 639 String input = evalVars(elem.getAttribute("input")); … … 643 643 String opts = evalVars(elem.getAttribute("options")); 644 644 String locOpts = evalVars(elem.getAttribute(LanguageInfo.getJOSMLocaleCode()+".options")); 645 if (!locOpts.isEmpty()) opts =locOpts;645 if (!locOpts.isEmpty()) opts = locOpts; 646 646 setVar(var, String.valueOf(askForOption(text, opts))); 647 647 } … … 678 678 String taskName = elem.getAttribute("name"); 679 679 Element task = tasksMap.get(taskName); 680 if (task !=null) {680 if (task != null) { 681 681 log("EXECUTING TASK "+taskName); 682 682 processXmlFragment(task); // process task recursively … … 728 728 xformer.transform(new DOMSource(item), out); 729 729 730 String fragmentWithReplacedVars= evalVars(outputWriter.toString()); 730 String fragmentWithReplacedVars = evalVars(outputWriter.toString()); 731 731 732 732 CharArrayReader reader = new CharArrayReader(fragmentWithReplacedVars.toCharArray()); … … 741 741 private String normalizeDirName(String dir) { 742 742 String s = dir.replace("\\", "/"); 743 if (s.endsWith("/")) s =s.substring(0,s.length()-1);743 if (s.endsWith("/")) s = s.substring(0, s.length()-1); 744 744 return s; 745 745 } … … 938 938 JOptionPane.showMessageDialog( 939 939 Main.parent, 940 tr("<html>Settings file asks to append preferences to <b>{0}</b>,<br/> but its default value is unknown at this moment.<br/> Please activate corresponding function manually and retry importing.", key), 940 tr("<html>Settings file asks to append preferences to <b>{0}</b>,<br/> "+ 941 "but its default value is unknown at this moment.<br/> " + 942 "Please activate corresponding function manually and retry importing.", key), 941 943 tr("Warning"), 942 944 JOptionPane.WARNING_MESSAGE); … … 1011 1013 Map<String, List<Collection<String>>> listlistMap = (SortedMap<String, List<Collection<String>>>) engine.get("listlistMap"); 1012 1014 @SuppressWarnings("unchecked") 1013 Map<String, List<Map<String, String>>> listmapMap = (SortedMap<String, List<Map<String,String>>>) engine.get("listmapMap"); 1015 Map<String, List<Map<String, String>>> listmapMap = (SortedMap<String, List<Map<String, String>>>) engine.get("listmapMap"); 1014 1016 1015 1017 tmpPref.settingsMap.clear(); … … 1025 1027 for (Entry<String, List<Collection<String>>> e : listlistMap.entrySet()) { 1026 1028 @SuppressWarnings("unchecked") 1027 List<List<String>> value = (List)e.getValue(); 1029 List<List<String>> value = (List) e.getValue(); 1028 1030 tmp.put(e.getKey(), new ListListSetting(value)); 1029 1031 } -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r8509 r8510 194 194 this.value = value; 195 195 } 196 196 197 @Override 197 198 public T getValue() { 198 199 return value; 199 200 } 201 200 202 @Override 201 203 public String toString() { 202 204 return value != null ? value.toString() : "null"; 203 205 } 206 204 207 @Override 205 208 public int hashCode() { … … 209 212 return result; 210 213 } 214 211 215 @Override 212 216 public boolean equals(Object obj) { … … 238 242 super(value); 239 243 } 240 @Override public boolean equalVal(String otherVal) { 244 245 @Override 246 public boolean equalVal(String otherVal) { 241 247 if (value == null) return otherVal == null; 242 248 return value.equals(otherVal); 243 249 } 244 @Override public StringSetting copy() { 250 251 @Override 252 public StringSetting copy() { 245 253 return new StringSetting(value); 246 254 } 247 @Override public void visit(SettingVisitor visitor) { 255 256 @Override 257 public void visit(SettingVisitor visitor) { 248 258 visitor.visit(this); 249 259 } 250 @Override public StringSetting getNullInstance() { 260 261 @Override 262 public StringSetting getNullInstance() { 251 263 return new StringSetting(null); 252 264 } 265 253 266 @Override 254 267 public boolean equals(Object other) { … … 270 283 consistencyTest(); 271 284 } 285 272 286 /** 273 287 * Convenience factory method. … … 278 292 return new ListSetting(value == null ? null : Collections.unmodifiableList(new ArrayList<>(value))); 279 293 } 280 @Override public boolean equalVal(List<String> otherVal) { 294 295 @Override 296 public boolean equalVal(List<String> otherVal) { 281 297 return equalCollection(value, otherVal); 282 298 } 299 283 300 public static boolean equalCollection(Collection<String> a, Collection<String> b) { 284 301 if (a == null) return b == null; … … 290 307 String aStr = itA.next(); 291 308 String bStr = itB.next(); 292 if (!Objects.equals(aStr,bStr)) return false; 309 if (!Objects.equals(aStr, bStr)) return false; 293 310 } 294 311 return true; 295 312 } 296 @Override public ListSetting copy() { 313 314 @Override 315 public ListSetting copy() { 297 316 return ListSetting.create(value); 298 317 } 318 299 319 private void consistencyTest() { 300 320 if (value != null && value.contains(null)) 301 321 throw new RuntimeException("Error: Null as list element in preference setting"); 302 322 } 303 @Override public void visit(SettingVisitor visitor) { 323 324 @Override 325 public void visit(SettingVisitor visitor) { 304 326 visitor.visit(this); 305 327 } 306 @Override public ListSetting getNullInstance() { 328 329 @Override 330 public ListSetting getNullInstance() { 307 331 return new ListSetting(null); 308 332 } 333 309 334 @Override 310 335 public boolean equals(Object other) { … … 470 495 public interface SettingVisitor { 471 496 void visit(StringSetting setting); 497 472 498 void visit(ListSetting value); 499 473 500 void visit(ListListSetting value); 501 474 502 void visit(MapListSetting value); 475 503 } … … 477 505 public interface PreferenceChangeEvent { 478 506 String getKey(); 507 479 508 Setting<?> getOldValue(); 509 480 510 Setting<?> getNewValue(); 481 511 } … … 514 544 public interface ColorKey { 515 545 String getColorName(); 546 516 547 String getSpecialName(); 548 517 549 Color getDefaultValue(); 518 550 } … … 707 739 708 740 public synchronized Map<String, String> getAllPrefix(final String prefix) { 709 final Map<String,String> all = new TreeMap<>(); 710 for (final Entry<String,Setting<?>> e : settingsMap.entrySet()) { 741 final Map<String, String> all = new TreeMap<>(); 742 for (final Entry<String, Setting<?>> e : settingsMap.entrySet()) { 711 743 if (e.getKey().startsWith(prefix) && (e.getValue() instanceof StringSetting)) { 712 744 all.put(e.getKey(), ((StringSetting) e.getValue()).getValue()); … … 727 759 728 760 public synchronized Map<String, String> getAllColors() { 729 final Map<String,String> all = new TreeMap<>(); 730 for (final Entry<String,Setting<?>> e : defaultsMap.entrySet()) { 761 final Map<String, String> all = new TreeMap<>(); 762 for (final Entry<String, Setting<?>> e : defaultsMap.entrySet()) { 731 763 if (e.getKey().startsWith("color.") && e.getValue() instanceof StringSetting) { 732 764 StringSetting d = (StringSetting) e.getValue(); … … 736 768 } 737 769 } 738 for (final Entry<String,Setting<?>> e : settingsMap.entrySet()) { 770 for (final Entry<String, Setting<?>> e : settingsMap.entrySet()) { 739 771 if (e.getKey().startsWith("color.") && (e.getValue() instanceof StringSetting)) { 740 772 all.put(e.getKey().substring(6), ((StringSetting) e.getValue()).getValue()); … … 758 790 Setting<?> prop = settingsMap.get(skey); 759 791 if (prop instanceof StringSetting) 760 return Boolean.parseBoolean(((StringSetting)prop).getValue()); 792 return Boolean.parseBoolean(((StringSetting) prop).getValue()); 761 793 else 762 794 return generic; … … 771 803 */ 772 804 public boolean put(final String key, String value) { 773 if(value != null && value.isEmpty()) { 805 if (value != null && value.isEmpty()) { 774 806 value = null; 775 807 } … … 870 902 File prefDir = getPreferencesDirectory(); 871 903 if (prefDir.exists()) { 872 if(!prefDir.isDirectory()) { 904 if (!prefDir.isDirectory()) { 873 905 Main.warn(tr("Failed to initialize preferences. Preference directory ''{0}'' is not a directory.", 874 906 prefDir.getAbsoluteFile())); … … 908 940 save(); 909 941 } 910 } catch(IOException e) { 942 } catch (IOException e) { 911 943 Main.error(e); 912 944 JOptionPane.showMessageDialog( … … 923 955 } catch (Exception e) { 924 956 Main.error(e); 925 File backupFile = new File(prefDir,"preferences.xml.bak"); 957 File backupFile = new File(prefDir, "preferences.xml.bak"); 926 958 JOptionPane.showMessageDialog( 927 959 Main.parent, 928 tr("<html>Preferences file had errors.<br> Making backup of old one to <br>{0}<br> and creating a new default preference file.</html>", 960 tr("<html>Preferences file had errors.<br> Making backup of old one to <br>{0}<br> " + 961 "and creating a new default preference file.</html>", 929 962 backupFile.getAbsoluteFile()), 930 963 tr("Error"), … … 935 968 resetToDefault(); 936 969 save(); 937 } catch(IOException e1) { 970 } catch (IOException e1) { 938 971 Main.error(e1); 939 972 Main.warn(tr("Failed to initialize preferences. Failed to reset preference file to default: {0}", getPreferenceFile())); … … 942 975 } 943 976 944 public final void resetToDefault(){ 977 public final void resetToDefault() { 945 978 settingsMap.clear(); 946 979 } … … 1001 1034 public synchronized Color getColor(String colName, String specName, Color def) { 1002 1035 String colKey = ColorProperty.getColorKey(colName); 1003 if(!colKey.equals(colName)) { 1036 if (!colKey.equals(colName)) { 1004 1037 colornames.put(colKey, colName); 1005 1038 } … … 1027 1060 public synchronized int getInteger(String key, int def) { 1028 1061 String v = get(key, Integer.toString(def)); 1029 if(v.isEmpty()) 1062 if (v.isEmpty()) 1030 1063 return def; 1031 1064 1032 1065 try { 1033 1066 return Integer.parseInt(v); 1034 } catch(NumberFormatException e) { 1067 } catch (NumberFormatException e) { 1035 1068 // fall out 1036 1069 } … … 1040 1073 public synchronized int getInteger(String key, String specName, int def) { 1041 1074 String v = get(key+"."+specName); 1042 if(v.isEmpty()) 1043 v = get(key,Integer.toString(def)); 1044 if(v.isEmpty()) 1075 if (v.isEmpty()) 1076 v = get(key, Integer.toString(def)); 1077 if (v.isEmpty()) 1045 1078 return def; 1046 1079 1047 1080 try { 1048 1081 return Integer.parseInt(v); 1049 } catch(NumberFormatException e) { 1082 } catch (NumberFormatException e) { 1050 1083 // fall out 1051 1084 } … … 1055 1088 public synchronized long getLong(String key, long def) { 1056 1089 String v = get(key, Long.toString(def)); 1057 if(null == v) 1090 if (null == v) 1058 1091 return def; 1059 1092 1060 1093 try { 1061 1094 return Long.parseLong(v); 1062 } catch(NumberFormatException e) { 1095 } catch (NumberFormatException e) { 1063 1096 // fall out 1064 1097 } … … 1068 1101 public synchronized double getDouble(String key, double def) { 1069 1102 String v = get(key, Double.toString(def)); 1070 if(null == v) 1103 if (null == v) 1071 1104 return def; 1072 1105 1073 1106 try { 1074 1107 return Double.parseDouble(v); 1075 } catch(NumberFormatException e) { 1108 } catch (NumberFormatException e) { 1076 1109 // fall out 1077 1110 } … … 1139 1172 try { 1140 1173 save(); 1141 } catch (IOException e){ 1174 } catch (IOException e) { 1142 1175 Main.warn(tr("Failed to persist preferences to ''{0}''", getPreferenceFile().getAbsoluteFile())); 1143 1176 } … … 1253 1286 */ 1254 1287 public <T> List<T> getListOfStructs(String key, Collection<T> def, Class<T> klass) { 1255 Collection<Map<String,String>> prop = 1288 Collection<Map<String, String>> prop = 1256 1289 getListOfStructs(key, def == null ? null : serializeListOfStructs(def, klass)); 1257 1290 if (prop == null) 1258 1291 return def == null ? null : new ArrayList<>(def); 1259 1292 List<T> lst = new ArrayList<>(); 1260 for (Map<String,String> entries : prop) { 1293 for (Map<String, String> entries : prop) { 1261 1294 T struct = deserializeStruct(entries, klass); 1262 1295 lst.add(struct); … … 1282 1315 } 1283 1316 1284 private <T> Collection<Map<String,String>> serializeListOfStructs(Collection<T> l, Class<T> klass) { 1317 private <T> Collection<Map<String, String>> serializeListOfStructs(Collection<T> l, Class<T> klass) { 1285 1318 if (l == null) 1286 1319 return null; 1287 Collection<Map<String,String>> vals = new ArrayList<>(); 1320 Collection<Map<String, String>> vals = new ArrayList<>(); 1288 1321 for (T struct : l) { 1289 1322 if (struct == null) { … … 1300 1333 try (JsonWriter writer = Json.createWriter(stringWriter)) { 1301 1334 JsonObjectBuilder object = Json.createObjectBuilder(); 1302 for(Object o: map.entrySet()) { 1335 for (Object o: map.entrySet()) { 1303 1336 Entry e = (Entry) o; 1304 1337 object.add(e.getKey().toString(), e.getValue().toString()); … … 1322 1355 } 1323 1356 1324 public static <T> Map<String,String> serializeStruct(T struct, Class<T> klass) { 1357 public static <T> Map<String, String> serializeStruct(T struct, Class<T> klass) { 1325 1358 T structPrototype; 1326 1359 try { … … 1330 1363 } 1331 1364 1332 Map<String,String> hash = new LinkedHashMap<>(); 1365 Map<String, String> hash = new LinkedHashMap<>(); 1333 1366 for (Field f : klass.getDeclaredFields()) { 1334 1367 if (f.getAnnotation(pref.class) == null) { … … 1356 1389 } 1357 1390 1358 public static <T> T deserializeStruct(Map<String,String> hash, Class<T> klass) { 1391 public static <T> T deserializeStruct(Map<String, String> hash, Class<T> klass) { 1359 1392 T struct = null; 1360 1393 try { … … 1363 1396 throw new RuntimeException(ex); 1364 1397 } 1365 for (Entry<String,String> key_value : hash.entrySet()) { 1398 for (Entry<String, String> key_value : hash.entrySet()) { 1366 1399 Object value = null; 1367 1400 Field f; … … 1422 1455 */ 1423 1456 public void updateSystemProperties() { 1424 if("true".equals(get("prefer.ipv6", "auto"))) { 1457 if ("true".equals(get("prefer.ipv6", "auto"))) { 1425 1458 // never set this to false, only true! 1426 if(!"true".equals(Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true"))) { 1459 if (!"true".equals(Utils.updateSystemProperty("java.net.preferIPv6Addresses", "true"))) { 1427 1460 Main.info(tr("Try enabling IPv6 network, prefering IPv6 over IPv4 (only works on early startup).")); 1428 1461 } … … 1750 1783 // update old style JOSM server links to use zip now, see #10581 1751 1784 // actually also cache and mirror entries should be cleared 1752 if(getInteger("josm.version", Version.getInstance().getVersion()) < 8099) { 1753 for(String key: new String[]{"mappaint.style.entries", "taggingpreset.entries"}) { 1785 if (getInteger("josm.version", Version.getInstance().getVersion()) < 8099) { 1786 for (String key: new String[]{"mappaint.style.entries", "taggingpreset.entries"}) { 1754 1787 Collection<Map<String, String>> data = getListOfStructs(key, (Collection<Map<String, String>>) null); 1755 1788 if (data != null) { 1756 1789 List<Map<String, String>> newlist = new ArrayList<Map<String, String>>(); 1757 1790 boolean modified = false; 1758 for(Map<String, String> map : data) { 1791 for (Map<String, String> map : data) { 1759 1792 Map<String, String> newmap = new LinkedHashMap<String, String>(); 1760 1793 for (Entry<String, String> entry : map.entrySet()) { -
trunk/src/org/openstreetmap/josm/data/SystemOfMeasurement.java
r7937 r8510 14 14 * A system of units used to express length and area measurements. 15 15 * @since 3406 (creation) 16 * @since 6992 (extraction in this package) 16 * @since 6992 (extraction in this package) 17 17 */ 18 18 public class SystemOfMeasurement { … … 41 41 */ 42 42 public static final SystemOfMeasurement NAUTICAL_MILE = new SystemOfMeasurement(185.2, "kbl", 1852, "NM"); 43 43 44 44 /** 45 45 * Known systems of measurement. … … 54 54 ALL_SYSTEMS.put(marktr("Nautical Mile"), NAUTICAL_MILE); 55 55 } 56 56 57 57 /** First value, in meters, used to translate unit according to above formula. */ 58 58 public final double aValue; … … 173 173 return format.format(v) + " " + unit; 174 174 } 175 return String.format(Locale.US, "%." + (v <9.999999 ? 2 : 1) + "f %s", v, unit);175 return String.format(Locale.US, "%." + (v < 9.999999 ? 2 : 1) + "f %s", v, unit); 176 176 } 177 177 } -
trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r8413 r8510 88 88 Main.main.getCurrentDataSet().beginUpdate(); 89 89 try { 90 for (int i =1; i<=num; ++i) {90 for (int i = 1; i <= num; ++i) { 91 91 final Command c = commands.removeLast(); 92 92 c.undoCommand(); … … 121 121 return; 122 122 Collection<? extends OsmPrimitive> oldSelection = Main.main.getCurrentDataSet().getSelected(); 123 for (int i =0; i<num; ++i) {123 for (int i = 0; i < num; ++i) { 124 124 final Command c = redoCommands.removeFirst(); 125 125 c.executeCommand(); -
trunk/src/org/openstreetmap/josm/data/Version.java
r8390 r8510 109 109 try { 110 110 version = Integer.parseInt(value); 111 } catch(NumberFormatException e) { 111 } catch (NumberFormatException e) { 112 112 version = 0; 113 113 Main.warn(tr("Unexpected JOSM version number in revision file, value is ''{0}''", value)); … … 143 143 // 144 144 StringBuilder sb = new StringBuilder(); 145 for(Entry<String,String> property: properties.entrySet()) { 145 for (Entry<String, String> property: properties.entrySet()) { 146 146 sb.append(property.getKey()).append(':').append(property.getValue()).append('\n'); 147 147 } -
trunk/src/org/openstreetmap/josm/data/cache/BufferedImageCacheEntry.java
r8488 r8510 42 42 if (imageLoaded) 43 43 return img; 44 synchronized(this) { 44 synchronized (this) { 45 45 if (imageLoaded) 46 46 return img; … … 57 57 return img; 58 58 } 59 60 59 61 60 private void writeObject(java.io.ObjectOutputStream out) throws IOException { … … 81 80 synchronized (this) { 82 81 if (content == null && img != null) { 83 throw new AssertionError("Trying to serialize (save to disk?) an BufferedImageCacheEntry that was converted to BufferedImage and no raw data is present anymore"); 82 throw new AssertionError("Trying to serialize (save to disk?) an BufferedImageCacheEntry " + 83 "that was converted to BufferedImage and no raw data is present anymore"); 84 84 } 85 85 out.writeObject(this); … … 90 90 content = null; 91 91 } 92 93 92 } 94 93 } -
trunk/src/org/openstreetmap/josm/data/cache/CacheEntryAttributes.java
r8421 r8510 75 75 */ 76 76 public void setEtag(String etag) { 77 if(etag != null) { 77 if (etag != null) { 78 78 attrs.put(ETAG, etag); 79 79 } -
trunk/src/org/openstreetmap/josm/data/cache/HostLimitQueue.java
r8418 r8510 95 95 Semaphore limit = hostSemaphores.get(host); 96 96 if (limit == null) { 97 synchronized(hostSemaphores) { 97 synchronized (hostSemaphores) { 98 98 limit = hostSemaphores.get(host); 99 99 if (limit == null) { … … 122 122 } 123 123 124 125 private boolean tryAcquireSemaphore(final JCSCachedTileLoaderJob<?,?> job) { 124 private boolean tryAcquireSemaphore(final JCSCachedTileLoaderJob<?, ?> job) { 126 125 boolean ret = true; 127 126 Semaphore limit = getSemaphore(job); … … 140 139 } 141 140 142 private void releaseSemaphore(JCSCachedTileLoaderJob<?,?> job) { 141 private void releaseSemaphore(JCSCachedTileLoaderJob<?, ?> job) { 143 142 Semaphore limit = getSemaphore(job); 144 143 if (limit != null) { -
trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
r8509 r8510 123 123 * @throws IOException if directory is not found 124 124 */ 125 public static <K,V> CacheAccess<K, V> getCache(String cacheName) throws IOException { 125 public static <K, V> CacheAccess<K, V> getCache(String cacheName) throws IOException { 126 126 return getCache(cacheName, DEFAULT_MAX_OBJECTS_IN_MEMORY.get().intValue(), 0, null); 127 127 } … … 136 136 * @throws IOException if directory is not found 137 137 */ 138 public static <K,V> CacheAccess<K, V> getCache(String cacheName, int maxMemoryObjects, int maxDiskObjects, String cachePath) throws IOException { 138 public static <K, V> CacheAccess<K, V> getCache(String cacheName, int maxMemoryObjects, int maxDiskObjects, String cachePath) 139 throws IOException { 139 140 if (cacheManager != null) 140 141 return getCacheInner(cacheName, maxMemoryObjects, maxDiskObjects, cachePath); … … 147 148 } 148 149 149 150 150 @SuppressWarnings("unchecked") 151 private static <K,V> CacheAccess<K, V> getCacheInner(String cacheName, int maxMemoryObjects, int maxDiskObjects, String cachePath) { 151 private static <K, V> CacheAccess<K, V> getCacheInner(String cacheName, int maxMemoryObjects, int maxDiskObjects, String cachePath) { 152 152 CompositeCache<K, V> cc = cacheManager.getCache(cacheName, getCacheAttributes(maxMemoryObjects)); 153 153 -
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r8509 r8510 84 84 85 85 public static ThreadFactory getNamedThreadFactory(final String name) { 86 return new ThreadFactory(){ 86 return new ThreadFactory() { 87 87 @Override 88 88 public Thread newThread(Runnable r) { … … 94 94 } 95 95 96 private static ConcurrentMap<String,Set<ICachedLoaderListener>> inProgress = new ConcurrentHashMap<>(); 96 private static ConcurrentMap<String, Set<ICachedLoaderListener>> inProgress = new ConcurrentHashMap<>(); 97 97 private static ConcurrentMap<String, Boolean> useHead = new ConcurrentHashMap<>(); 98 98 … … 119 119 * @param downloadJobExecutor that will be executing the jobs 120 120 */ 121 public JCSCachedTileLoaderJob(ICacheAccess<K,V> cache, 121 public JCSCachedTileLoaderJob(ICacheAccess<K, V> cache, 122 122 int connectTimeout, int readTimeout, 123 123 Map<String, String> headers, … … 337 337 // we have an object in cache, but we haven't received 304 resposne code 338 338 // check if we should use HEAD request to verify 339 if((attributes.getEtag() != null && attributes.getEtag().equals(urlConn.getRequestProperty("ETag"))) || 339 if ((attributes.getEtag() != null && attributes.getEtag().equals(urlConn.getRequestProperty("ETag"))) || 340 340 attributes.getLastModification() == urlConn.getLastModified()) { 341 341 // we sent ETag or If-Modified-Since, but didn't get 304 response code … … 455 455 urlConn.setReadTimeout(readTimeout); // 30 seconds read timeout 456 456 urlConn.setConnectTimeout(connectTimeout); 457 for(Map.Entry<String, String> e: headers.entrySet()) { 457 for (Map.Entry<String, String> e: headers.entrySet()) { 458 458 urlConn.setRequestProperty(e.getKey(), e.getValue()); 459 459 } … … 466 466 private boolean isCacheValidUsingHead() throws IOException { 467 467 URLConnection urlConn = getUrl().openConnection(); 468 if(urlConn instanceof HttpURLConnection) { 469 ((HttpURLConnection)urlConn).setRequestMethod("HEAD"); 468 if (urlConn instanceof HttpURLConnection) { 469 ((HttpURLConnection) urlConn).setRequestMethod("HEAD"); 470 470 long lastModified = urlConn.getLastModified(); 471 471 return (attributes.getEtag() != null && attributes.getEtag().equals(urlConn.getRequestProperty("ETag"))) || … … 504 504 public void cancelOutstandingTasks() { 505 505 ThreadPoolExecutor downloadExecutor = getDownloadExecutor(); 506 for(Runnable r: downloadExecutor.getQueue()) { 506 for (Runnable r: downloadExecutor.getQueue()) { 507 507 if (downloadExecutor.remove(r)) { 508 508 if (r instanceof JCSCachedTileLoaderJob) { -
trunk/src/org/openstreetmap/josm/data/conflict/Conflict.java
r6313 r8510 103 103 if (my != other.my) 104 104 return false; 105 if(their != other.their) 105 if (their != other.their) 106 106 return false; 107 107 return true; -
trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java
r8465 r8510 26 26 * ConflictCollection conflictCollection = .... 27 27 * 28 * for(Conflict c : conflictCollection) { 28 * for (Conflict c : conflictCollection) { 29 29 * // do something 30 30 * } … … 132 132 public void add(Collection<Conflict<?>> otherConflicts) { 133 133 if (otherConflicts == null) return; 134 for(Conflict<?> c : otherConflicts) { 134 for (Conflict<?> c : otherConflicts) { 135 135 addConflict(c); 136 136 } … … 167 167 public void remove(OsmPrimitive my) { 168 168 Iterator<Conflict<?>> it = iterator(); 169 while(it.hasNext()) { 169 while (it.hasNext()) { 170 170 if (it.next().isMatchingMy(my)) { 171 171 it.remove(); … … 184 184 */ 185 185 public Conflict<?> getConflictForMy(OsmPrimitive my) { 186 for(Conflict<?> c : conflicts) { 186 for (Conflict<?> c : conflicts) { 187 187 if (c.isMatchingMy(my)) 188 188 return c; … … 199 199 */ 200 200 public Conflict<?> getConflictForTheir(OsmPrimitive their) { 201 for(Conflict<?> c : conflicts) { 201 for (Conflict<?> c : conflicts) { 202 202 if (c.isMatchingTheir(their)) 203 203 return c; … … 243 243 public void removeForMy(OsmPrimitive my) { 244 244 Iterator<Conflict<?>> it = iterator(); 245 while(it.hasNext()) { 245 while (it.hasNext()) { 246 246 if (it.next().isMatchingMy(my)) { 247 247 it.remove(); … … 257 257 public void removeForTheir(OsmPrimitive their) { 258 258 Iterator<Conflict<?>> it = iterator(); 259 while(it.hasNext()) { 259 while (it.hasNext()) { 260 260 if (it.next().isMatchingTheir(their)) { 261 261 it.remove(); -
trunk/src/org/openstreetmap/josm/data/conflict/IConflictListener.java
r3083 r8510 4 4 public interface IConflictListener { 5 5 public void onConflictsAdded(ConflictCollection conflicts); 6 6 7 public void onConflictsRemoved(ConflictCollection conflicts); 7 8 } -
trunk/src/org/openstreetmap/josm/data/coor/EastNorth.java
r8345 r8510 14 14 15 15 public EastNorth(double east, double north) { 16 super(east,north); 16 super(east, north); 17 17 } 18 18 … … 73 73 * @return length of this 74 74 */ 75 public double length(){ 75 public double length() { 76 76 return Math.sqrt(x*x + y*y); 77 77 } … … 86 86 public double heading(EastNorth other) { 87 87 double hd = Math.atan2(other.east() - east(), other.north() - north()); 88 if(hd < 0) { 88 if (hd < 0) { 89 89 hd = 2 * Math.PI + hd; 90 90 } -
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r8444 r8510 198 198 public static final String SOUTH = trc("compass", "S"); 199 199 public static final String NORTH = trc("compass", "N"); 200 200 201 public String latToString(CoordinateFormat d) { 201 202 switch(d) { … … 218 219 public static final String WEST = trc("compass", "W"); 219 220 public static final String EAST = trc("compass", "E"); 221 220 222 public String lonToString(CoordinateFormat d) { 221 223 switch(d) { -
trunk/src/org/openstreetmap/josm/data/coor/QuadTiling.java
r8395 r8510 14 14 15 15 public static final int TILES_PER_LEVEL_SHIFT = 2; // Has to be 2. Other parts of QuadBuckets code rely on it 16 public static final int TILES_PER_LEVEL = 1 <<TILES_PER_LEVEL_SHIFT;16 public static final int TILES_PER_LEVEL = 1 << TILES_PER_LEVEL_SHIFT; 17 17 public static final int X_PARTS = 360; 18 18 public static final int X_BIAS = -180; … … 58 58 tile <<= 2; 59 59 // Note that x is the MSB 60 tile |= (xbit <<1) | ybit;60 tile |= (xbit << 1) | ybit; 61 61 } 62 62 return tile; … … 68 68 69 69 static long lon2x(double lon) { 70 long ret = (long)((lon + 180.0) * WORLD_PARTS / 360.0); 70 long ret = (long) ((lon + 180.0) * WORLD_PARTS / 360.0); 71 71 if (Utils.equalsEpsilon(ret, WORLD_PARTS)) { 72 72 ret--; … … 76 76 77 77 static long lat2y(double lat) { 78 long ret = (long)((lat + 90.0) * WORLD_PARTS / 180.0); 78 long ret = (long) ((lat + 90.0) * WORLD_PARTS / 180.0); 79 79 if (Utils.equalsEpsilon(ret, WORLD_PARTS)) { 80 80 ret--; … … 90 90 long mask = 0x00000003; 91 91 int total_shift = TILES_PER_LEVEL_SHIFT*(NR_LEVELS-level-1); 92 return (int)(mask & (quad >> total_shift)); 92 return (int) (mask & (quad >> total_shift)); 93 93 } 94 94 … … 125 125 long y = lat2y(lat); 126 126 int shift = NR_LEVELS-level-1; 127 return (int)((x >> shift & 1) * 2 + (y >> shift & 1)); 127 return (int) ((x >> shift & 1) * 2 + (y >> shift & 1)); 128 128 } 129 129 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxConstants.java
r7937 r8510 102 102 * Possible fix values. 103 103 */ 104 public static Collection<String> FIX_VALUES = Arrays.asList("none", "2d","3d","dgps","pps");104 public static Collection<String> FIX_VALUES = Arrays.asList("none", "2d", "3d", "dgps", "pps"); 105 105 } -
trunk/src/org/openstreetmap/josm/data/gpx/GpxData.java
r8506 r8510 200 200 } 201 201 } 202 if (earliest ==null || latest==null) return null;202 if (earliest == null || latest == null) return null; 203 203 return new Date[]{earliest.getTime(), latest.getTime()}; 204 204 } … … 212 212 */ 213 213 public Date[] getMinMaxTimeForAllTracks() { 214 double min =1e100;215 double max =-1e100;214 double min = 1e100; 215 double max = -1e100; 216 216 double now = System.currentTimeMillis()/1000.0; 217 217 for (GpxTrack trk: tracks) { … … 219 219 for (WayPoint pnt : seg.getWayPoints()) { 220 220 double t = pnt.time; 221 if (t >0 && t<=now) {222 if (t >max) max=t;223 if (t <min) min=t;224 } 225 } 226 } 227 } 228 if (Utils.equalsEpsilon(min,1e100) || Utils.equalsEpsilon(max,-1e100)) return new Date[0]; 221 if (t > 0 && t <= now) { 222 if (t > max) max = t; 223 if (t < min) min = t; 224 } 225 } 226 } 227 } 228 if (Utils.equalsEpsilon(min, 1e100) || Utils.equalsEpsilon(max, -1e100)) return new Date[0]; 229 229 return new Date[]{new Date((long) (min * 1000)), new Date((long) (max * 1000))}; 230 230 } … … 363 363 public void resetEastNorthCache() { 364 364 if (waypoints != null) { 365 for (WayPoint wp : waypoints){ 365 for (WayPoint wp : waypoints) { 366 366 wp.invalidateEastNorthCache(); 367 367 } 368 368 } 369 if (tracks != null){ 369 if (tracks != null) { 370 370 for (GpxTrack track: tracks) { 371 371 for (GpxTrackSegment segment: track.getSegments()) { -
trunk/src/org/openstreetmap/josm/data/gpx/GpxTrack.java
r7509 r8510 14 14 15 15 Collection<GpxTrackSegment> getSegments(); 16 16 17 Map<String, Object> getAttributes(); 18 17 19 Bounds getBounds(); 20 18 21 double length(); 19 22 -
trunk/src/org/openstreetmap/josm/data/gpx/GpxTrackSegment.java
r5170 r8510 13 13 14 14 Bounds getBounds(); 15 15 16 Collection<WayPoint> getWayPoints(); 17 16 18 double length(); 19 17 20 /** 18 21 * -
trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrack.java
r7005 r8510 30 30 } 31 31 32 private double calculateLength(){ 32 private double calculateLength() { 33 33 double result = 0.0; // in meters 34 34 -
trunk/src/org/openstreetmap/josm/data/gpx/ImmutableGpxTrackSegment.java
r7005 r8510 36 36 WayPoint last = null; 37 37 for (WayPoint tpt : wayPoints) { 38 if(last != null){ 38 if (last != null) { 39 39 Double d = last.getCoor().greatCircleDistance(tpt.getCoor()); 40 if(!d.isNaN() && !d.isInfinite()) { 40 if (!d.isNaN() && !d.isInfinite()) { 41 41 result += d; 42 42 } -
trunk/src/org/openstreetmap/josm/data/gpx/WayPoint.java
r8376 r8510 67 67 68 68 public final LatLon getCoor() { 69 return new LatLon(lat,lon); 69 return new LatLon(lat, lon); 70 70 } 71 71 … … 95 95 @Override 96 96 public String toString() { 97 return "WayPoint (" + (attr.containsKey(GPX_NAME) ? get(GPX_NAME) + ", " :"") + getCoor() + ", " + attr + ")"; 97 return "WayPoint (" + (attr.containsKey(GPX_NAME) ? get(GPX_NAME) + ", " : "") + getCoor() + ", " + attr + ")"; 98 98 } 99 99 … … 105 105 try { 106 106 time = dateParser.get().parse(get(PT_TIME).toString()).getTime() / 1000.; /* ms => seconds */ 107 } catch(Exception e) { 107 } catch (Exception e) { 108 108 time = 0; 109 109 } -
trunk/src/org/openstreetmap/josm/data/gpx/WithAttributes.java
r7518 r8510 44 44 public String getString(String key) { 45 45 Object value = attr.get(key); 46 return (value instanceof String) ? (String)value : null; 46 return (value instanceof String) ? (String) value : null; 47 47 } 48 48 … … 60 60 public <T> Collection<T> getCollection(String key) { 61 61 Object value = attr.get(key); 62 return (value instanceof Collection) ? (Collection<T>)value : null; 62 return (value instanceof Collection) ? (Collection<T>) value : null; 63 63 } 64 64 -
trunk/src/org/openstreetmap/josm/data/imagery/GeorefImage.java
r7425 r8510 37 37 private int yIndex; 38 38 39 private static final Color transparentColor = new Color(0, 0,0,0);39 private static final Color transparentColor = new Color(0, 0, 0, 0); 40 40 private Color fadeColor = transparentColor; 41 41 … … 118 118 return false; 119 119 120 if(!(this.xIndex == xIndex && this.yIndex == yIndex)) 120 if (!(this.xIndex == xIndex && this.yIndex == yIndex)) 121 121 return false; 122 122 … … 130 130 131 131 // This happens if you zoom outside the world 132 if(width == 0 || height == 0) 132 if (width == 0 || height == 0) 133 133 return false; 134 134 … … 141 141 } 142 142 143 BufferedImage img = reImg == null ?null:reImg.get();144 if(img != null && img.getWidth() == width && img.getHeight() == height && fadeColor.equals(newFadeColor)) { 143 BufferedImage img = reImg == null ? null : reImg.get(); 144 if (img != null && img.getWidth() == width && img.getHeight() == height && fadeColor.equals(newFadeColor)) { 145 145 g.drawImage(img, x, y, null); 146 146 return true; … … 152 152 153 153 try { 154 if(img != null) { 154 if (img != null) { 155 155 img.flush(); 156 156 } … … 163 163 // traditional rendering is as fast at these zoom levels, so it's no loss. 164 164 // Also prevent caching if we're out of memory soon 165 if(width > 2000 || height > 2000 || width*height*multipl > freeMem) { 165 if (width > 2000 || height > 2000 || width*height*multipl > freeMem) { 166 166 fallbackDraw(g, getImage(), x, y, width, height, alphaChannel); 167 167 } else { 168 168 // We haven't got a saved resized copy, so resize and cache it 169 img = new BufferedImage(width, height, alphaChannel ?BufferedImage.TYPE_INT_ARGB:BufferedImage.TYPE_3BYTE_BGR);169 img = new BufferedImage(width, height, alphaChannel ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_3BYTE_BGR); 170 170 img.getGraphics().drawImage(getImage(), 171 171 0, 0, width, height, // dest … … 179 179 reImg = new SoftReference<>(img); 180 180 } 181 } catch(Exception e) { 181 } catch (Exception e) { 182 182 fallbackDraw(g, getImage(), x, y, width, height, alphaChannel); 183 183 } … … 216 216 private void writeObject(ObjectOutputStream out) throws IOException { 217 217 out.writeObject(state); 218 if(getImage() == null) { 218 if (getImage() == null) { 219 219 out.writeBoolean(false); 220 220 out.writeObject(null); -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r8459 r8510 353 353 setExtendedUrl(url); 354 354 ImageryType t = ImageryType.fromString(type); 355 this.cookies =cookies;355 this.cookies = cookies; 356 356 this.eulaAcceptanceRequired = eulaAcceptanceRequired; 357 357 if (t != null) { … … 664 664 serverProjections = new ArrayList<>(); 665 665 Matcher m = Pattern.compile(".*\\{PROJ\\(([^)}]+)\\)\\}.*").matcher(url.toUpperCase(Locale.ENGLISH)); 666 if(m.matches()) { 667 for(String p : m.group(1).split(",")) 666 if (m.matches()) { 667 for (String p : m.group(1).split(",")) 668 668 serverProjections.add(p); 669 669 } … … 708 708 public void setName(String language, String name) { 709 709 boolean isdefault = LanguageInfo.getJOSMLocaleCode(null).equals(language); 710 if(LanguageInfo.isBetterLanguage(langName, language)) { 710 if (LanguageInfo.isBetterLanguage(langName, language)) { 711 711 this.name = isdefault ? tr(name) : name; 712 712 this.langName = language; 713 713 } 714 if(origName == null || isdefault) { 714 if (origName == null || isdefault) { 715 715 this.origName = name; 716 716 } … … 827 827 public void setDescription(String language, String description) { 828 828 boolean isdefault = LanguageInfo.getJOSMLocaleCode(null).equals(language); 829 if(LanguageInfo.isBetterLanguage(langDescription, language)) { 829 if (LanguageInfo.isBetterLanguage(langDescription, language)) { 830 830 this.description = isdefault ? tr(description) : description; 831 831 this.langDescription = language; … … 916 916 public String getExtendedUrl() { 917 917 return imageryType.getTypeString() + (defaultMaxZoom != 0 918 ? "["+(defaultMinZoom != 0 ? defaultMinZoom+"," :"")+defaultMaxZoom+"]" : "") + ":" + url;918 ? "["+(defaultMinZoom != 0 ? defaultMinZoom+"," : "")+defaultMaxZoom+"]" : "") + ":" + url; 919 919 } 920 920 -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryLayerInfo.java
r8465 r8510 220 220 221 221 // automatically update user entries with same id as a default entry 222 for (int i =0; i<layers.size(); i++) {222 for (int i = 0; i < layers.size(); i++) { 223 223 ImageryInfo info = layers.get(i); 224 224 if (info.getId() == null) { -
trunk/src/org/openstreetmap/josm/data/imagery/OffsetBookmark.java
r8393 r8510 79 79 80 80 public static void loadBookmarks() { 81 for(Collection<String> c : Main.pref.getArray("imagery.offsets", 81 for (Collection<String> c : Main.pref.getArray("imagery.offsets", 82 82 Collections.<Collection<String>>emptySet())) { 83 83 allBookmarks.add(new OffsetBookmark(c)); … … 106 106 center = Main.getProjection().eastNorth2latlon(Main.map.mapView.getCenter()); 107 107 } else { 108 center = new LatLon(0,0); 108 center = new LatLon(0, 0); 109 109 } 110 110 OffsetBookmark nb = new OffsetBookmark( 111 111 Main.getProjection().toCode(), layer.getInfo().getName(), 112 112 name, layer.getDx(), layer.getDy(), center.lon(), center.lat()); 113 for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator();it.hasNext();) { 113 for (ListIterator<OffsetBookmark> it = allBookmarks.listIterator(); it.hasNext();) { 114 114 OffsetBookmark b = it.next(); 115 115 if (b.isUsable(layer) && name.equals(b.name)) { -
trunk/src/org/openstreetmap/josm/data/imagery/Shape.java
r8509 r8510 29 29 throw new IllegalArgumentException(MessageFormat.format("Even number of doubles expected in string, got {0}: {1}", 30 30 components.length, asString)); 31 for (int i =0; i<components.length; i+=2) {31 for (int i = 0; i < components.length; i += 2) { 32 32 addPoint(components[i], components[i+1]); 33 33 } -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoader.java
r8509 r8510 105 105 @Override 106 106 public Tile getTile(TileSource source, int x, int y, int z) { 107 return createTileLoaderJob(new Tile(source,x, y, z)).getTile(); 107 return createTileLoaderJob(new Tile(source, x, y, z)).getTile(); 108 108 } 109 109 … … 135 135 */ 136 136 public void cancelOutstandingTasks() { 137 for(Runnable r: downloadExecutor.getQueue()) { 137 for (Runnable r: downloadExecutor.getQueue()) { 138 138 if (downloadExecutor.remove(r) && r instanceof TMSCachedTileLoaderJob) { 139 ((TMSCachedTileLoaderJob)r).handleJobCancellation(); 139 ((TMSCachedTileLoaderJob) r).handleJobCancellation(); 140 140 } 141 141 } -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r8488 r8510 45 45 private volatile URL url; 46 46 47 48 47 // we need another deduplication of Tile Loader listeners, as for each submit, new TMSCachedTileLoaderJob was created 49 48 // that way, we reduce calls to tileLoadingFinished, and general CPU load due to surplus Map repaints 50 private static final ConcurrentMap<String,Set<TileLoaderListener>> inProgress = new ConcurrentHashMap<>(); 49 private static final ConcurrentMap<String, Set<TileLoaderListener>> inProgress = new ConcurrentHashMap<>(); 51 50 52 51 /** … … 177 176 178 177 try { 179 if(!tile.isLoaded()) { //if someone else already loaded tile, skip all the handling 178 if (!tile.isLoaded()) { //if someone else already loaded tile, skip all the handling 180 179 tile.finishLoading(); // whatever happened set that loading has finished 181 180 // set tile metadata … … 186 185 } 187 186 188 switch(result){ 187 switch(result) { 189 188 case SUCCESS: 190 189 handleNoTileAtZoom(); … … 215 214 // always check, if there is some listener interested in fact, that tile has finished loading 216 215 if (listeners != null) { // listeners might be null, if some other thread notified already about success 217 for(TileLoaderListener l: listeners) { 216 for (TileLoaderListener l: listeners) { 218 217 l.tileLoadingFinished(tile, status); 219 218 } … … 224 223 tile.setLoaded(false); 225 224 if (listeners != null) { // listeners might be null, if some other thread notified already about success 226 for(TileLoaderListener l: listeners) { 225 for (TileLoaderListener l: listeners) { 227 226 l.tileLoadingFinished(tile, false); 228 227 } -
trunk/src/org/openstreetmap/josm/data/imagery/WmsCache.java
r8509 r8510 135 135 136 136 for (Object propKey: layersIndex.keySet()) { 137 String s = (String)propKey; 137 String s = (String) propKey; 138 138 if (url.equals(layersIndex.getProperty(s))) { 139 139 cacheDirName = s; … … 186 186 WmsCacheType cacheEntries; 187 187 try (InputStream is = new FileInputStream(indexFile)) { 188 cacheEntries = (WmsCacheType)unmarshaller.unmarshal(is); 188 cacheEntries = (WmsCacheType) unmarshaller.unmarshal(is); 189 189 } 190 190 totalFileSize = cacheEntries.getTotalFileSize(); … … 440 440 drawAtLeastOnce = true; 441 441 442 int xDiff = (int)((ce.east - east) * pixelPerDegree); 443 int yDiff = (int)((ce.north - north) * pixelPerDegree); 444 int size = (int)(pixelPerDegree / ce.pixelPerDegree * tileSize); 442 int xDiff = (int) ((ce.east - east) * pixelPerDegree); 443 int yDiff = (int) ((ce.north - north) * pixelPerDegree); 444 int size = (int) (pixelPerDegree / ce.pixelPerDegree * tileSize); 445 445 446 446 int x = xDiff; … … 467 467 double deltaLat = Math.abs(ll3.lat() - ll1.lat()); 468 468 double deltaLon = Math.abs(ll3.lon() - ll1.lon()); 469 int precisionLat = Math.max(0, -(int)Math.ceil(Math.log10(deltaLat)) + 1); 470 int precisionLon = Math.max(0, -(int)Math.ceil(Math.log10(deltaLon)) + 1); 469 int precisionLat = Math.max(0, -(int) Math.ceil(Math.log10(deltaLat)) + 1); 470 int precisionLon = Math.max(0, -(int) Math.ceil(Math.log10(deltaLon)) + 1); 471 471 472 472 String zoom = SystemOfMeasurement.METRIC.getDistText(ll1.greatCircleDistance(ll2)); … … 493 493 while (true) { 494 494 String result = String.format("%s_%." + precisionLat + "f_%." + precisionLon +"f%s.%s", 495 zoom, ll1.lat(), ll1.lon(), counter ==0?"":"_" + counter, extension);495 zoom, ll1.lat(), ll1.lon(), counter == 0 ? "" : "_" + counter, extension); 496 496 for (CacheEntry entry: projectionEntries.entries) { 497 497 if (entry.filename.equals(result)) { … … 528 528 } 529 529 entry = new CacheEntry(pixelPerDegree, east, north, 530 tileSize,generateFileName(projectionEntries, pixelPerDegree, projection, east, north, mimeType)); 530 tileSize, generateFileName(projectionEntries, pixelPerDegree, projection, east, north, mimeType)); 531 531 entry.lastUsed = System.currentTimeMillis(); 532 532 entry.lastModified = entry.lastUsed; -
trunk/src/org/openstreetmap/josm/data/oauth/OsmPrivileges.java
r6066 r8510 13 13 return allowWriteApi; 14 14 } 15 15 16 public void setAllowWriteApi(boolean allowWriteApi) { 16 17 this.allowWriteApi = allowWriteApi; 17 18 } 19 18 20 public boolean isAllowWriteGpx() { 19 21 return allowWriteGpx; 20 22 } 23 21 24 public void setAllowWriteGpx(boolean allowWriteGpx) { 22 25 this.allowWriteGpx = allowWriteGpx; 23 26 } 27 24 28 public boolean isAllowReadGpx() { 25 29 return allowReadGpx; 26 30 } 31 27 32 public void setAllowReadGpx(boolean allowReadGpx) { 28 33 this.allowReadGpx = allowReadGpx; 29 34 } 35 30 36 public boolean isAllowReadPrefs() { 31 37 return allowReadPrefs; 32 38 } 39 33 40 public void setAllowReadPrefs(boolean allowReadPrefs) { 34 41 this.allowReadPrefs = allowReadPrefs; 35 42 } 43 36 44 public boolean isAllowWritePrefs() { 37 45 return allowWritePrefs; 38 46 } 47 39 48 public void setAllowWritePrefs(boolean allowWritePrefs) { 40 49 this.allowWritePrefs = allowWritePrefs; -
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r8449 r8510 107 107 setKeys(other.getKeys()); 108 108 id = other.id; 109 if (id <=0) { 109 if (id <= 0) { 110 110 // reset version and changeset id 111 111 version = 0; … … 117 117 } 118 118 flags = other.flags; 119 user= other.user; 119 user = other.user; 120 120 if (id > 0 && other.changesetId > 0) { 121 121 // #4208: sometimes we cloned from other with id < 0 *and* … … 146 146 public long getId() { 147 147 long id = this.id; 148 return id >= 0 ?id:0;148 return id >= 0 ? id : 0; 149 149 } 150 150 … … 289 289 @Override 290 290 public void setTimestamp(Date timestamp) { 291 this.timestamp = (int)(timestamp.getTime() / 1000); 291 this.timestamp = (int) (timestamp.getTime() / 1000); 292 292 } 293 293 … … 474 474 String[] keys = this.keys; 475 475 if (keys != null) { 476 for (int i =0; i<keys.length; i+=2) {476 for (int i = 0; i < keys.length; i += 2) { 477 477 result.put(keys[i], keys[i + 1]); 478 478 } … … 522 522 else if (value == null) { 523 523 remove(key); 524 } else if (keys == null){ 524 } else if (keys == null) { 525 525 keys = new String[] {key, value}; 526 526 keysChangedImpl(originalKeys); 527 527 } else { 528 for (int i =0; i<keys.length;i+=2) {528 for (int i = 0; i < keys.length; i += 2) { 529 529 if (keys[i].equals(key)) { 530 530 keys[i+1] = value; // This modifies the keys array but it doesn't make it invalidate for any time so its ok (see note no top) … … 534 534 } 535 535 String[] newKeys = new String[keys.length + 2]; 536 for (int i =0; i< keys.length;i+=2) {536 for (int i = 0; i < keys.length; i += 2) { 537 537 newKeys[i] = keys[i]; 538 538 newKeys[i+1] = keys[i+1]; … … 562 562 } 563 563 String[] newKeys = new String[keys.length - 2]; 564 int j =0;565 for (int i =0; i < keys.length; i+=2) {564 int j = 0; 565 for (int i = 0; i < keys.length; i += 2) { 566 566 if (!keys[i].equals(key)) { 567 567 newKeys[j++] = keys[i]; … … 599 599 if (keys == null) 600 600 return null; 601 for (int i =0; i<keys.length;i+=2) {601 for (int i = 0; i < keys.length; i += 2) { 602 602 if (keys[i].equals(key)) return keys[i+1]; 603 603 } … … 627 627 if (keys == null) 628 628 return null; 629 for (int i =0; i<keys.length;i+=2) {629 for (int i = 0; i < keys.length; i += 2) { 630 630 if (keys[i].equalsIgnoreCase(key)) return keys[i+1]; 631 631 } … … 643 643 return Collections.emptySet(); 644 644 Set<String> result = new HashSet<>(keys.length / 2); 645 for (int i =0; i<keys.length; i+=2) {645 for (int i = 0; i < keys.length; i += 2) { 646 646 result.add(keys[i]); 647 647 } … … 670 670 if (key == null) return false; 671 671 if (keys == null) return false; 672 for (int i =0; i< keys.length;i+=2) {672 for (int i = 0; i < keys.length; i += 2) { 673 673 if (keys[i].equals(key)) return true; 674 674 } … … 701 701 @Override 702 702 public String getLocalName() { 703 for(String s : LanguageInfo.getLanguageCodes(null)) { 703 for (String s : LanguageInfo.getLanguageCodes(null)) { 704 704 String val = get("name:" + s); 705 705 if (val != null) -
trunk/src/org/openstreetmap/josm/data/osm/BBox.java
r8470 r8510 267 267 @Override 268 268 public int hashCode() { 269 return (int)(ymin * xmin); 269 return (int) (ymin * xmin); 270 270 } 271 271 … … 273 273 public boolean equals(Object o) { 274 274 if (o instanceof BBox) { 275 BBox b = (BBox)o; 275 BBox b = (BBox) o; 276 276 return b.xmax == xmax && b.ymax == ymax 277 277 && b.xmin == xmin && b.ymin == ymin; -
trunk/src/org/openstreetmap/josm/data/osm/Changeset.java
r8365 r8510 42 42 private int commentsCount; 43 43 /** the map of tags */ 44 private Map<String,String> tags; 44 private Map<String, String> tags; 45 45 /** indicates whether this changeset is incomplete. For an incomplete changeset we only know its id */ 46 46 private boolean incomplete; … … 159 159 public Bounds getBounds() { 160 160 if (min != null && max != null) 161 return new Bounds(min,max); 161 return new Bounds(min, max); 162 162 return null; 163 163 } -
trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java
r8444 r8510 69 69 GuiHelper.runInEDT(new Runnable() { 70 70 @Override public void run() { 71 for(ChangesetCacheListener l: listeners) { 71 for (ChangesetCacheListener l: listeners) { 72 72 l.changesetCacheUpdated(e); 73 73 } … … 105 105 106 106 public boolean contains(int id) { 107 if (id <=0) return false; 107 if (id <= 0) return false; 108 108 return cache.get(id) != null; 109 109 } -
trunk/src/org/openstreetmap/josm/data/osm/ChangesetCacheEvent.java
r3083 r8510 6 6 public interface ChangesetCacheEvent { 7 7 ChangesetCache getSource(); 8 8 9 Collection<Changeset> getAddedChangesets(); 10 9 11 Collection<Changeset> getRemovedChangesets(); 12 10 13 Collection<Changeset> getUpdatedChangesets(); 11 12 14 } -
trunk/src/org/openstreetmap/josm/data/osm/ChangesetDataSet.java
r8338 r8510 25 25 public static interface ChangesetDataSetEntry { 26 26 public ChangesetModificationType getModificationType(); 27 27 28 public HistoryOsmPrimitive getPrimitive(); 28 29 } … … 40 41 */ 41 42 public void put(HistoryOsmPrimitive primitive, ChangesetModificationType cmt) { 42 CheckParameterUtil.ensureParameterNotNull(primitive,"primitive"); 43 CheckParameterUtil.ensureParameterNotNull(cmt,"cmt"); 43 CheckParameterUtil.ensureParameterNotNull(primitive, "primitive"); 44 CheckParameterUtil.ensureParameterNotNull(cmt, "cmt"); 44 45 primitives.put(primitive.getPrimitiveId(), primitive); 45 46 modificationTypes.put(primitive.getPrimitiveId(), cmt); … … 115 116 */ 116 117 public Set<HistoryOsmPrimitive> getPrimitivesByModificationType(ChangesetModificationType cmt) { 117 CheckParameterUtil.ensureParameterNotNull(cmt,"cmt"); 118 CheckParameterUtil.ensureParameterNotNull(cmt, "cmt"); 118 119 Set<HistoryOsmPrimitive> ret = new HashSet<>(); 119 120 for (Entry<PrimitiveId, ChangesetModificationType> entry: modificationTypes.entrySet()) { -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r8470 r8510 254 254 */ 255 255 public void addChangeSetTag(String k, String v) { 256 this.changeSetTags.put(k,v); 256 this.changeSetTags.put(k, v); 257 257 } 258 258 … … 526 526 */ 527 527 public static void addSelectionListener(SelectionChangedListener listener) { 528 ((CopyOnWriteArrayList<SelectionChangedListener>)selListeners).addIfAbsent(listener); 528 ((CopyOnWriteArrayList<SelectionChangedListener>) selListeners).addIfAbsent(listener); 529 529 } 530 530 … … 542 542 * 543 543 */ 544 public void fireSelectionChanged(){ 544 public void fireSelectionChanged() { 545 545 Collection<? extends OsmPrimitive> currentSelection = getAllSelected(); 546 546 for (SelectionChangedListener l : selListeners) { … … 698 698 */ 699 699 public void setHighlightedVirtualNodes(Collection<WaySegment> waySegments) { 700 if(highlightedVirtualNodes.isEmpty() && waySegments.isEmpty()) 700 if (highlightedVirtualNodes.isEmpty() && waySegments.isEmpty()) 701 701 return; 702 702 … … 711 711 */ 712 712 public void setHighlightedWaySegments(Collection<WaySegment> waySegments) { 713 if(highlightedWaySegments.isEmpty() && waySegments.isEmpty()) 713 if (highlightedWaySegments.isEmpty() && waySegments.isEmpty()) 714 714 return; 715 715 … … 889 889 List<Node> newNodes = new ArrayList<>(); 890 890 for (Node n: w.getNodes()) { 891 newNodes.add((Node)primMap.get(n)); 891 newNodes.add((Node) primMap.get(n)); 892 892 } 893 893 newWay.setNodes(newNodes); … … 903 903 } 904 904 for (Relation r : relations) { 905 Relation newRelation = (Relation)primMap.get(r); 905 Relation newRelation = (Relation) primMap.get(r); 906 906 List<RelationMember> newMembers = new ArrayList<>(); 907 907 for (RelationMember rm: r.getMembers()) { … … 1016 1016 Iterator<RelationMember> it = members.iterator(); 1017 1017 boolean removed = false; 1018 while(it.hasNext()) { 1018 while (it.hasNext()) { 1019 1019 RelationMember member = it.next(); 1020 1020 if (member.getMember().equals(primitive)) { … … 1046 1046 try { 1047 1047 if (referencedPrimitive instanceof Node) { 1048 result.addAll(unlinkNodeFromWays((Node)referencedPrimitive)); 1048 result.addAll(unlinkNodeFromWays((Node) referencedPrimitive)); 1049 1049 } 1050 1050 result.addAll(unlinkPrimitiveFromRelations(referencedPrimitive)); … … 1078 1078 for (OsmPrimitive primitive: node.getReferrers()) { 1079 1079 if (primitive instanceof Way) { 1080 reindexWay((Way)primitive); 1080 reindexWay((Way) primitive); 1081 1081 } else { 1082 1082 reindexRelation((Relation) primitive); … … 1094 1094 if (!way.getBBox().equals(before)) { 1095 1095 for (OsmPrimitive primitive: way.getReferrers()) { 1096 reindexRelation((Relation)primitive); 1096 reindexRelation((Relation) primitive); 1097 1097 } 1098 1098 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r8509 r8510 141 141 142 142 protected void fixIncomplete(Way other) { 143 Way myWay = (Way)getMergeTarget(other); 143 Way myWay = (Way) getMergeTarget(other); 144 144 if (myWay == null) 145 145 throw new RuntimeException(tr("Missing merge target for way with id {0}", other.getUniqueId())); … … 174 174 do { 175 175 flag = false; 176 for (Iterator<OsmPrimitive> it = objectsToDelete.iterator();it.hasNext();) { 176 for (Iterator<OsmPrimitive> it = objectsToDelete.iterator(); it.hasNext();) { 177 177 OsmPrimitive target = it.next(); 178 178 OsmPrimitive source = sourceDataSet.getPrimitiveById(target.getPrimitiveId()); … … 234 234 */ 235 235 private void mergeNodeList(Way source) { 236 Way target = (Way)getMergeTarget(source); 236 Way target = (Way) getMergeTarget(source); 237 237 if (target == null) 238 238 throw new IllegalStateException(tr("Missing merge target for way with id {0}", source.getUniqueId())); … … 240 240 List<Node> newNodes = new ArrayList<>(source.getNodesCount()); 241 241 for (Node sourceNode : source.getNodes()) { 242 Node targetNode = (Node)getMergeTarget(sourceNode); 242 Node targetNode = (Node) getMergeTarget(sourceNode); 243 243 if (targetNode != null) { 244 244 newNodes.add(targetNode); … … 363 363 // this have to be resolved manually. 364 364 // 365 addConflict(target,source); 365 addConflict(target, source); 366 366 } else if (!target.hasEqualSemanticAttributes(source)) { 367 367 // target is modified and is not semantically equal with source. Can't automatically 368 368 // resolve the differences 369 369 // => create a conflict 370 addConflict(target,source); 370 addConflict(target, source); 371 371 } else { 372 372 // clone from other. mergeFrom will mainly copy -
trunk/src/org/openstreetmap/josm/data/osm/DefaultChangesetCacheEvent.java
r7005 r8510 25 25 return Collections.unmodifiableCollection(added); 26 26 } 27 27 28 @Override 28 29 public Collection<Changeset> getRemovedChangesets() { 29 30 return Collections.unmodifiableCollection(removed); 30 31 } 32 31 33 @Override 32 34 public ChangesetCache getSource() { 33 35 return source; 34 36 } 37 35 38 @Override 36 39 public Collection<Changeset> getUpdatedChangesets() { -
trunk/src/org/openstreetmap/josm/data/osm/FilterMatcher.java
r8285 r8510 85 85 86 86 Match compiled = SearchCompiler.compile(filter.text, filter.caseSensitive, filter.regexSearch); 87 this.match = filter.inverted ?new Not(compiled):compiled;87 this.match = filter.inverted ? new Not(compiled) : compiled; 88 88 this.isInverted = filter.inverted; 89 89 } -
trunk/src/org/openstreetmap/josm/data/osm/Hash.java
r6380 r8510 11 11 * @author nenik 12 12 */ 13 public interface Hash<K,T> { 13 public interface Hash<K, T> { 14 14 15 15 /** -
trunk/src/org/openstreetmap/josm/data/osm/INode.java
r4126 r8510 8 8 9 9 LatLon getCoor(); 10 10 11 void setCoor(LatLon coor); 12 11 13 EastNorth getEastNorth(); 14 12 15 void setEastNorth(EastNorth eastNorth); 13 16 } -
trunk/src/org/openstreetmap/josm/data/osm/IPrimitive.java
r6009 r8510 12 12 13 13 boolean isModified(); 14 14 15 void setModified(boolean modified); 16 15 17 boolean isVisible(); 18 16 19 void setVisible(boolean visible); 20 17 21 boolean isDeleted(); 22 18 23 void setDeleted(boolean deleted); 24 19 25 boolean isIncomplete(); 26 20 27 boolean isNewOrUndeleted(); 28 21 29 long getId(); 30 22 31 PrimitiveId getPrimitiveId(); 32 23 33 int getVersion(); 34 24 35 void setOsmId(long id, int version); 36 25 37 User getUser(); 38 26 39 void setUser(User user); 40 27 41 Date getTimestamp(); 42 28 43 void setTimestamp(Date timestamp); 44 29 45 boolean isTimestampEmpty(); 46 30 47 int getChangesetId(); 48 31 49 void setChangesetId(int changesetId); 32 50 33 51 void accept(PrimitiveVisitor visitor); 52 34 53 String getName(); 54 35 55 String getLocalName(); 36 37 56 } -
trunk/src/org/openstreetmap/josm/data/osm/IRelation.java
r4098 r8510 5 5 6 6 int getMembersCount(); 7 7 8 long getMemberId(int idx); 9 8 10 String getRole(int idx); 11 9 12 OsmPrimitiveType getMemberType(int idx); 10 11 13 } -
trunk/src/org/openstreetmap/josm/data/osm/IWay.java
r4100 r8510 5 5 6 6 int getNodesCount(); 7 7 8 long getNodeId(int idx); 9 8 10 boolean isClosed(); 9 10 11 } -
trunk/src/org/openstreetmap/josm/data/osm/MultipolygonBuilder.java
r8509 r8510 203 203 while (true) { 204 204 boolean curWayReverse = prevNode == curWay.lastNode(); 205 Node nextNode = (curWayReverse) ? curWay.firstNode(): curWay.lastNode(); 205 Node nextNode = (curWayReverse) ? curWay.firstNode() : curWay.lastNode(); 206 206 207 207 //add cur way to the list … … 222 222 223 223 Way nextWay = null; 224 for(Way way: adjacentWays) { 224 for (Way way: adjacentWays) { 225 225 if (way != curWay) { 226 226 nextWay = way; … … 306 306 final int noBuckets = (boundaryWays.size() + bucketsize - 1) / bucketsize; 307 307 final boolean singleThread = THREAD_POOL.a == 1 || noBuckets == 1; 308 for (int i =0; i<noBuckets; i++) {308 for (int i = 0; i < noBuckets; i++) { 309 309 int from = i*bucketsize; 310 310 int to = Math.min((i+1)*bucketsize, boundaryWays.size()); … … 404 404 @Override 405 405 public List<PolygonLevel> call() throws Exception { 406 for (int i = from; i <to; i++) {406 for (int i = from; i < to; i++) { 407 407 if (processOuterWay(0, input, output, input.get(i)) == null) { 408 408 return null; -
trunk/src/org/openstreetmap/josm/data/osm/NameFormatter.java
r4431 r8510 6 6 public interface NameFormatter { 7 7 String format(Node node); 8 8 9 String format(Way way); 10 9 11 String format(Relation relation); 12 10 13 String format(Changeset changeset); 11 14 12 15 Comparator<Node> getNodeComparator(); 16 13 17 Comparator<Way> getWayComparator(); 18 14 19 Comparator<Relation> getRelationComparator(); 15 20 } -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r8509 r8510 70 70 public final LatLon getCoor() { 71 71 if (!isLatLonKnown()) return null; 72 return new LatLon(lat,lon); 72 return new LatLon(lat, lon); 73 73 } 74 74 … … 223 223 try { 224 224 super.cloneFrom(osm); 225 setCoor(((Node)osm).getCoor()); 225 setCoor(((Node) osm).getCoor()); 226 226 } finally { 227 227 writeUnlock(locked); … … 246 246 super.mergeFrom(other); 247 247 if (!other.isIncomplete()) { 248 setCoor(((Node)other).getCoor()); 248 setCoor(((Node) other).getCoor()); 249 249 } 250 250 } finally { … … 257 257 try { 258 258 super.load(data); 259 setCoor(((NodeData)data).getCoor()); 259 setCoor(((NodeData) data).getCoor()); 260 260 } finally { 261 261 writeUnlock(locked); … … 284 284 if (!super.hasEqualSemanticAttributes(other)) 285 285 return false; 286 Node n = (Node)other; 286 Node n = (Node) other; 287 287 LatLon coor = getCoor(); 288 288 LatLon otherCoor = n.getCoor(); -
trunk/src/org/openstreetmap/josm/data/osm/NodeData.java
r8415 r8510 37 37 @Override 38 38 public LatLon getCoor() { 39 return isLatLonKnown() ? new LatLon(lat,lon) : null; 39 return isLatLonKnown() ? new LatLon(lat, lon) : null; 40 40 } 41 41 -
trunk/src/org/openstreetmap/josm/data/osm/NoteData.java
r8474 r8510 193 193 */ 194 194 public synchronized void createNote(LatLon location, String text) { 195 if(text == null || text.isEmpty()) { 195 if (text == null || text.isEmpty()) { 196 196 throw new IllegalArgumentException("Comment can not be blank when creating a note"); 197 197 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r8509 r8510 122 122 if (list == null) return Collections.emptyList(); 123 123 List<T> ret = new LinkedList<>(); 124 for(OsmPrimitive p: list) { 124 for (OsmPrimitive p: list) { 125 125 if (type.isInstance(p)) { 126 126 ret.add(type.cast(p)); … … 144 144 Set<T> ret = new LinkedHashSet<>(); 145 145 if (set != null) { 146 for(OsmPrimitive p: set) { 146 for (OsmPrimitive p: set) { 147 147 if (type.isInstance(p)) { 148 148 ret.add(type.cast(p)); … … 626 626 627 627 private boolean isOuterMemberOfMultipolygon(OsmPrimitive ref) { 628 if (ref instanceof Relation && ref.isSelected() && ((Relation)ref).isMultipolygon()) { 629 for (RelationMember rm : ((Relation)ref).getMembersFor(Collections.singleton(this))) { 628 if (ref instanceof Relation && ref.isSelected() && ((Relation) ref).isMultipolygon()) { 629 for (RelationMember rm : ((Relation) ref).getMembersFor(Collections.singleton(this))) { 630 630 if ("outer".equals(rm.getRole())) { 631 631 return true; … … 965 965 } else if (referrers instanceof OsmPrimitive) { 966 966 if (referrers != referrer) { 967 referrers = new OsmPrimitive[] {(OsmPrimitive)referrers, referrer}; 967 referrers = new OsmPrimitive[] {(OsmPrimitive) referrers, referrer}; 968 968 } 969 969 } else { 970 for (OsmPrimitive primitive:(OsmPrimitive[])referrers) { 970 for (OsmPrimitive primitive:(OsmPrimitive[]) referrers) { 971 971 if (primitive == referrer) 972 972 return; 973 973 } 974 referrers = Utils.addInArrayCopy((OsmPrimitive[])referrers, referrer); 974 referrers = Utils.addInArrayCopy((OsmPrimitive[]) referrers, referrer); 975 975 } 976 976 } … … 986 986 } 987 987 } else if (referrers instanceof OsmPrimitive[]) { 988 OsmPrimitive[] orig = (OsmPrimitive[])referrers; 988 OsmPrimitive[] orig = (OsmPrimitive[]) referrers; 989 989 int idx = -1; 990 for (int i =0; i<orig.length; i++) {990 for (int i = 0; i < orig.length; i++) { 991 991 if (orig[i] == referrer) { 992 992 idx = i; … … 1034 1034 if (referrers != null) { 1035 1035 if (referrers instanceof OsmPrimitive) { 1036 OsmPrimitive ref = (OsmPrimitive)referrers; 1036 OsmPrimitive ref = (OsmPrimitive) referrers; 1037 1037 if (ref.dataSet == dataSet) { 1038 1038 result.add(ref); 1039 1039 } 1040 1040 } else { 1041 for (OsmPrimitive o:(OsmPrimitive[])referrers) { 1041 for (OsmPrimitive o:(OsmPrimitive[]) referrers) { 1042 1042 if (dataSet == o.dataSet) { 1043 1043 result.add(o); … … 1058 1058 * @param visitor the visitor. Ignored, if null. 1059 1059 */ 1060 public void visitReferrers(Visitor visitor){ 1060 public void visitReferrers(Visitor visitor) { 1061 1061 if (visitor == null) return; 1062 1062 if (this.referrers == null) … … 1088 1088 checkDataset(); 1089 1089 if (referrers instanceof OsmPrimitive) 1090 return n <=1 && referrers instanceof Way && ((OsmPrimitive)referrers).dataSet == dataSet;1090 return n <= 1 && referrers instanceof Way && ((OsmPrimitive) referrers).dataSet == dataSet; 1091 1091 else { 1092 int counter =0;1093 for (OsmPrimitive o : (OsmPrimitive[])referrers) { 1092 int counter = 0; 1093 for (OsmPrimitive o : (OsmPrimitive[]) referrers) { 1094 1094 if (dataSet == o.dataSet && o instanceof Way) { 1095 1095 if (++counter >= n) … … 1100 1100 } 1101 1101 } 1102 1103 1102 1104 1103 /*----------------- … … 1153 1152 setIncomplete(other.isIncomplete()); 1154 1153 flags = other.flags; 1155 user= other.user; 1154 user = other.user; 1156 1155 changesetId = other.changesetId; 1157 1156 } finally { … … 1218 1217 && version == other.version 1219 1218 && isVisible() == other.isVisible() 1220 && (user == null ? other.user ==null : user==other.user)1219 && (user == null ? other.user == null : user == other.user) 1221 1220 && changesetId == other.changesetId; 1222 1221 } … … 1305 1304 * An primitive is equal to its incomplete counter part. 1306 1305 */ 1307 @Override public boolean equals(Object obj) { 1306 @Override 1307 public boolean equals(Object obj) { 1308 1308 if (obj instanceof OsmPrimitive) 1309 return ((OsmPrimitive)obj).id == id && obj.getClass() == getClass(); 1309 return ((OsmPrimitive) obj).id == id && obj.getClass() == getClass(); 1310 1310 return false; 1311 1311 } … … 1316 1316 * An primitive has the same hashcode as its incomplete counterpart. 1317 1317 */ 1318 @Override public final int hashCode() { 1319 return (int)id; 1318 @Override 1319 public final int hashCode() { 1320 return (int) id; 1320 1321 } 1321 1322 -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java
r7865 r8510 66 66 public static OsmPrimitiveType from(String value) { 67 67 if (value == null) return null; 68 for (OsmPrimitiveType type: values()){ 68 for (OsmPrimitiveType type: values()) { 69 69 if (type.getAPIName().equalsIgnoreCase(value)) 70 70 return type; -
trunk/src/org/openstreetmap/josm/data/osm/OsmUtils.java
r8390 r8510 30 30 31 31 public static Boolean getOsmBoolean(String value) { 32 if(value == null) return null; 32 if (value == null) return null; 33 33 String lowerValue = value.toLowerCase(Locale.ENGLISH); 34 34 if (TRUE_VALUES.contains(lowerValue)) return Boolean.TRUE; -
trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java
r7005 r8510 56 56 public static <T extends PrimitiveData> List<T> getFilteredList(Collection<T> list, OsmPrimitiveType type) { 57 57 List<T> ret = new ArrayList<>(); 58 for(PrimitiveData p: list) { 58 for (PrimitiveData p: list) { 59 59 if (type.getDataClass().isInstance(p)) { 60 ret.add((T)p); 60 ret.add((T) p); 61 61 } 62 62 } -
trunk/src/org/openstreetmap/josm/data/osm/PrimitiveDeepCopy.java
r8285 r8510 64 64 (firstIteration ? directlyAdded : referenced).add(n.save()); 65 65 } 66 66 67 @Override 67 68 public void visit(Way w) { … … 74 75 } 75 76 } 77 76 78 @Override 77 79 public void visit(Relation r) { -
trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
r8375 r8510 179 179 180 180 boolean matches(final T o, final BBox search_bbox) { 181 if (o instanceof Node){ 182 final LatLon latLon = ((Node)o).getCoor(); 181 if (o instanceof Node) { 182 final LatLon latLon = ((Node) o).getCoor(); 183 183 // node without coords -> bbox[0,0,0,0] 184 184 return search_bbox.bounds(latLon != null ? latLon : LatLon.ZERO); -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r8509 r8510 232 232 super.cloneFrom(osm); 233 233 // It's not necessary to clone members as RelationMember class is immutable 234 setMembers(((Relation)osm).getMembers()); 234 setMembers(((Relation) osm).getMembers()); 235 235 } finally { 236 236 writeUnlock(locked); … … 295 295 if (!super.hasEqualSemanticAttributes(other)) 296 296 return false; 297 Relation r = (Relation)other; 297 Relation r = (Relation) other; 298 298 return Arrays.equals(members, r.members); 299 299 } … … 460 460 BBox result = null; 461 461 for (RelationMember rm:members) { 462 BBox box = rm.isRelation() ?rm.getRelation().calculateBBox(visitedRelations):rm.getMember().getBBox();462 BBox box = rm.isRelation() ? rm.getRelation().calculateBBox(visitedRelations) : rm.getMember().getBBox(); 463 463 if (box != null) { 464 464 if (result == null) { -
trunk/src/org/openstreetmap/josm/data/osm/RelationMember.java
r8291 r8510 94 94 */ 95 95 public Relation getRelation() { 96 return (Relation)member; 96 return (Relation) member; 97 97 } 98 98 … … 103 103 */ 104 104 public Way getWay() { 105 return (Way)member; 105 return (Way) member; 106 106 } 107 107 … … 112 112 */ 113 113 public Node getNode() { 114 return (Node)member; 114 return (Node) member; 115 115 } 116 116 -
trunk/src/org/openstreetmap/josm/data/osm/RelationMemberData.java
r6830 r8510 9 9 10 10 public RelationMemberData(String role, OsmPrimitiveType type, long id) { 11 this.role = role == null ?"":role;11 this.role = role == null ? "" : role; 12 12 this.memberType = type; 13 13 this.memberId = id; -
trunk/src/org/openstreetmap/josm/data/osm/RelationToChildReference.java
r7005 r8510 18 18 Set<RelationToChildReference> references = new HashSet<>(); 19 19 for (Relation parent: parents) { 20 for (int i =0; i < parent.getMembersCount(); i++) {20 for (int i = 0; i < parent.getMembersCount(); i++) { 21 21 if (parent.getMember(i).refersTo(child)) { 22 22 references.add(new RelationToChildReference(parent, i, parent.getMember(i))); … … 87 87 return result; 88 88 } 89 89 90 @Override 90 91 public boolean equals(Object obj) { -
trunk/src/org/openstreetmap/josm/data/osm/Storage.java
r8470 r8510 75 75 @Override 76 76 public int getHashCode(PrimitiveId k) { 77 return (int)k.getUniqueId() ^ k.getType().hashCode(); 77 return (int) k.getUniqueId() ^ k.getType().hashCode(); 78 78 } 79 79 … … 85 85 } 86 86 87 private final Hash<? super T,? super T> hash; 87 private final Hash<? super T, ? super T> hash; 88 88 private T[] data; 89 89 private int mask; … … 109 109 } 110 110 111 public Storage(Hash<? super T,? super T> ha) { 111 public Storage(Hash<? super T, ? super T> ha) { 112 112 this(ha, DEFAULT_CAPACITY, false); 113 113 } … … 121 121 } 122 122 123 public Storage(Hash<? super T,? super T> ha, boolean safeIterator) { 123 public Storage(Hash<? super T, ? super T> ha, boolean safeIterator) { 124 124 this(ha, DEFAULT_CAPACITY, safeIterator); 125 125 } … … 140 140 public Storage(Hash<? super T, ? super T> ha, int capacity, boolean safeIterator) { 141 141 this.hash = ha; 142 int cap = 1 << (int)(Math.ceil(Math.log(capacity/loadFactor) / Math.log(2))); 142 int cap = 1 << (int) (Math.ceil(Math.log(capacity/loadFactor) / Math.log(2))); 143 143 @SuppressWarnings("unchecked") T[] newData = (T[]) new Object[cap]; 144 144 data = newData; … … 195 195 modCount++; 196 196 size = 0; 197 for (int i = 0; i <data.length; i++) {197 for (int i = 0; i < data.length; i++) { 198 198 data[i] = null; 199 199 } … … 257 257 } 258 258 259 public <K> Map<K,T> foreignKey(Hash<K,? super T> h) { 259 public <K> Map<K, T> foreignKey(Hash<K, ? super T> h) { 260 260 return new FMap<>(h); 261 261 } … … 278 278 * where such an entry can be stored. 279 279 */ 280 private <K> int getBucket(Hash<K,? super T> ha, K key) { 280 private <K> int getBucket(Hash<K, ? super T> ha, K key) { 281 281 T entry; 282 282 int hcode = rehash(ha.getHashCode(key)); … … 309 309 // because the entry safely belongs to <previous_null+1,hole> 310 310 if ((bucket < right && (right <= hole || hole <= bucket)) || 311 (right <=hole && hole <= bucket)) { 311 (right <= hole && hole <= bucket)) { 312 312 313 313 data[hole] = data[bucket]; … … 348 348 * hashCode and equals. 349 349 */ 350 public static <O> Hash<O,O> defaultHash() { 351 return new Hash<O,O>() { 350 public static <O> Hash<O, O> defaultHash() { 351 return new Hash<O, O>() { 352 352 @Override 353 353 public int getHashCode(O t) { 354 354 return t.hashCode(); 355 355 } 356 356 357 @Override 357 358 public boolean equals(O t1, O t2) { … … 373 374 */ 374 375 375 private final class FMap<K> implements Map<K,T> { 376 private Hash<K,? super T> fHash; 377 378 private FMap(Hash<K,? super T> h) { 376 private final class FMap<K> implements Map<K, T> { 377 private Hash<K, ? super T> fHash; 378 379 private FMap(Hash<K, ? super T> h) { 379 380 fHash = h; 380 381 } … … 488 489 } 489 490 490 491 491 private final class Iter implements Iterator<T> { 492 492 private final int mods; -
trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java
r8444 r8510 73 73 * @return the tag collection 74 74 */ 75 public static TagCollection from(Map<String,String> tags) { 75 public static TagCollection from(Map<String, String> tags) { 76 76 TagCollection ret = new TagCollection(); 77 77 if (tags == null) return ret; 78 for (Entry<String,String> entry: tags.entrySet()) { 79 String key = entry.getKey() == null? "" : entry.getKey(); 78 for (Entry<String, String> entry: tags.entrySet()) { 79 String key = entry.getKey() == null ? "" : entry.getKey(); 80 80 String value = entry.getValue() == null ? "" : entry.getValue(); 81 ret.add(new Tag(key,value)); 81 ret.add(new Tag(key, value)); 82 82 } 83 83 return ret; … … 199 199 * @param tag the tag to add 200 200 */ 201 public final void add(Tag tag){ 201 public final void add(Tag tag) { 202 202 if (tag == null) return; 203 203 if (tags.contains(tag)) return; … … 213 213 public final void add(Collection<Tag> tags) { 214 214 if (tags == null) return; 215 for (Tag tag: tags){ 215 for (Tag tag: tags) { 216 216 add(tag); 217 217 } … … 269 269 */ 270 270 public void removeByKey(String key) { 271 if (key 271 if (key == null) return; 272 272 Iterator<Tag> it = tags.iterator(); 273 while(it.hasNext()) { 273 while (it.hasNext()) { 274 274 if (it.next().matchesKey(key)) { 275 275 it.remove(); … … 461 461 if (keys == null) 462 462 return ret; 463 for(String key : keys) { 463 for (String key : keys) { 464 464 if (key != null) { 465 465 ret.add(getTagsFor(key)); … … 520 520 for (Tag tag: tags) { 521 521 Integer v = counters.get(tag.getKey()); 522 counters.put(tag.getKey(), (v==null) ? 1 : v+1);522 counters.put(tag.getKey(), (v == null) ? 1 : v+1); 523 523 } 524 524 Set<String> ret = new HashSet<>(); … … 718 718 public TagCollection emptyTagsForKeysMissingIn(TagCollection other) { 719 719 TagCollection ret = new TagCollection(); 720 for(String key: this.minus(other).getKeys()) { 720 for (String key: this.minus(other).getKeys()) { 721 721 ret.add(new Tag(key)); 722 722 } … … 778 778 } 779 779 780 781 780 @Override 782 781 public String toString() { -
trunk/src/org/openstreetmap/josm/data/osm/Tagged.java
r3083 r8510 17 17 * @param keys the map of key value pairs. If null, reset to the empty map. 18 18 */ 19 void setKeys(Map<String,String> keys); 19 void setKeys(Map<String, String> keys); 20 20 21 21 /** … … 24 24 * @return the map of key/value pairs 25 25 */ 26 Map<String,String> getKeys(); 26 Map<String, String> getKeys(); 27 27 28 28 /** -
trunk/src/org/openstreetmap/josm/data/osm/User.java
r8470 r8510 29 29 * the map of known users 30 30 */ 31 private static Map<Long,User> userMap = new HashMap<>(); 31 private static Map<Long, User> userMap = new HashMap<>(); 32 32 33 33 /** … … 49 49 */ 50 50 public static synchronized User createLocalUser(String name) { 51 for(long i = -1; i >= uidCounter; --i) { 51 for (long i = -1; i >= uidCounter; --i) { 52 52 User olduser = getById(i); 53 if(olduser != null && olduser.hasName(name)) 53 if (olduser != null && olduser.hasName(name)) 54 54 return olduser; 55 55 } -
trunk/src/org/openstreetmap/josm/data/osm/UserInfo.java
r6349 r8510 35 35 return id; 36 36 } 37 37 38 public void setId(int id) { 38 39 this.id = id; 39 40 } 41 40 42 public String getDisplayName() { 41 43 return displayName; 42 44 } 45 43 46 public void setDisplayName(String displayName) { 44 47 this.displayName = displayName; 45 48 } 49 46 50 public Date getAccountCreated() { 47 51 return accountCreated; 48 52 } 53 49 54 public void setAccountCreated(Date accountCreated) { 50 55 this.accountCreated = accountCreated; 51 56 } 57 52 58 public LatLon getHome() { 53 59 return home; 54 60 } 61 55 62 public void setHome(LatLon home) { 56 63 this.home = home; 57 64 } 65 58 66 public String getDescription() { 59 67 return description; 60 68 } 69 61 70 public void setDescription(String description) { 62 71 this.description = description; 63 72 } 73 64 74 public List<String> getLanguages() { 65 75 return languages; 66 76 } 77 67 78 public void setLanguages(List<String> languages) { 68 79 this.languages = languages; -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r8509 r8510 84 84 Node last = null; 85 85 int count = nodes.size(); 86 for(int i = 0; i < count && count > 2;) { 86 for (int i = 0; i < count && count > 2;) { 87 87 Node n = nodes.get(i); 88 if(last == n) { 88 if (last == n) { 89 89 nodes.remove(i); 90 90 --count; … … 173 173 174 174 Node[] nodes = this.nodes; 175 for (int i =0; i<nodes.length; i++) {175 for (int i = 0; i < nodes.length; i++) { 176 176 if (nodes[i].equals(node)) { 177 177 if (i > 0) … … 192 192 * @since 3348 193 193 */ 194 public List<Pair<Node,Node>> getNodePairs(boolean sort) { 195 List<Pair<Node,Node>> chunkSet = new ArrayList<>(); 194 public List<Pair<Node, Node>> getNodePairs(boolean sort) { 195 List<Pair<Node, Node>> chunkSet = new ArrayList<>(); 196 196 if (isIncomplete()) return chunkSet; 197 197 Node lastN = null; … … 202 202 continue; 203 203 } 204 Pair<Node,Node> np = new Pair<>(lastN, n); 204 Pair<Node, Node> np = new Pair<>(lastN, n); 205 205 if (sort) { 206 206 Pair.sort(np); … … 293 293 List<Node> newNodes = new ArrayList<>(wayData.getNodes().size()); 294 294 for (Long nodeId : wayData.getNodes()) { 295 Node node = (Node)getDataSet().getPrimitiveById(nodeId, OsmPrimitiveType.NODE); 295 Node node = (Node) getDataSet().getPrimitiveById(nodeId, OsmPrimitiveType.NODE); 296 296 if (node != null) { 297 297 newNodes.add(node); … … 321 321 try { 322 322 super.cloneFrom(osm); 323 Way otherWay = (Way)osm; 323 Way otherWay = (Way) osm; 324 324 setNodes(otherWay.getNodes()); 325 325 } finally { … … 330 330 @Override 331 331 public String toString() { 332 String nodesDesc = isIncomplete() ?"(incomplete)":"nodes=" + Arrays.toString(nodes);332 String nodesDesc = isIncomplete() ? "(incomplete)" : "nodes=" + Arrays.toString(nodes); 333 333 return "{Way id=" + getUniqueId() + " version=" + getVersion()+ " " + getFlagsAsString() + " " + nodesDesc + "}"; 334 334 } … … 340 340 if (!super.hasEqualSemanticAttributes(other)) 341 341 return false; 342 Way w = (Way)other; 342 Way w = (Way) other; 343 343 if (getNodesCount() != w.getNodesCount()) return false; 344 for (int i =0; i<getNodesCount(); i++) {344 for (int i = 0; i < getNodesCount(); i++) { 345 345 if (!getNode(i).hasEqualSemanticAttributes(w.getNode(i))) 346 346 return false; … … 426 426 */ 427 427 public void addNode(Node n) { 428 if (n ==null) return;428 if (n == null) return; 429 429 430 430 boolean locked = writeLock(); … … 453 453 */ 454 454 public void addNode(int offs, Node n) throws IndexOutOfBoundsException { 455 if (n ==null) return;455 if (n == null) return; 456 456 457 457 boolean locked = writeLock(); … … 510 510 if (this.nodes.length >= 4 && isClosed()) { 511 511 Node distinctNode = null; 512 for (int i =1; i<nodes.length-1; i++) {512 for (int i = 1; i < nodes.length-1; i++) { 513 513 if (distinctNode == null && nodes[i] != nodes[0]) { 514 514 distinctNode = nodes[i]; -
trunk/src/org/openstreetmap/josm/data/osm/WaySegment.java
r7509 r8510 42 42 * @return the second node 43 43 */ 44 public Node getSecondNode(){ 44 public Node getSecondNode() { 45 45 return way.getNode(lowerIndex + 1); 46 46 } -
trunk/src/org/openstreetmap/josm/data/osm/event/DatasetEventManager.java
r8509 r8510 122 122 @Override 123 123 public boolean equals(Object o) { 124 return o instanceof ListenerInfo && ((ListenerInfo)o).listener == listener; 124 return o instanceof ListenerInfo && ((ListenerInfo) o).listener == listener; 125 125 } 126 126 } -
trunk/src/org/openstreetmap/josm/data/osm/event/SelectionEventManager.java
r8285 r8510 40 40 @Override 41 41 public boolean equals(Object o) { 42 return o instanceof ListenerInfo && ((ListenerInfo)o).listener == listener; 42 return o instanceof ListenerInfo && ((ListenerInfo) o).listener == listener; 43 43 } 44 44 } -
trunk/src/org/openstreetmap/josm/data/osm/history/History.java
r8390 r8510 32 32 } 33 33 } 34 return new History(history.id, history.type,out); 34 return new History(history.id, history.type, out); 35 35 } 36 36 … … 96 96 } 97 97 ); 98 return new History(id, type,copy); 98 return new History(id, type, copy); 99 99 } 100 100 … … 232 232 public boolean contains(long version) { 233 233 for (HistoryOsmPrimitive primitive: versions) { 234 if (primitive.matches(id,version)) 234 if (primitive.matches(id, version)) 235 235 return true; 236 236 } … … 247 247 public HistoryOsmPrimitive getByVersion(long version) { 248 248 for (HistoryOsmPrimitive primitive: versions) { 249 if (primitive.matches(id,version)) 249 if (primitive.matches(id, version)) 250 250 return primitive; 251 251 } … … 265 265 if (h.versions.isEmpty()) 266 266 return null; 267 if (h.get(0).getTimestamp().compareTo(date)> 0) 267 if (h.get(0).getTimestamp().compareTo(date) > 0) 268 268 return null; 269 for (int i = 1; i < h.versions.size();i++) { 269 for (int i = 1; i < h.versions.size(); i++) { 270 270 if (h.get(i-1).getTimestamp().compareTo(date) <= 0 271 271 && h.get(i).getTimestamp().compareTo(date) >= 0) -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryDataSet.java
r8413 r8510 90 90 * type <code>type</code>, and version <code>version</code> 91 91 */ 92 public HistoryOsmPrimitive get(long id, OsmPrimitiveType type, long version){ 92 public HistoryOsmPrimitive get(long id, OsmPrimitiveType type, long version) { 93 93 if (id <= 0) 94 94 throw new IllegalArgumentException(MessageFormat.format("Parameter ''{0}'' > 0 expected, got {1}", "id", id)); … … 204 204 /* irrelevant in this context */ 205 205 } 206 206 207 @Override 207 208 public void layerAdded(Layer newLayer) { 208 209 /* irrelevant in this context */ 209 210 } 211 210 212 @Override 211 213 public void layerRemoved(Layer oldLayer) { -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryNameFormatter.java
r3083 r8510 4 4 public interface HistoryNameFormatter { 5 5 String format(HistoryNode node); 6 6 7 String format(HistoryWay node); 8 7 9 String format(HistoryRelation node); 8 10 } -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryOsmPrimitive.java
r8376 r8510 128 128 return visible; 129 129 } 130 130 131 public User getUser() { 131 132 return user; 132 133 } 134 133 135 public long getChangesetId() { 134 136 return changesetId; 135 137 } 138 136 139 public Date getTimestamp() { 137 140 return timestamp; … … 171 174 } 172 175 173 public Map<String,String> getTags() { 176 public Map<String, String> getTags() { 174 177 return Collections.unmodifiableMap(tags); 175 178 } … … 189 192 * @param tags the tags. May be null. 190 193 */ 191 public void setTags(Map<String,String> tags) { 194 public void setTags(Map<String, String> tags) { 192 195 if (tags == null) { 193 196 this.tags = new HashMap<>(); -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryRelation.java
r8291 r8510 112 112 public RelationMemberData getRelationMember(int idx) throws IndexOutOfBoundsException { 113 113 if (idx < 0 || idx >= members.size()) 114 throw new IndexOutOfBoundsException(MessageFormat.format("Parameter {0} not in range 0..{1}. Got ''{2}''.", "idx", members.size(),idx)); 114 throw new IndexOutOfBoundsException( 115 MessageFormat.format("Parameter {0} not in range 0..{1}. Got ''{2}''.", "idx", members.size(), idx)); 115 116 return members.get(idx); 116 117 } -
trunk/src/org/openstreetmap/josm/data/osm/history/HistoryWay.java
r8291 r8510 99 99 public long getNodeId(int idx) throws IndexOutOfBoundsException { 100 100 if (idx < 0 || idx >= nodeIds.size()) 101 throw new IndexOutOfBoundsException(tr("Parameter {0} not in range 0..{1}. Got ''{2}''.", "idx", nodeIds.size(),idx)); 101 throw new IndexOutOfBoundsException(tr("Parameter {0} not in range 0..{1}. Got ''{2}''.", "idx", nodeIds.size(), idx)); 102 102 return nodeIds.get(idx); 103 103 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/BoundingXYVisitor.java
r8470 r8510 65 65 if (latlon != null) { 66 66 if (latlon instanceof CachedLatLon) { 67 visit(((CachedLatLon)latlon).getEastNorth()); 67 visit(((CachedLatLon) latlon).getEastNorth()); 68 68 } else { 69 69 visit(Main.getProjection().latlon2eastNorth(latlon)); … … 179 179 } 180 180 181 182 @Overridepublic String toString() {181 @Override 182 public String toString() { 183 183 return "BoundingXYVisitor["+bounds+"]"; 184 184 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java
r8291 r8510 95 95 RelationData clone; 96 96 if (isAlreadyRemembered(r)) { 97 clone = (RelationData)mappedPrimitives.get(r); 97 clone = (RelationData) mappedPrimitives.get(r); 98 98 } else { 99 99 clone = r.save(); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/LineClip.java
r8509 r8510 77 77 } else { 78 78 long x = 0, y = 0; 79 outcodeOut = outcode0 != 0 ? outcode0: outcode1; 79 outcodeOut = outcode0 != 0 ? outcode0 : outcode1; 80 80 if ((outcodeOut & OUT_TOP) > 0) { 81 81 x = x1 + (x2 - x1) * (ymax - y1)/(y2 - y1); … … 84 84 x = x1 + (x2 - x1) * (ymin - y1)/(y2 - y1); 85 85 y = ymin; 86 } else if ((outcodeOut & OUT_RIGHT)> 0) { 86 } else if ((outcodeOut & OUT_RIGHT) > 0) { 87 87 y = y1 + (y2 - y1) * (xmax - x1)/(x2 - x1); 88 88 x = xmax; … … 104 104 while (!done); 105 105 106 if(accept) { 106 if (accept) { 107 107 p1 = new Point((int) x1, (int) y1); 108 108 p2 = new Point((int) x2, (int) y2); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapRendererFactory.java
r8509 r8510 121 121 } 122 122 123 private void activateMapRenderer(String rendererClassName){ 123 private void activateMapRenderer(String rendererClassName) { 124 124 Class<?> c = loadRendererClass(rendererClassName); 125 if (c == null){ 125 if (c == null) { 126 126 Main.error(tr("Can''t activate map renderer class ''{0}'', because the class wasn''t found.", rendererClassName)); 127 127 Main.error(tr("Activating the standard map renderer instead.")); … … 208 208 if (!isRegistered(renderer)) return; 209 209 Iterator<Descriptor> it = descriptors.iterator(); 210 while(it.hasNext()) { 210 while (it.hasNext()) { 211 211 Descriptor d = it.next(); 212 212 if (d.getRenderer().getName().equals(renderer.getName())) { … … 262 262 */ 263 263 public AbstractMapRenderer createActiveRenderer(Graphics2D g, NavigatableComponent viewport, boolean isInactiveMode) 264 throws MapRendererFactoryException{ 264 throws MapRendererFactoryException { 265 265 try { 266 266 Constructor<?> c = activeRenderer.getConstructor(new Class<?>[]{Graphics2D.class, NavigatableComponent.class, boolean.class}); 267 267 return AbstractMapRenderer.class.cast(c.newInstance(g, viewport, isInactiveMode)); 268 } catch(NoSuchMethodException | IllegalArgumentException | InstantiationException | IllegalAccessException e){ 268 } catch (NoSuchMethodException | IllegalArgumentException | InstantiationException | IllegalAccessException e) { 269 269 throw new MapRendererFactoryException(e); 270 270 } catch (InvocationTargetException e) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/PaintColors.java
r8126 r8510 21 21 CONNECTION(marktr("Node: connection"), Color.yellow), 22 22 TAGGED(marktr("Node: tagged"), new Color(204, 255, 255)), // light cyan 23 DEFAULT_WAY(marktr("way"), new Color(0, 0,128)), // dark blue24 RELATION(marktr("relation"), new Color(0, 128,128)), // teal25 UNTAGGED_WAY(marktr("untagged way"), new Color(0, 128,0)), // dark green23 DEFAULT_WAY(marktr("way"), new Color(0, 0, 128)), // dark blue 24 RELATION(marktr("relation"), new Color(0, 128, 128)), // teal 25 UNTAGGED_WAY(marktr("untagged way"), new Color(0, 128, 0)), // dark green 26 26 BACKGROUND(marktr("background"), Color.BLACK), 27 27 HIGHLIGHT(marktr("highlight"), SELECTED.get()), 28 28 HIGHLIGHT_WIREFRAME(marktr("highlight wireframe"), Color.orange), 29 29 30 UNTAGGED(marktr("untagged"),Color.GRAY), 30 UNTAGGED(marktr("untagged"), Color.GRAY), 31 31 TEXT(marktr("text"), Color.WHITE), 32 32 AREA_TEXT(marktr("areatext"), Color.LIGHT_GRAY); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r8509 r8510 149 149 int yCurrent0 = current.y - (int) Math.round(offset * dxNext / lenNext); 150 150 151 if (idx ==0) {151 if (idx == 0) { 152 152 ++idx; 153 153 prev = current; … … 172 172 int m = dxNext*(yCurrent0 - yPrev0) - dyNext*(xCurrent0 - xPrev0); 173 173 174 int cx = xPrev0 + (int) Math.round((double)m * dxPrev / det); 175 int cy = yPrev0 + (int) Math.round((double)m * dyPrev / det); 174 int cx = xPrev0 + (int) Math.round((double) m * dxPrev / det); 175 int cy = yPrev0 + (int) Math.round((double) m * dyPrev / det); 176 176 ++idx; 177 177 prev = current; … … 238 238 } 239 239 240 private static Map<Font,Boolean> IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG = new HashMap<>(); 240 private static Map<Font, Boolean> IS_GLYPH_VECTOR_DOUBLE_TRANSLATION_BUG = new HashMap<>(); 241 241 242 242 /** … … 335 335 super(g, nc, isInactiveMode); 336 336 337 if (nc !=null) {337 if (nc != null) { 338 338 Component focusOwner = FocusManager.getCurrentManager().getFocusOwner(); 339 339 useWiderHighlight = !(focusOwner instanceof AbstractButton || focusOwner == nc); … … 364 364 g.draw(path); 365 365 366 if(!isInactiveMode && useStrokes && dashes != null) { 366 if (!isInactiveMode && useStrokes && dashes != null) { 367 367 g.setColor(dashedColor); 368 368 g.setStroke(dashes); … … 486 486 final double h = pb.height - nb.getHeight(); 487 487 488 final int x2 = pb.x + (int)(w/2.0); 489 final int y2 = pb.y + (int)(h/2.0); 488 final int x2 = pb.x + (int) (w/2.0); 489 final int y2 = pb.y + (int) (h/2.0); 490 490 491 491 final int nbw = (int) nb.getWidth(); … … 498 498 if (!labelOK) { 499 499 // if center position (C) is not inside osm shape, try naively some other positions as follows: 500 final int x1 = pb.x + (int) (w/4.0);501 final int x3 = pb.x + (int)(3*w/4.0); 502 final int y1 = pb.y + (int) (h/4.0);503 final int y3 = pb.y + (int)(3*h/4.0); 500 final int x1 = pb.x + (int) (w/4.0); 501 final int x3 = pb.x + (int) (3*w/4.0); 502 final int y1 = pb.y + (int) (h/4.0); 503 final int y3 = pb.y + (int) (3*h/4.0); 504 504 // +-----------+ 505 505 // | 5 1 6 | … … 526 526 if (labelOK) { 527 527 Font defaultFont = g.getFont(); 528 int x = (int)(centeredNBounds.getMinX() - nb.getMinX()); 529 int y = (int)(centeredNBounds.getMinY() - nb.getMinY()); 528 int x = (int) (centeredNBounds.getMinX() - nb.getMinX()); 529 int y = (int) (centeredNBounds.getMinY() - nb.getMinY()); 530 530 displayText(null, name, x, y, osm.isDisabled(), text); 531 531 g.setFont(defaultFont); … … 707 707 @Override 708 708 public void drawNode(Node n, Color color, int size, boolean fill) { 709 if(size <= 0 && !n.isHighlighted()) 709 if (size <= 0 && !n.isHighlighted()) 710 710 return; 711 711 712 712 Point p = nc.getPoint(n); 713 713 714 if(n.isHighlighted()) { 714 if (n.isHighlighted()) { 715 715 drawPointHighlight(p, size); 716 716 } … … 737 737 738 738 final int w = img.getWidth(), h = img.getHeight(); 739 if(n.isHighlighted()) { 739 if (n.isHighlighted()) { 740 740 drawPointHighlight(p, Math.max(w, h)); 741 741 } … … 768 768 int radius = s.size / 2; 769 769 770 if(n.isHighlighted()) { 770 if (n.isHighlighted()) { 771 771 drawPointHighlight(p, s.size); 772 772 } … … 861 861 */ 862 862 private void drawPathHighlight(GeneralPath path, BasicStroke line) { 863 if(path == null) 863 if (path == null) 864 864 return; 865 865 g.setColor(highlightColorTransparent); 866 866 float w = line.getLineWidth() + highlightLineWidth; 867 if (useWiderHighlight) w +=widerHighlight;868 while(w >= line.getLineWidth()) { 867 if (useWiderHighlight) w += widerHighlight; 868 while (w >= line.getLineWidth()) { 869 869 g.setStroke(new BasicStroke(w, line.getEndCap(), line.getLineJoin(), line.getMiterLimit())); 870 870 g.draw(path); … … 879 879 g.setColor(highlightColorTransparent); 880 880 int s = size + highlightPointRadius; 881 if (useWiderHighlight) s +=widerHighlight;882 while(s >= size) { 881 if (useWiderHighlight) s += widerHighlight; 882 while (s >= size) { 883 883 int r = (int) Math.floor(s/2d); 884 884 g.fillRoundRect(p.x-r, p.y-r, s, s, r, r); … … 890 890 // rotate image with direction last node in from to, and scale down image to 16*16 pixels 891 891 Image smallImg = ImageProvider.createRotatedImage(img, angle, new Dimension(16, 16)); 892 int w = smallImg.getWidth(null), h =smallImg.getHeight(null);893 g.drawImage(smallImg, (int)(pVia.x+vx+vx2)-w/2, (int)(pVia.y+vy+vy2)-h/2, nc); 892 int w = smallImg.getWidth(null), h = smallImg.getHeight(null); 893 g.drawImage(smallImg, (int) (pVia.x+vx+vx2)-w/2, (int) (pVia.y+vy+vy2)-h/2, nc); 894 894 895 895 if (selected) { 896 896 g.setColor(isInactiveMode ? inactiveColor : relationSelectedColor); 897 g.drawRect((int)(pVia.x+vx+vx2)-w/2-2, (int)(pVia.y+vy+vy2)-h/2-2, w+4, h+4);897 g.drawRect((int) (pVia.x+vx+vx2)-w/2-2, (int) (pVia.y+vy+vy2)-h/2-2, w+4, h+4); 898 898 } 899 899 } … … 906 906 /* find the "from", "via" and "to" elements */ 907 907 for (RelationMember m : r.getMembers()) { 908 if(m.getMember().isIncomplete()) 908 if (m.getMember().isIncomplete()) 909 909 return; 910 910 else { 911 if(m.isWay()) { 911 if (m.isWay()) { 912 912 Way w = m.getWay(); 913 if(w.getNodesCount() < 2) { 913 if (w.getNodesCount() < 2) { 914 914 continue; 915 915 } … … 917 917 switch(m.getRole()) { 918 918 case "from": 919 if(fromWay == null) { 919 if (fromWay == null) { 920 920 fromWay = w; 921 921 } 922 922 break; 923 923 case "to": 924 if(toWay == null) { 924 if (toWay == null) { 925 925 toWay = w; 926 926 } 927 927 break; 928 928 case "via": 929 if(via == null) { 929 if (via == null) { 930 930 via = w; 931 931 } 932 932 } 933 } else if(m.isNode()) { 933 } else if (m.isNode()) { 934 934 Node n = m.getNode(); 935 if("via".equals(m.getRole()) && via == null) { 935 if ("via".equals(m.getRole()) && via == null) { 936 936 via = n; 937 937 } … … 944 944 945 945 Node viaNode; 946 if(via instanceof Node) { 946 if (via instanceof Node) { 947 947 viaNode = (Node) via; 948 if(!fromWay.isFirstLastNode(viaNode)) 948 if (!fromWay.isFirstLastNode(viaNode)) 949 949 return; 950 950 } else { … … 955 955 956 956 String onewayviastr = viaWay.get("oneway"); 957 if(onewayviastr != null) { 958 if("-1".equals(onewayviastr)) { 957 if (onewayviastr != null) { 958 if ("-1".equals(onewayviastr)) { 959 959 onewayvia = Boolean.TRUE; 960 960 Node tmp = firstNode; … … 969 969 } 970 970 971 if(fromWay.isFirstLastNode(firstNode)) { 971 if (fromWay.isFirstLastNode(firstNode)) { 972 972 viaNode = firstNode; 973 973 } else if (!onewayvia && fromWay.isFirstLastNode(lastNode)) { … … 979 979 /* find the "direct" nodes before the via node */ 980 980 Node fromNode; 981 if(fromWay.firstNode() == via) { 981 if (fromWay.firstNode() == via) { 982 982 fromNode = fromWay.getNode(1); 983 983 } else { … … 992 992 away from the "via" node along the first segment of the "from" way) 993 993 */ 994 double distanceFromVia =14;994 double distanceFromVia = 14; 995 995 double dx = pFrom.x >= pVia.x ? pFrom.x - pVia.x : pVia.x - pFrom.x; 996 996 double dy = pFrom.y >= pVia.y ? pFrom.y - pVia.y : pVia.y - pFrom.y; … … 1007 1007 double vy = distanceFromVia * Math.sin(fromAngle); 1008 1008 1009 if(pFrom.x < pVia.x) { 1009 if (pFrom.x < pVia.x) { 1010 1010 vx = -vx; 1011 1011 } 1012 if(pFrom.y < pVia.y) { 1012 if (pFrom.y < pVia.y) { 1013 1013 vy = -vy; 1014 1014 } … … 1018 1018 90degrees away from the first segment of the "from" way) 1019 1019 */ 1020 double distanceFromWay =10;1020 double distanceFromWay = 10; 1021 1021 double vx2 = 0; 1022 1022 double vy2 = 0; 1023 1023 double iconAngle = 0; 1024 1024 1025 if(pFrom.x >= pVia.x && pFrom.y >= pVia.y) { 1026 if(!leftHandTraffic) { 1025 if (pFrom.x >= pVia.x && pFrom.y >= pVia.y) { 1026 if (!leftHandTraffic) { 1027 1027 vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg - 90)); 1028 1028 vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg - 90)); … … 1033 1033 iconAngle = 270+fromAngleDeg; 1034 1034 } 1035 if(pFrom.x < pVia.x && pFrom.y >= pVia.y) { 1036 if(!leftHandTraffic) { 1035 if (pFrom.x < pVia.x && pFrom.y >= pVia.y) { 1036 if (!leftHandTraffic) { 1037 1037 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg)); 1038 1038 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg)); … … 1043 1043 iconAngle = 90-fromAngleDeg; 1044 1044 } 1045 if(pFrom.x < pVia.x && pFrom.y < pVia.y) { 1046 if(!leftHandTraffic) { 1045 if (pFrom.x < pVia.x && pFrom.y < pVia.y) { 1046 if (!leftHandTraffic) { 1047 1047 vx2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 90)); 1048 1048 vy2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 90)); … … 1053 1053 iconAngle = 90+fromAngleDeg; 1054 1054 } 1055 if(pFrom.x >= pVia.x && pFrom.y < pVia.y) { 1056 if(!leftHandTraffic) { 1055 if (pFrom.x >= pVia.x && pFrom.y < pVia.y) { 1056 if (!leftHandTraffic) { 1057 1057 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 180)); 1058 1058 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 180)); … … 1096 1096 poly.addPoint(p.x, p.y); 1097 1097 1098 if(lastPoint != null) { 1098 if (lastPoint != null) { 1099 1099 dx = p.x - lastPoint.x; 1100 1100 dy = p.y - lastPoint.y; … … 1149 1149 double bestDistanceToCenter = Double.MAX_VALUE; 1150 1150 double bestQuality = -1; 1151 for (int i =0; i<longHalfSegmentStart.size(); i++) {1151 for (int i = 0; i < longHalfSegmentStart.size(); i++) { 1152 1152 double start = longHalfSegmentStart.get(i); 1153 1153 double end = longHalfSegmentEnd.get(i); … … 1215 1215 GlyphVector gv = text.font.layoutGlyphVector(frc, chars, 0, chars.length, dirFlag); 1216 1216 1217 for (int i =0; i<gv.getNumGlyphs(); ++i) {1217 for (int i = 0; i < gv.getNumGlyphs(); ++i) { 1218 1218 Rectangle2D rect = gv.getGlyphLogicalBounds(i).getBounds2D(); 1219 1219 double t = tStart + offsetSign * (rect.getX() + rect.getWidth()/2) / pathLength; … … 1271 1271 continue; 1272 1272 } 1273 if(highlightSegs == null) { 1273 if (highlightSegs == null) { 1274 1274 highlightSegs = new GeneralPath(); 1275 1275 } … … 1333 1333 1334 1334 while (dist < segmentLength) { 1335 for (int i =0; i<2; ++i) {1335 for (int i = 0; i < 2; ++i) { 1336 1336 float onewaySize = i == 0 ? 3f : 2f; 1337 1337 GeneralPath onewayPath = i == 0 ? onewayArrowsCasing : onewayArrows; … … 1361 1361 lastPoint = p; 1362 1362 } 1363 if(way.isHighlighted()) { 1363 if (way.isHighlighted()) { 1364 1364 drawPathHighlight(path, line); 1365 1365 } … … 1499 1499 MapCSSStyleSource.STYLE_SOURCE_LOCK.readLock().lock(); 1500 1500 try { 1501 for (int i = from; i <to; i++) {1501 for (int i = from; i < to; i++) { 1502 1502 OsmPrimitive osm = input.get(i); 1503 1503 if (osm.isDrawable()) { … … 1601 1601 final int noBuckets = (prims.size() + bucketsize - 1) / bucketsize; 1602 1602 final boolean singleThread = THREAD_POOL.a == 1 || noBuckets == 1; 1603 for (int i =0; i<noBuckets; i++) {1603 for (int i = 0; i < noBuckets; i++) { 1604 1604 int from = i*bucketsize; 1605 1605 int to = Math.min((i+1)*bucketsize, prims.size()); … … 1636 1636 highlightWaySegments = data.getHighlightedWaySegments(); 1637 1637 1638 long timeStart =0, timePhase1=0, timeFinished;1638 long timeStart = 0, timePhase1 = 0, timeFinished; 1639 1639 if (Main.isTraceEnabled()) { 1640 1640 timeStart = System.currentTimeMillis(); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/WireframeMapRenderer.java
r8444 r8510 170 170 List<Way> untaggedWays = new ArrayList<>(); 171 171 172 for (final Way way : data.searchWays(bbox)){ 172 for (final Way way : data.searchWays(bbox)) { 173 173 if (way.isDrawable() && !ds.isSelected(way) && !way.isDisabledAndHidden()) { 174 174 if (way.isHighlighted()) { … … 186 186 List<Way> specialWays = new ArrayList<>(untaggedWays); 187 187 specialWays.addAll(highlightedWays); 188 for (final Way way : specialWays){ 188 for (final Way way : specialWays) { 189 189 way.accept(this); 190 190 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
r8465 r8510 95 95 Collection<String> literals; 96 96 literals = Main.pref.getCollection(PREF_KEY_OUTER_ROLES); 97 if (literals != null && !literals.isEmpty()){ 97 if (literals != null && !literals.isEmpty()) { 98 98 setNormalized(literals, outerExactRoles); 99 99 } 100 100 literals = Main.pref.getCollection(PREF_KEY_OUTER_ROLE_PREFIXES); 101 if (literals != null && !literals.isEmpty()){ 101 if (literals != null && !literals.isEmpty()) { 102 102 setNormalized(literals, outerRolePrefixes); 103 103 } 104 104 literals = Main.pref.getCollection(PREF_KEY_INNER_ROLES); 105 if (literals != null && !literals.isEmpty()){ 105 if (literals != null && !literals.isEmpty()) { 106 106 setNormalized(literals, innerExactRoles); 107 107 } 108 108 literals = Main.pref.getCollection(PREF_KEY_INNER_ROLE_PREFIXES); 109 if (literals != null && !literals.isEmpty()){ 109 if (literals != null && !literals.isEmpty()) { 110 110 setNormalized(literals, innerRolePrefixes); 111 111 } … … 117 117 PREF_KEY_INNER_ROLES.equals(evt.getKey()) || 118 118 PREF_KEY_OUTER_ROLE_PREFIXES.equals(evt.getKey()) || 119 PREF_KEY_OUTER_ROLES.equals(evt.getKey())){ 119 PREF_KEY_OUTER_ROLES.equals(evt.getKey())) { 120 120 initFromPreferences(); 121 121 } … … 149 149 */ 150 150 private static MultipolygonRoleMatcher roleMatcher; 151 151 152 private static synchronized MultipolygonRoleMatcher getMultipolygonRoleMatcher() { 152 153 if (roleMatcher == null) { 153 154 roleMatcher = new MultipolygonRoleMatcher(); 154 if (Main.pref != null){ 155 if (Main.pref != null) { 155 156 roleMatcher.initFromPreferences(); 156 157 Main.pref.addPreferenceChangeListener(roleMatcher); … … 302 303 if (ds == null) { 303 304 // DataSet still not found. This should not happen, but a warning does no harm 304 Main.warn("DataSet not found while resetting nodes in Multipolygon. This should not happen, you may report it to JOSM developers."); 305 Main.warn("DataSet not found while resetting nodes in Multipolygon. " + 306 "This should not happen, you may report it to JOSM developers."); 305 307 } else if (wayIds.size() == 1) { 306 308 Way w = (Way) ds.getPrimitiveById(wayIds.iterator().next(), OsmPrimitiveType.WAY); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/MultipolygonCache.java
r8374 r8510 210 210 pd.nodeMoved((NodeMovedEvent) event); 211 211 } else if (event instanceof WayNodesChangedEvent) { 212 pd.wayNodesChanged((WayNodesChangedEvent)event); 212 pd.wayNodesChanged((WayNodesChangedEvent) event); 213 213 } 214 214 } -
trunk/src/org/openstreetmap/josm/data/preferences/ColorProperty.java
r8404 r8510 42 42 */ 43 43 public static String getColorKey(String colName) { 44 return colName == null ? null : colName.toLowerCase(Locale.ENGLISH).replaceAll("[^a-z0-9]+","."); 44 return colName == null ? null : colName.toLowerCase(Locale.ENGLISH).replaceAll("[^a-z0-9]+", "."); 45 45 } 46 46 -
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r8509 r8510 352 352 return new CentricDatum(null, null, ellps); 353 353 boolean is3Param = true; 354 for (int i = 3; i <towgs84Param.size(); i++) {354 for (int i = 3; i < towgs84Param.size(); i++) { 355 355 if (towgs84Param.get(i) != 0) { 356 356 is3Param = false; -
trunk/src/org/openstreetmap/josm/data/projection/Ellipsoid.java
r8451 r8510 29 29 */ 30 30 public static final Ellipsoid AustSA = Ellipsoid.create_a_rf(6378160.0, 298.25); 31 31 32 32 /** 33 33 * Bessel 1841 ellipsoid 34 34 */ 35 35 public static final Ellipsoid Bessel1841 = Ellipsoid.create_a_rf(6377397.155, 299.1528128); 36 36 37 37 /** 38 38 * Clarke 1866 ellipsoid … … 251 251 double v1 = 1-e*Math.sin(phi); 252 252 double v2 = 1+e*Math.sin(phi); 253 return Math.log(Math.tan(Math.PI/4+phi/2)*Math.pow(v1/v2,e/2)); 253 return Math.log(Math.tan(Math.PI/4+phi/2)*Math.pow(v1/v2, e/2)); 254 254 } 255 255 … … 262 262 double v1 = 1-e*Math.sin(phi); 263 263 double v2 = 1+e*Math.sin(phi); 264 return Math.log(Math.tan(Math.PI/4+phi/2)*Math.pow(v1/v2,e/2)); 264 return Math.log(Math.tan(Math.PI/4+phi/2)*Math.pow(v1/v2, e/2)); 265 265 } 266 266 … … 275 275 double lati = lat0; 276 276 double lati1 = 1.0; // random value to start the iterative processus 277 while(Math.abs(lati1-lati) >=epsilon) {277 while (Math.abs(lati1-lati) >= epsilon) { 278 278 lati = lati1; 279 279 double v1 = 1+e*Math.sin(lati); 280 280 double v2 = 1-e*Math.sin(lati); 281 lati1 = 2*Math.atan(Math.pow(v1/v2,e/2)*Math.exp(latIso))-Math.PI/2; 281 lati1 = 2*Math.atan(Math.pow(v1/v2, e/2)*Math.exp(latIso))-Math.PI/2; 282 282 } 283 283 return lati1; -
trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java
r8470 r8510 312 312 NTV2SubGrid[] clone = new NTV2SubGrid[topLevelSubGrid.length]; 313 313 for (int i = 0; i < topLevelSubGrid.length; i++) { 314 clone[i] = (NTV2SubGrid)topLevelSubGrid[i].clone(); 314 clone[i] = (NTV2SubGrid) topLevelSubGrid[i].clone(); 315 315 } 316 316 return clone; -
trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java
r8470 r8510 105 105 readBytes(in, b8); 106 106 lonInterval = NTV2Util.getDouble(b8, bigEndian); 107 lonColumnCount = 1 + (int)((maxLon - minLon) / lonInterval); 108 latRowCount = 1 + (int)((maxLat - minLat) / latInterval); 107 lonColumnCount = 1 + (int) ((maxLon - minLon) / lonInterval); 108 latRowCount = 1 + (int) ((maxLat - minLat) / latInterval); 109 109 readBytes(in, b8); 110 110 readBytes(in, b8); … … 121 121 for (int i = 0; i < nodeCount; i++) { 122 122 // Read the grid file byte after byte. This is a workaround about a bug in 123 // certain VM which are not able to read byte blocks when the resource file is 124 // in a .jar file (Pieren) 123 // certain VM which are not able to read byte blocks when the resource file is in a .jar file (Pieren) 125 124 readBytes(in, b1); b4[0] = b1[0]; 126 125 readBytes(in, b1); b4[1] = b1[0]; … … 211 210 */ 212 211 private final double interpolate(float a, float b, float c, float d, double x, double y) { 213 return a + (((double)b - (double)a) * x) + (((double)c - (double)a) * y) + 214 (((double)a + (double)d - b - c) * x * y); 212 return a + (((double) b - (double) a) * x) + (((double) c - (double) a) * y) + 213 (((double) a + (double) d - b - c) * x * y); 215 214 } 216 215 … … 225 224 */ 226 225 public void interpolateGridShift(NTV2GridShift gs) { 227 int lonIndex = (int)((gs.getLonPositiveWestSeconds() - minLon) / lonInterval); 228 int latIndex = (int)((gs.getLatSeconds() - minLat) / latInterval); 226 int lonIndex = (int) ((gs.getLonPositiveWestSeconds() - minLon) / lonInterval); 227 int latIndex = (int) ((gs.getLatSeconds() - minLat) / latInterval); 229 228 230 229 double x = (gs.getLonPositiveWestSeconds() - (minLon + (lonInterval * lonIndex))) / lonInterval; … … 331 330 NTV2SubGrid clone = null; 332 331 try { 333 clone = (NTV2SubGrid)super.clone(); 332 clone = (NTV2SubGrid) super.clone(); 334 333 // Do a deep clone of the sub grids 335 334 if (subGrid != null) { 336 335 clone.subGrid = new NTV2SubGrid[subGrid.length]; 337 336 for (int i = 0; i < subGrid.length; i++) { 338 clone.subGrid[i] = (NTV2SubGrid)subGrid[i].clone(); 337 clone.subGrid[i] = (NTV2SubGrid) subGrid[i].clone(); 339 338 } 340 339 } … … 344 343 return clone; 345 344 } 345 346 346 /** 347 347 * Get maximum latitude value -
trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Util.java
r8374 r8510 100 100 j = getIntLE(b, 0); 101 101 } 102 long l = ((long)i << 32) | 102 long l = ((long) i << 32) | 103 103 (j & 0x00000000FFFFFFFFL); 104 104 return Double.longBitsToDouble(l); -
trunk/src/org/openstreetmap/josm/data/projection/proj/LambertConformalConic.java
r8444 r8510 31 31 public abstract static class Parameters { 32 32 public final double latitudeOrigin; 33 33 34 public Parameters(double latitudeOrigin) { 34 35 this.latitudeOrigin = latitudeOrigin; … … 45 46 public final double standardParallel1; 46 47 public final double standardParallel2; 48 47 49 public Parameters2SP(double latitudeOrigin, double standardParallel1, double standardParallel2) { 48 50 super(latitudeOrigin); … … 163 165 @Override 164 166 public double[] invproject(double east, double north) { 165 double r = sqrt(pow(east,2) + pow(north-r0, 2)); 167 double r = sqrt(pow(east, 2) + pow(north-r0, 2)); 166 168 double gamma = atan(east / (r0-north)); 167 169 double lambda = gamma/n; -
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r8378 r8510 168 168 pathDir.mkdirs(); 169 169 } 170 } catch (Exception e){ 170 } catch (Exception e) { 171 171 Main.error(e); 172 172 } … … 242 242 243 243 private static void applyPrefs(Map<String, Test> tests, boolean beforeUpload) { 244 for(String testName : Main.pref.getCollection(beforeUpload 244 for (String testName : Main.pref.getCollection(beforeUpload 245 245 ? ValidatorPreference.PREF_SKIP_TESTS_BEFORE_UPLOAD : ValidatorPreference.PREF_SKIP_TESTS)) { 246 246 Test test = tests.get(testName); -
trunk/src/org/openstreetmap/josm/data/validation/TestError.java
r8435 r8510 317 317 v.visit((WaySegment) o); 318 318 } else if (o instanceof List<?>) { 319 v.visit((List<Node>)o); 319 v.visit((List<Node>) o); 320 320 } 321 321 } … … 366 366 367 367 @Override public void primitivesAdded(PrimitivesAddedEvent event) {} 368 368 369 @Override public void tagsChanged(TagsChangedEvent event) {} 370 369 371 @Override public void nodeMoved(NodeMovedEvent event) {} 372 370 373 @Override public void wayNodesChanged(WayNodesChangedEvent event) {} 374 371 375 @Override public void relationMembersChanged(RelationMembersChangedEvent event) {} 376 372 377 @Override public void otherDatasetChange(AbstractDatasetChangedEvent event) {} 378 373 379 @Override public void dataChanged(DataChangedEvent event) {} 374 380 -
trunk/src/org/openstreetmap/josm/data/validation/ValidatorVisitor.java
r8378 r8510 10 10 public interface ValidatorVisitor { 11 11 void visit(TestError error); 12 12 13 void visit(OsmPrimitive p); 14 13 15 void visit(WaySegment ws); 16 14 17 void visit(List<Node> nodes); 15 18 } -
trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java
r8419 r8510 115 115 */ 116 116 public static DomainValidator getInstance(boolean allowLocal) { 117 if(allowLocal) { 117 if (allowLocal) { 118 118 return DOMAIN_VALIDATOR_WITH_LOCAL; 119 119 } … … 138 138 if (groups != null && groups.length > 0) { 139 139 return isValidTld(groups[0]); 140 } else if(allowLocal) { 140 } else if (allowLocal) { 141 141 if (hostnameRegex.isValid(domain)) { 142 142 return true; … … 154 154 */ 155 155 public boolean isValidTld(String tld) { 156 if(allowLocal && isValidLocalTld(tld)) { 156 if (allowLocal && isValidLocalTld(tld)) { 157 157 return true; 158 158 } -
trunk/src/org/openstreetmap/josm/data/validation/routines/EmailValidator.java
r7937 r8510 88 88 */ 89 89 public static EmailValidator getInstance(boolean allowLocal) { 90 if(allowLocal) { 90 if (allowLocal) { 91 91 return EMAIL_VALIDATOR_WITH_LOCAL; 92 92 } -
trunk/src/org/openstreetmap/josm/data/validation/routines/InetAddressValidator.java
r8461 r8510 82 82 try { 83 83 iIpSegment = Integer.parseInt(ipSegment); 84 } catch(NumberFormatException e) { 84 } catch (NumberFormatException e) { 85 85 return false; 86 86 } -
trunk/src/org/openstreetmap/josm/data/validation/routines/RegexValidator.java
r8394 r8510 107 107 } 108 108 patterns = new Pattern[regexs.length]; 109 int flags = caseSensitive ? 0: Pattern.CASE_INSENSITIVE; 109 int flags = caseSensitive ? 0 : Pattern.CASE_INSENSITIVE; 110 110 for (int i = 0; i < regexs.length; i++) { 111 111 if (regexs[i] == null || regexs[i].isEmpty()) { -
trunk/src/org/openstreetmap/josm/data/validation/routines/UrlValidator.java
r8509 r8510 405 405 406 406 String extra = authorityMatcher.group(PARSE_AUTHORITY_EXTRA); 407 if (extra != null && !extra.trim().isEmpty()){ 407 if (extra != null && !extra.trim().isEmpty()) { 408 408 return false; 409 409 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/Addresses.java
r8419 r8510 55 55 this(code, Collections.singleton(p), message); 56 56 } 57 57 58 public AddressError(int code, Collection<OsmPrimitive> collection, String message) { 58 59 this(code, collection, message, null, null); 59 60 } 61 60 62 public AddressError(int code, Collection<OsmPrimitive> collection, String message, String description, String englishDescription) { 61 63 this(code, Severity.WARNING, collection, message, description, englishDescription); 62 64 } 65 63 66 public AddressError(int code, Severity severity, Collection<OsmPrimitive> collection, String message, String description, 64 67 String englishDescription) { … … 207 210 centroid = ((Node) house).getEastNorth(); 208 211 } else if (house instanceof Way) { 209 List<Node> nodes = ((Way)house).getNodes(); 212 List<Node> nodes = ((Way) house).getNodes(); 210 213 if (house.hasKey(ADDR_INTERPOLATION)) { 211 214 for (Node n : nodes) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
r8378 r8510 40 40 41 41 /** All way segments, grouped by cells */ 42 private Map<Point2D,List<WaySegment>> cellSegments; 42 private Map<Point2D, List<WaySegment>> cellSegments; 43 43 /** The already detected errors */ 44 44 private Set<WaySegment> errorSegments; … … 181 181 */ 182 182 public CrossingWays(String title) { 183 super(title, tr("This test checks if two roads, railways, waterways or buildings crosses in the same layer, but are not connected by a node.")); 183 super(title, tr("This test checks if two roads, railways, waterways or buildings crosses in the same layer, " + 184 "but are not connected by a node.")); 184 185 } 185 186 -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
r8393 r8510 121 121 } 122 122 123 124 123 @SuppressWarnings("unchecked") 125 124 @Override … … 163 162 List<TestError> errors = new ArrayList<>(); 164 163 165 MultiMap<Map<String,String>, OsmPrimitive> mm = new MultiMap<>(); 164 MultiMap<Map<String, String>, OsmPrimitive> mm = new MultiMap<>(); 166 165 for (Node n: nodes) { 167 166 mm.put(n.getKeys(), n); 168 167 } 169 168 170 Map<String,Boolean> typeMap =new HashMap<>();169 Map<String, Boolean> typeMap = new HashMap<>(); 171 170 String[] types = {"none", "highway", "railway", "waterway", "boundary", "power", "natural", "landuse", "building"}; 172 171 173 174 // check whether we have multiple nodes at the same position with 175 // the same tag set 176 // 177 for (Iterator<Map<String,String>> it = mm.keySet().iterator(); it.hasNext();) { 178 Map<String,String> tagSet = it.next(); 172 // check whether we have multiple nodes at the same position with the same tag set 173 for (Iterator<Map<String, String>> it = mm.keySet().iterator(); it.hasNext();) { 174 Map<String, String> tagSet = it.next(); 179 175 if (mm.get(tagSet).size() > 1) { 180 176 … … 184 180 185 181 for (OsmPrimitive p : mm.get(tagSet)) { 186 if (p.getType() ==OsmPrimitiveType.NODE) {182 if (p.getType() == OsmPrimitiveType.NODE) { 187 183 Node n = (Node) p; 188 List<OsmPrimitive> lp =n.getReferrers();184 List<OsmPrimitive> lp = n.getReferrers(); 189 185 for (OsmPrimitive sp: lp) { 190 if (sp.getType() ==OsmPrimitiveType.WAY) {186 if (sp.getType() == OsmPrimitiveType.WAY) { 191 187 boolean typed = false; 192 Way w =(Way) sp;188 Way w = (Way) sp; 193 189 Map<String, String> keys = w.getKeys(); 194 190 for (String type: typeMap.keySet()) { 195 191 if (keys.containsKey(type)) { 196 192 typeMap.put(type, true); 197 typed =true;193 typed = true; 198 194 } 199 195 } … … 207 203 } 208 204 209 int nbType =0;205 int nbType = 0; 210 206 for (Entry<String, Boolean> entry: typeMap.entrySet()) { 211 207 if (entry.getValue()) { … … 214 210 } 215 211 216 if (nbType >1) {212 if (nbType > 1) { 217 213 String msg = marktr("Mixed type duplicated nodes"); 218 214 errors.add(new TestError( … … 364 360 // object to keep track of the nodes at this position. 365 361 // 366 Node n1 = (Node)potentialDuplicates.get(n); 362 Node n1 = (Node) potentialDuplicates.get(n); 367 363 List<Node> nodes = new ArrayList<>(2); 368 364 nodes.add(n1); … … 372 368 // we have multiple nodes at the same position. 373 369 // 374 List<Node> nodes = (List<Node>)potentialDuplicates.get(n); 370 List<Node> nodes = (List<Node>) potentialDuplicates.get(n); 375 371 nodes.add(n); 376 372 } … … 413 409 } 414 410 415 return null;// undoRedo handling done in mergeNodes 411 return null; // undoRedo handling done in mergeNodes 416 412 } 417 413 -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java
r8444 r8510 55 55 @Override 56 56 public int hashCode() { 57 return role.hashCode()+(int)relId+tags.hashCode()+type.hashCode()+coor.hashCode(); 57 return role.hashCode()+(int) relId+tags.hashCode()+type.hashCode()+coor.hashCode(); 58 58 } 59 59 … … 62 62 if (!(obj instanceof RelMember)) return false; 63 63 RelMember rm = (RelMember) obj; 64 return rm.role.equals(role) && rm.type.equals(type) && rm.relId ==relId && rm.tags.equals(tags) && rm.coor.equals(coor);64 return rm.role.equals(role) && rm.type.equals(type) && rm.relId == relId && rm.tags.equals(tags) && rm.coor.equals(coor); 65 65 } 66 66 … … 233 233 for (OsmPrimitive osm : sel) 234 234 if (osm instanceof Relation && !osm.isDeleted()) { 235 relFix.add((Relation)osm); 235 relFix.add((Relation) osm); 236 236 } 237 237 … … 296 296 for (OsmPrimitive osm : sel) 297 297 if (osm instanceof Relation) { 298 relations.add((Relation)osm); 298 relations.add((Relation) osm); 299 299 } 300 300 -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
r8382 r8510 67 67 private static class WayPairNoTags { 68 68 private final List<LatLon> coor; 69 69 70 public WayPairNoTags(List<LatLon> coor) { 70 71 this.coor = coor; 71 72 } 73 72 74 @Override 73 75 public int hashCode() { 74 76 return coor.hashCode(); 75 77 } 78 76 79 @Override 77 80 public boolean equals(Object obj) { … … 125 128 if (sameway.size() > 1) { 126 129 //Report error only if at least some tags are different, as otherwise the error was already reported as duplicated ways 127 Map<String, String> tags0 =null;128 boolean skip =true;130 Map<String, String> tags0 = null; 131 boolean skip = true; 129 132 130 133 for (OsmPrimitive o : sameway) { 131 if (tags0 ==null) {132 tags0 =o.getKeys();134 if (tags0 == null) { 135 tags0 = o.getKeys(); 133 136 removeUninterestingKeys(tags0); 134 137 } else { 135 Map<String, String> tagsCmp =o.getKeys();138 Map<String, String> tagsCmp = o.getKeys(); 136 139 removeUninterestingKeys(tagsCmp); 137 140 if (!tagsCmp.equals(tags0)) { 138 skip =false;141 skip = false; 139 142 break; 140 143 } … … 158 161 */ 159 162 public void removeUninterestingKeys(Map<String, String> wkeys) { 160 for(String key : OsmPrimitive.getDiscardableKeys()) { 163 for (String key : OsmPrimitive.getDiscardableKeys()) { 161 164 wkeys.remove(key); 162 165 } … … 207 210 int lowestIndex = 0; 208 211 long lowestNodeId = wNodes.get(0).getUniqueId(); 209 for (int i =1; i<wNodes.size(); i++) {212 for (int i = 1; i < wNodes.size(); i++) { 210 213 if (wNodes.get(i).getUniqueId() < lowestNodeId) { 211 214 lowestNodeId = wNodes.get(i).getUniqueId(); … … 213 216 } 214 217 } 215 for (int i =lowestIndex; i<wNodes.size()-1; i++) {218 for (int i = lowestIndex; i < wNodes.size()-1; i++) { 216 219 wNodesToUse.add(wNodes.get(i)); 217 220 } 218 for (int i =0; i<lowestIndex; i++) {221 for (int i = 0; i < lowestIndex; i++) { 219 222 wNodesToUse.add(wNodes.get(i)); 220 223 } … … 241 244 for (OsmPrimitive osm : sel) { 242 245 if (osm instanceof Way && !osm.isDeleted()) { 243 ways.add((Way)osm); 246 ways.add((Way) osm); 244 247 } 245 248 } … … 301 304 302 305 //Do not automatically fix same ways with different tags 303 if (testError.getCode() !=DUPLICATE_WAY) return false;306 if (testError.getCode() != DUPLICATE_WAY) return false; 304 307 305 308 // We fix it only if there is no more than one way that is relation member. … … 309 312 for (OsmPrimitive osm : sel) { 310 313 if (osm instanceof Way) { 311 ways.add((Way)osm); 314 ways.add((Way) osm); 312 315 } 313 316 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/InternetTags.java
r7937 r8510 132 132 String errMsg = validator.getErrorMessage(); 133 133 // Special treatment to allow URLs without protocol. See UrlValidator#isValid 134 if (tr("URL contains an invalid protocol: {0}", (String)null).equals(errMsg)) { 134 if (tr("URL contains an invalid protocol: {0}", (String) null).equals(errMsg)) { 135 135 String proto = validator instanceof EmailValidator ? "mailto://" : "http://"; 136 136 return doValidateTag(p, k, proto+value, validator, code); -
trunk/src/org/openstreetmap/josm/data/validation/tests/LongSegment.java
r8455 r8510 35 35 public void visit(Way w) { 36 36 Double length = w.getLongestSegmentLength(); 37 if(length > maxlength) { 37 if (length > maxlength) { 38 38 length /= 1000.0; 39 39 errors.add(new TestError(this, Severity.WARNING, tr("Long segments"), -
trunk/src/org/openstreetmap/josm/data/validation/tests/MapCSSTagChecker.java
r8509 r8510 424 424 static String insertArguments(Selector matchingSelector, String s, OsmPrimitive p) { 425 425 if (s != null && matchingSelector instanceof Selector.ChildOrParentSelector) { 426 return insertArguments(((Selector.ChildOrParentSelector)matchingSelector).right, s, p); 426 return insertArguments(((Selector.ChildOrParentSelector) matchingSelector).right, s, p); 427 427 } else if (s == null || !(matchingSelector instanceof GeneralSelector)) { 428 428 return s; … … 583 583 for (Selector s : rule.selectors) { 584 584 if (s instanceof AbstractSelector) { 585 for (Condition c : ((AbstractSelector)s).getConditions()) { 585 for (Condition c : ((AbstractSelector) s).getConditions()) { 586 586 if (c instanceof ClassCondition) { 587 587 result.add(((ClassCondition) c).id); -
trunk/src/org/openstreetmap/josm/data/validation/tests/MultipolygonTest.java
r8509 r8510 79 79 for (Test t : OsmValidator.getEnabledTests(false)) { 80 80 if (t instanceof UnclosedWays) { 81 keysCheckedByAnotherTest.addAll(((UnclosedWays)t).getCheckedKeys()); 81 keysCheckedByAnotherTest.addAll(((UnclosedWays) t).getCheckedKeys()); 82 82 break; 83 83 } … … 94 94 GeneralPath result = new GeneralPath(); 95 95 result.moveTo((float) nodes.get(0).getCoor().lat(), (float) nodes.get(0).getCoor().lon()); 96 for (int i =1; i<nodes.size(); i++) {96 for (int i = 1; i < nodes.size(); i++) { 97 97 Node n = nodes.get(i); 98 98 result.lineTo((float) n.getCoor().lat(), (float) n.getCoor().lon()); -
trunk/src/org/openstreetmap/josm/data/validation/tests/NameMismatch.java
r8455 r8510 40 40 public NameMismatch() { 41 41 super(tr("Missing name:* translation"), 42 tr("This test finds multilingual objects whose ''name'' attribute is not equal to some ''name:*'' attribute and not a composition of ''name:*'' attributes, e.g., Italia - Italien - Italy.")); 42 tr("This test finds multilingual objects whose ''name'' attribute is not equal to some ''name:*'' attribute " + 43 "and not a composition of ''name:*'' attributes, e.g., Italia - Italien - Italy.")); 43 44 } 44 45 -
trunk/src/org/openstreetmap/josm/data/validation/tests/OpeningHourTest.java
r8382 r8510 63 63 " r.getErrors = function() {return [];};" + 64 64 " return r;" + 65 " } catch(err) {" + 65 " } catch (err) {" + 66 66 " return {" + 67 67 " getWarnings: function() {return [];}," + -
trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java
r8444 r8510 40 40 41 41 /** Bag of all way segments */ 42 private MultiMap<Pair<Node,Node>, WaySegment> nodePairs; 42 private MultiMap<Pair<Node, Node>, WaySegment> nodePairs; 43 43 44 44 protected static final int OVERLAPPING_HIGHWAY = 101; -
trunk/src/org/openstreetmap/josm/data/validation/tests/PowerLines.java
r8382 r8510 122 122 List<List<Node>> nodesLists = new ArrayList<>(); 123 123 if (station instanceof Way) { 124 nodesLists.add(((Way)station).getNodes()); 124 nodesLists.add(((Way) station).getNodes()); 125 125 } else if (station instanceof Relation) { 126 126 Multipolygon polygon = MultipolygonCache.getInstance().get(Main.map.mapView, (Relation) station); … … 147 147 if (it.hasNext()) { 148 148 return new ChangePropertyCommand(it.next(), 149 "power", towerPoleTagMap.get(((PowerLineError)testError).line)); 149 "power", towerPoleTagMap.get(((PowerLineError) testError).line)); 150 150 } 151 151 } … … 155 155 @Override 156 156 public boolean isFixable(TestError testError) { 157 return testError instanceof PowerLineError && towerPoleTagMap.containsKey(((PowerLineError)testError).line); 157 return testError instanceof PowerLineError && towerPoleTagMap.containsKey(((PowerLineError) testError).line); 158 158 } 159 159 … … 207 207 protected class PowerLineError extends TestError { 208 208 private final Way line; 209 209 210 public PowerLineError(Node n, Way line) { 210 211 super(PowerLines.this, Severity.WARNING, … … 212 213 this.line = line; 213 214 } 215 214 216 public final Node getNode() { 215 217 // primitives list can be empty if all primitives have been purged -
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r8461 r8510 85 85 86 86 private static class RolePreset { 87 private final List<Role> roles; 88 private final String name; 89 87 90 public RolePreset(List<Role> roles, String name) { 88 91 this.roles = roles; 89 92 this.name = name; 90 93 } 91 private final List<Role> roles;92 private final String name;93 94 } 94 95 … … 118 119 119 120 private Map<String, RoleInfo> buildRoleInfoMap(Relation n) { 120 Map<String,RoleInfo> map = new HashMap<>(); 121 Map<String, RoleInfo> map = new HashMap<>(); 121 122 for (RelationMember m : n.getMembers()) { 122 123 String role = m.getRole(); … … 150 151 } 151 152 if (matches && r != null) { 152 for(Role role: r.roles) { 153 for (Role role: r.roles) { 153 154 String key = role.key; 154 155 List<Role> roleGroup = null; … … 213 214 // verify if preset accepts such member 214 215 OsmPrimitive primitive = member.getMember(); 215 if(!primitive.isUsable()) { 216 if (!primitive.isUsable()) { 216 217 // if member is not usable (i.e. not present in working set) 217 218 // we can't verify expression - so we just skip it … … 219 220 } else { 220 221 // verify expression 221 if(r.memberExpression.match(primitive)) { 222 if (r.memberExpression.match(primitive)) { 222 223 return true; 223 224 } else { … … 283 284 284 285 // verify role counts based on whole role sets 285 for(RolePreset rp: allroles.values()) { 286 for (RolePreset rp: allroles.values()) { 286 287 for (Role r: rp.roles) { 287 288 String keyname = r.key; -
trunk/src/org/openstreetmap/josm/data/validation/tests/SimilarNamedWays.java
r8404 r8510 37 37 38 38 /** All ways, grouped by cells */ 39 private Map<Point2D,List<Way>> cellWays; 39 private Map<Point2D, List<Way>> cellWays; 40 40 /** The already detected errors */ 41 41 private MultiMap<Way, Way> errorWays; … … 130 130 if (m == 0) 131 131 return n; 132 d = new int[n + 1][m +1];132 d = new int[n+1][m+1]; 133 133 134 134 // Step 2 … … 198 198 // check plain strings 199 199 int distance = getLevenshteinDistance(name, name2); 200 boolean similar = distance >0 && distance<=2;200 boolean similar = distance > 0 && distance <= 2; 201 201 202 202 // try all rules -
trunk/src/org/openstreetmap/josm/data/validation/tests/TagChecker.java
r8470 r8510 265 265 } 266 266 // TODO directionKeys are no longer in OsmPrimitive (search pattern is used instead) 267 /* for(String a : OsmPrimitive.getDirectionKeys()) 267 /* for (String a : OsmPrimitive.getDirectionKeys()) 268 268 presetsValueData.add(a); 269 269 */ … … 345 345 withErrors.put(p, "ICK"); 346 346 } 347 if (checkValues && (value !=null && value.length() > 255) && !withErrors.contains(p, "LV")) {347 if (checkValues && (value != null && value.length() > 255) && !withErrors.contains(p, "LV")) { 348 348 errors.add(new TestError(this, Severity.ERROR, tr("Tag value longer than allowed"), 349 349 tr(s, key), MessageFormat.format(s, key), LONG_VALUE, p)); 350 350 withErrors.put(p, "LV"); 351 351 } 352 if (checkKeys && (key !=null && key.length() > 255) && !withErrors.contains(p, "LK")) {352 if (checkKeys && (key != null && key.length() > 255) && !withErrors.contains(p, "LK")) { 353 353 errors.add(new TestError(this, Severity.ERROR, tr("Tag key longer than allowed"), 354 354 tr(s, key), MessageFormat.format(s, key), LONG_KEY, p)); 355 355 withErrors.put(p, "LK"); 356 356 } 357 if (checkValues && (value ==null || value.trim().isEmpty()) && !withErrors.contains(p, "EV")) {357 if (checkValues && (value == null || value.trim().isEmpty()) && !withErrors.contains(p, "EV")) { 358 358 errors.add(new TestError(this, Severity.WARNING, tr("Tags with empty values"), 359 359 tr(s, key), MessageFormat.format(s, key), EMPTY_VALUES, p)); … … 392 392 } 393 393 for (String a : ignoreDataEquals) { 394 if(key.equals(a)) { 394 if (key.equals(a)) { 395 395 ignore = true; 396 396 } 397 397 } 398 398 for (String a : ignoreDataEndsWith) { 399 if(key.endsWith(a)) { 399 if (key.endsWith(a)) { 400 400 ignore = true; 401 401 } … … 508 508 a.anchor = GridBagConstraints.EAST; 509 509 510 testPanel.add(new JLabel(name+" :"), GBC.eol().insets(3, 0,0,0));510 testPanel.add(new JLabel(name+" :"), GBC.eol().insets(3, 0, 0, 0)); 511 511 512 512 prefCheckKeys = new JCheckBox(tr("Check property keys."), Main.pref.getBoolean(PREF_CHECK_KEYS, true)); 513 513 prefCheckKeys.setToolTipText(tr("Validate that property keys are valid checking against list of words.")); 514 testPanel.add(prefCheckKeys, GBC.std().insets(20, 0,0,0));514 testPanel.add(prefCheckKeys, GBC.std().insets(20, 0, 0, 0)); 515 515 516 516 prefCheckKeysBeforeUpload = new JCheckBox(); … … 520 520 prefCheckComplex = new JCheckBox(tr("Use complex property checker."), Main.pref.getBoolean(PREF_CHECK_COMPLEX, true)); 521 521 prefCheckComplex.setToolTipText(tr("Validate property values and tags using complex rules.")); 522 testPanel.add(prefCheckComplex, GBC.std().insets(20, 0,0,0));522 testPanel.add(prefCheckComplex, GBC.std().insets(20, 0, 0, 0)); 523 523 524 524 prefCheckComplexBeforeUpload = new JCheckBox(); … … 547 547 prefCheckValues = new JCheckBox(tr("Check property values."), Main.pref.getBoolean(PREF_CHECK_VALUES, true)); 548 548 prefCheckValues.setToolTipText(tr("Validate that property values are valid checking against presets.")); 549 testPanel.add(prefCheckValues, GBC.std().insets(20, 0,0,0));549 testPanel.add(prefCheckValues, GBC.std().insets(20, 0, 0, 0)); 550 550 551 551 prefCheckValuesBeforeUpload = new JCheckBox(); … … 555 555 prefCheckFixmes = new JCheckBox(tr("Check for FIXMES."), Main.pref.getBoolean(PREF_CHECK_FIXMES, true)); 556 556 prefCheckFixmes.setToolTipText(tr("Looks for nodes or ways with FIXME in any property value.")); 557 testPanel.add(prefCheckFixmes, GBC.std().insets(20, 0,0,0));557 testPanel.add(prefCheckFixmes, GBC.std().insets(20, 0, 0, 0)); 558 558 559 559 prefCheckFixmesBeforeUpload = new JCheckBox(); … … 667 667 private Pattern getPattern(String str) throws PatternSyntaxException { 668 668 if (str.endsWith("/i")) 669 return Pattern.compile(str.substring(1,str.length()-2), Pattern.CASE_INSENSITIVE); 669 return Pattern.compile(str.substring(1, str.length()-2), Pattern.CASE_INSENSITIVE); 670 670 if (str.endsWith("/")) 671 return Pattern.compile(str.substring(1,str.length()-1)); 671 return Pattern.compile(str.substring(1, str.length()-1)); 672 672 673 673 throw new IllegalStateException(); 674 674 } 675 675 676 public CheckerElement(String exp) throws PatternSyntaxException { 676 677 Matcher m = Pattern.compile("(.+)([!=]=)(.+)").matcher(exp); -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnclosedWays.java
r8390 r8510 174 174 175 175 for (OsmPrimitive parent: w.getReferrers()) { 176 if (parent instanceof Relation && ((Relation)parent).isMultipolygon()) 176 if (parent instanceof Relation && ((Relation) parent).isMultipolygon()) 177 177 return; 178 178 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/UnconnectedWays.java
r8509 r8510 423 423 return ret; 424 424 for (int i = 1; i < size; ++i) { 425 if(i < size-1) { 425 if (i < size-1) { 426 426 addNode(w.getNode(i), middlenodes); 427 427 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/UntaggedWay.java
r8444 r8510 127 127 OsmPrimitive member = m.getMember(); 128 128 if (member instanceof Way && member.isUsable() && !member.isTagged()) { 129 waysUsedInRelations.add((Way)member); 129 waysUsedInRelations.add((Way) member); 130 130 } 131 131 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/WayConnectedToArea.java
r7937 r8510 40 40 List<OsmPrimitive> r = w.firstNode().getReferrers(); 41 41 for (OsmPrimitive p : r) { 42 if(p != w && p.hasKey("highway")) { 42 if (p != w && p.hasKey("highway")) { 43 43 hasway = true; 44 44 break; … … 53 53 r = w.lastNode().getReferrers(); 54 54 for (OsmPrimitive p : r) { 55 if(p != w && p.hasKey("highway")) { 55 if (p != w && p.hasKey("highway")) { 56 56 hasway = true; 57 57 break; -
trunk/src/org/openstreetmap/josm/data/validation/util/Entities.java
r8395 r8510 382 382 } 383 383 } else { // escaped value content is an entity name 384 if(mapNameToValue == null) { 384 if (mapNameToValue == null) { 385 385 mapNameToValue = new HashMap<>(); 386 386 for (String[] pair : ARRAY) -
trunk/src/org/openstreetmap/josm/data/validation/util/ValUtil.java
r8444 r8510 33 33 * @return A list with all the cells the way starts or ends 34 34 */ 35 public static List<List<Way>> getWaysInCell(Way w, Map<Point2D,List<Way>> cellWays) { 35 public static List<List<Way>> getWaysInCell(Way w, Map<Point2D, List<Way>> cellWays) { 36 36 if (w.getNodesCount() == 0) 37 37 return Collections.emptyList();
Note:
See TracChangeset
for help on using the changeset viewer.