Changeset 19108 in josm
- Timestamp:
- 2024-06-17T19:37:02+02:00 (4 months ago)
- Location:
- trunk
- Files:
-
- 38 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/TagInfoExtract.java
r19050 r19108 224 224 225 225 private abstract class Extractor { 226 abstract void run() throws Exception;226 abstract void run() throws IOException, OsmTransferException, ParseException, SAXException; 227 227 228 228 void writeJson(String name, String description, Iterable<TagInfoTag> tags) throws IOException { -
trunk/scripts/TaggingPresetSchemeWikiGenerator.java
r19050 r19108 35 35 } 36 36 37 public static void main(String[] args) throws Exception {37 public static void main(String[] args) throws IOException, ParserConfigurationException, SAXException, XPathExpressionException { 38 38 document = parseTaggingPresetSchema(); 39 39 xPath = XPathFactory.newInstance().newXPath(); -
trunk/src/org/openstreetmap/josm/actions/OpenFileAction.java
r18871 r19108 84 84 // If the user explicitly wants native file dialogs, let them use it. 85 85 // Rather unfortunately, this means that they will not be able to select files and directories. 86 if ( FileChooserManager.PROP_USE_NATIVE_FILE_DIALOG.get()86 if (Boolean.TRUE.equals(FileChooserManager.PROP_USE_NATIVE_FILE_DIALOG.get()) 87 87 // This is almost redundant, as the JDK currently doesn't support this with (all?) native file choosers. 88 88 && !NativeFileChooser.supportsSelectionMode(FILES_AND_DIRECTORIES)) { -
trunk/src/org/openstreetmap/josm/actions/SelectAllAction.java
r17062 r19108 8 8 import java.awt.event.KeyEvent; 9 9 10 import org.openstreetmap.josm.data.osm.IPrimitive; 10 11 import org.openstreetmap.josm.data.osm.OsmData; 11 12 import org.openstreetmap.josm.tools.Shortcut; … … 30 31 return; 31 32 OsmData<?, ?, ?, ?> ds = getLayerManager().getActiveData(); 32 // Do not use method reference before the Java 11 migration 33 // Otherwise we face a compiler bug, see below: 34 // https://bugs.openjdk.java.net/browse/JDK-8141508 35 // https://bugs.openjdk.java.net/browse/JDK-8142476 36 // https://bugs.openjdk.java.net/browse/JDK-8191655 37 ds.setSelected(ds.getPrimitives(t -> t.isSelectable())); 33 ds.setSelected(ds.getPrimitives(IPrimitive::isSelectable)); 38 34 } 39 35 -
trunk/src/org/openstreetmap/josm/actions/SelectByInternalPointAction.java
r13434 r19108 104 104 final Collection<OsmPrimitive> surroundingObjects = getSurroundingObjects(internalPoint); 105 105 final DataSet ds = MainApplication.getLayerManager().getActiveDataSet(); 106 if ( surroundingObjects.isEmpty()) {107 return;108 } else if (doRemove) {109 final Collection<OsmPrimitive> newSelection = new ArrayList<>(ds.getSelected());110 newSelection.removeAll(surroundingObjects);111 ds.setSelected(newSelection);112 } else if (doAdd) {113 final Collection<OsmPrimitive> newSelection = new ArrayList<>(ds.getSelected());114 newSelection.add(surroundingObjects.iterator().next());115 ds.setSelected(newSelection);116 } else {117 ds.setSelected(surroundingObjects.iterator().next());106 if (!surroundingObjects.isEmpty()) { 107 if (doRemove) { 108 final Collection<OsmPrimitive> newSelection = new ArrayList<>(ds.getSelected()); 109 newSelection.removeAll(surroundingObjects); 110 ds.setSelected(newSelection); 111 } else if (doAdd) { 112 final Collection<OsmPrimitive> newSelection = new ArrayList<>(ds.getSelected()); 113 newSelection.add(surroundingObjects.iterator().next()); 114 ds.setSelected(newSelection); 115 } else { 116 ds.setSelected(surroundingObjects.iterator().next()); 117 } 118 118 } 119 119 } -
trunk/src/org/openstreetmap/josm/actions/SelectNonBranchingWaySequences.java
r18211 r19108 56 56 private void addNodes(Node node) { 57 57 if (node == null) return; 58 else if (!nodes.add(node))58 if (!nodes.add(node)) { 59 59 outerNodes.remove(node); 60 else60 } else { 61 61 outerNodes.add(node); 62 } 62 63 } 63 64 -
trunk/src/org/openstreetmap/josm/actions/SessionSaveAction.java
r18942 r19108 3 3 4 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 import static org.openstreetmap.josm.tools.I18n.marktr; 5 6 import static org.openstreetmap.josm.tools.I18n.tr; 6 7 import static org.openstreetmap.josm.tools.I18n.trn; … … 8 9 import java.awt.Component; 9 10 import java.awt.Dimension; 11 import java.awt.GridBagConstraints; 10 12 import java.awt.GridBagLayout; 11 13 import java.awt.event.ActionEvent; … … 84 86 private static final BooleanProperty SAVE_PLUGIN_INFORMATION_PROPERTY = new BooleanProperty("session.saveplugins", false); 85 87 private static final String TOOLTIP_DEFAULT = tr("Save the current session."); 88 private static final String SAVE_SESSION = marktr("Save Session"); 86 89 87 90 protected transient FileFilter joz = new ExtensionFileFilter("joz", "joz", tr("Session file (archive) (*.joz)")); … … 120 123 */ 121 124 protected SessionSaveAction(boolean toolbar, boolean installAdapters) { 122 this(tr( "Save Session"), "session", TOOLTIP_DEFAULT,125 this(tr(SAVE_SESSION), "session", TOOLTIP_DEFAULT, 123 126 Shortcut.registerShortcut("system:savesession", tr("File: {0}", tr("Save Session...")), KeyEvent.VK_S, Shortcut.ALT_CTRL), 124 127 toolbar, "save-session", installAdapters); … … 183 186 .collect(Collectors.toList()); 184 187 185 boolean zipRequired = layersOut.stream().map( l -> exporters.get(l))188 boolean zipRequired = layersOut.stream().map(exporters::get) 186 189 .anyMatch(ex -> ex != null && ex.requiresZip()) || pluginsWantToSave(); 187 190 … … 333 336 334 337 if (zipRequired) { 335 fc = createAndOpenFileChooser(false, false, tr( "Save Session"), joz, JFileChooser.FILES_ONLY, "lastDirectory");338 fc = createAndOpenFileChooser(false, false, tr(SAVE_SESSION), joz, JFileChooser.FILES_ONLY, "lastDirectory"); 336 339 } else { 337 fc = createAndOpenFileChooser(false, false, tr( "Save Session"), Arrays.asList(jos, joz), jos,340 fc = createAndOpenFileChooser(false, false, tr(SAVE_SESSION), Arrays.asList(jos, joz), jos, 338 341 JFileChooser.FILES_ONLY, "lastDirectory"); 339 342 } … … 366 369 */ 367 370 public SessionSaveAsDialog() { 368 super(MainApplication.getMainFrame(), tr( "Save Session"), tr("Save As"), tr("Cancel"));371 super(MainApplication.getMainFrame(), tr(SAVE_SESSION), tr("Save As"), tr("Cancel")); 369 372 configureContextsensitiveHelp("Action/SessionSaveAs", true /* show help button */); 370 373 initialize(); … … 442 445 JPanel wrapper = new JPanel(new GridBagLayout()); 443 446 wrapper.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); 444 wrapper.add(exportPanel, GBC.std().fill(G BC.HORIZONTAL));445 ip.add(wrapper, GBC.eol().fill(G BC.HORIZONTAL).insets(2, 2, 4, 2));446 } 447 ip.add(GBC.glue(0, 1), GBC.eol().fill(G BC.VERTICAL));447 wrapper.add(exportPanel, GBC.std().fill(GridBagConstraints.HORIZONTAL)); 448 ip.add(wrapper, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(2, 2, 4, 2)); 449 } 450 ip.add(GBC.glue(0, 1), GBC.eol().fill(GridBagConstraints.VERTICAL)); 448 451 JScrollPane sp = new JScrollPane(ip); 449 452 sp.setBorder(BorderFactory.createEmptyBorder()); … … 475 478 p.add(include, GBC.std()); 476 479 p.add(lbl, GBC.std()); 477 p.add(GBC.glue(1, 0), GBC.std().fill(G BC.HORIZONTAL));480 p.add(GBC.glue(1, 0), GBC.std().fill(GridBagConstraints.HORIZONTAL)); 478 481 return p; 479 482 } … … 538 541 * @deprecated since 18833, use {@link #setCurrentSession(File, List, SessionWriter.SessionWriterFlags...)} instead 539 542 */ 540 @Deprecated 543 @Deprecated(since = "18833") 541 544 public static void setCurrentSession(File file, boolean zip, List<Layer> layers) { 542 545 if (zip) { -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTask.java
r18830 r19108 61 61 62 62 protected static <T extends Enum<T> & UrlPattern> String[] patterns(Class<T> urlPatternEnum) { 63 // Do not use a method reference until we switch to Java 11, as we face JDK-8141508 with Java 8 64 return Arrays.stream(urlPatternEnum.getEnumConstants()).map(/* JDK-8141508 */ t -> t.pattern()).toArray(String[]::new); 63 return Arrays.stream(urlPatternEnum.getEnumConstants()).map(UrlPattern::pattern).toArray(String[]::new); 65 64 } 66 65 -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskList.java
r17330 r19108 213 213 public Set<OsmPrimitive> getDownloadedPrimitives() { 214 214 return tasks.stream() 215 .filter(t -> t instanceof DownloadOsmTask) 216 .map(t -> ((DownloadOsmTask) t).getDownloadedData()) 215 .filter(DownloadOsmTask.class::isInstance) 216 .map(DownloadOsmTask.class::cast) 217 .map(DownloadOsmTask::getDownloadedData) 217 218 .filter(Objects::nonNull) 218 219 .flatMap(ds -> ds.allPrimitives().stream()) … … 240 241 try { 241 242 future.get(); 242 } catch (InterruptedException | ExecutionException | CancellationException e) { 243 } catch (InterruptedException interruptedException) { 244 Thread.currentThread().interrupt(); 245 Logging.error(interruptedException); 246 return; 247 } catch (ExecutionException | CancellationException e) { 243 248 Logging.error(e); 244 249 return; … … 255 260 Utils.joinAsHtmlUnorderedList(errors)) + "</html>", 256 261 tr("Errors during download"), JOptionPane.ERROR_MESSAGE); 257 return;258 262 } 259 263 }); … … 269 273 if (editDataSet != null && osmData) { 270 274 final List<DownloadOsmTask> osmTasks = tasks.stream() 271 .filter( t -> t instanceof DownloadOsmTask).map(t -> (DownloadOsmTask)t)275 .filter(DownloadOsmTask.class::isInstance).map(DownloadOsmTask.class::cast) 272 276 .filter(t -> t.getDownloadedData() != null) 273 277 .collect(Collectors.toList()); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r18987 r19108 390 390 if (!map.mapView.isActiveLayerVisible()) 391 391 return; 392 if ( !(Boolean) this.getValue("active"))392 if (Boolean.FALSE.equals(this.getValue("active"))) 393 393 return; 394 394 if (e.getButton() != MouseEvent.BUTTON1) … … 512 512 if (moveCommand == null) { 513 513 //make a new move command 514 moveCommand = new MoveCommand(new ArrayList< OsmPrimitive>(movingNodeList), bestMovement);514 moveCommand = new MoveCommand(new ArrayList<>(movingNodeList), bestMovement); 515 515 UndoRedoHandler.getInstance().add(moveCommand); 516 516 } else { … … 939 939 private EastNorth calculateBestMovementAndNewNodes(EastNorth mouseEn) { 940 940 EastNorth bestMovement = calculateBestMovement(mouseEn); 941 EastNorth n1movedEn = initialN1en.add(bestMovement), n2movedEn; 941 EastNorth n1movedEn = initialN1en.add(bestMovement); 942 EastNorth n2movedEn; 942 943 943 944 // find out the movement distance, in metres … … 1158 1159 double raoffsety = symbolSize*factor*normal.getY(); 1159 1160 1160 double cx = center.getX(), cy = center.getY(); 1161 final double cx = center.getX(); 1162 final double cy = center.getY(); 1161 1163 double k = mirror ? -1 : 1; 1162 1164 Point2D ra1 = new Point2D.Double(cx + raoffsetx, cy + raoffsety); -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r19050 r19108 398 398 all = ds.allPrimitives(); 399 399 } else { 400 all = ds.getPrimitives( p -> p.isSelectable()); // Do not use method reference before Java 11!400 all = ds.getPrimitives(IPrimitive::isSelectable); 401 401 } 402 402 final ProgressMonitor subMonitor = getProgressMonitor().createSubTaskMonitor(all.size(), false); -
trunk/src/org/openstreetmap/josm/data/StructUtils.java
r18871 r19108 267 267 } 268 268 269 @SuppressWarnings("rawtypes") 270 private static String mapToJson(Map map) { 269 private static String mapToJson(Map<?, ?> map) { 271 270 StringWriter stringWriter = new StringWriter(); 272 271 try (JsonWriter writer = Json.createWriter(stringWriter)) { 273 272 JsonObjectBuilder object = Json.createObjectBuilder(); 274 for (Object o: map.entrySet()) { 275 Map.Entry e = (Map.Entry) o; 273 for (Map.Entry<?, ?> e: map.entrySet()) { 276 274 Object evalue = e.getValue(); 277 275 object.add(e.getKey().toString(), evalue.toString()); … … 282 280 } 283 281 284 @SuppressWarnings({ "rawtypes", "unchecked" }) 285 private static Map mapFromJson(String s) { 286 Map ret; 282 private static Map<String, String> mapFromJson(String s) { 283 Map<String, String> ret; 287 284 try (JsonReader reader = Json.createReader(new StringReader(s))) { 288 285 JsonObject object = reader.readObject(); 289 ret = new HashMap (Utils.hashMapInitialCapacity(object.size()));286 ret = new HashMap<>(Utils.hashMapInitialCapacity(object.size())); 290 287 for (Map.Entry<String, JsonValue> e: object.entrySet()) { 291 288 JsonValue value = e.getValue(); … … 301 298 } 302 299 303 @SuppressWarnings("rawtypes") 304 private static String multiMapToJson(MultiMap map) { 300 private static String multiMapToJson(MultiMap<?, ?> map) { 305 301 StringWriter stringWriter = new StringWriter(); 306 302 try (JsonWriter writer = Json.createWriter(stringWriter)) { 307 303 JsonObjectBuilder object = Json.createObjectBuilder(); 308 for (Object o: map.entrySet()) { 309 Map.Entry e = (Map.Entry) o; 310 Set evalue = (Set) e.getValue(); 304 for (Map.Entry<?, ?> e : map.entrySet()) { 305 Set<?> evalue = (Set<?>) e.getValue(); 311 306 JsonArrayBuilder a = Json.createArrayBuilder(); 312 307 for (Object evo: evalue) { … … 320 315 } 321 316 322 @SuppressWarnings({ "rawtypes", "unchecked" }) 323 private static MultiMap multiMapFromJson(String s) { 324 MultiMap ret; 317 private static MultiMap<String, String> multiMapFromJson(String s) { 318 MultiMap<String, String> ret; 325 319 try (JsonReader reader = Json.createReader(new StringReader(s))) { 326 320 JsonObject object = reader.readObject(); 327 ret = new MultiMap (object.size());321 ret = new MultiMap<>(object.size()); 328 322 for (Map.Entry<String, JsonValue> e: object.entrySet()) { 329 323 JsonValue value = e.getValue(); -
trunk/src/org/openstreetmap/josm/data/cache/JCSCacheManager.java
r18434 r19108 174 174 */ 175 175 public static <K, V> CacheAccess<K, V> getCache(String cacheName) { 176 return getCache(cacheName, DEFAULT_MAX_OBJECTS_IN_MEMORY.get() .intValue(), 0, null);176 return getCache(cacheName, DEFAULT_MAX_OBJECTS_IN_MEMORY.get(), 0, null); 177 177 } 178 178 -
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r19050 r19108 474 474 * Check if the object is loadable. This means, if the data will be parsed, and if this response 475 475 * will finish as successful retrieve. 476 * 476 * <p> 477 477 * This simple implementation doesn't load empty response, nor client (4xx) and server (5xx) errors 478 478 * … … 544 544 } 545 545 546 final boolean noCache = force 547 // To remove when switching to Java 11 548 // Workaround for https://bugs.openjdk.java.net/browse/JDK-8146450 549 || (Utils.getJavaVersion() == 8 && Utils.isRunningJavaWebStart()); 546 final boolean noCache = force; 550 547 urlConn.useCache(!noCache); 551 548 -
trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/Layer.java
r18473 r19108 99 99 * @throws IOException - if an IO error occurs 100 100 */ 101 @SuppressWarnings("PMD.CloseResource") // The resources _are_ closed after use; it just isn't detect with PMD 7.2.x. 101 102 public Layer(Collection<ProtobufRecord> records) throws IOException { 102 103 // Do the unique required fields first … … 137 138 } 138 139 // Cleanup bytes (for memory) 139 for (ProtobufRecord protobufRecord : records) { 140 for (ProtobufRecord protobufRecord : records) { // NOSONAR -- this shouldn't be combined since this is a cleanup loop. 140 141 protobufRecord.close(); 141 142 } -
trunk/src/org/openstreetmap/josm/data/imagery/vectortile/mapbox/style/Layers.java
r19103 r19108 307 307 stringBuffer.append(",\""); 308 308 } 309 stringBuffer.append(tail); 310 stringBuffer.append('"'); 309 stringBuffer.append(tail).append('"'); 311 310 } 312 311 -
trunk/src/org/openstreetmap/josm/data/osm/AbstractPrimitive.java
r19096 r19108 310 310 } 311 311 312 @Deprecated 312 @Deprecated(since = "17749") 313 313 @Override 314 314 public void setTimestamp(Date timestamp) { … … 326 326 } 327 327 328 @Deprecated 328 @Deprecated(since = "17749") 329 329 @Override 330 330 public Date getTimestamp() { … … 648 648 if (key == null || Utils.isStripEmpty(key)) 649 649 return; 650 elseif (value == null) {650 if (value == null) { 651 651 remove(key); 652 652 } else if (keys == null) { … … 808 808 809 809 @Override 810 @SuppressWarnings("PMD.UseArraysAsList") // See https://github.com/pmd/pmd/issues/5071 810 811 public final Collection<String> keySet() { 811 812 String[] tKeys = this.keys; -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r19078 r19108 50 50 /** 51 51 * constructor 52 * 52 * <p> 53 53 * The visitor will merge <code>sourceDataSet</code> onto <code>targetDataSet</code> 54 54 * … … 69 69 /** 70 70 * Merges a primitive onto primitives dataset. 71 * 71 * <p> 72 72 * If other.id != 0 it tries to merge it with an corresponding primitive from 73 73 * my dataset with the same id. If this is not possible a conflict is remembered 74 74 * in {@link #conflicts}. 75 * 75 * <p> 76 76 * If other.id == 0 (new primitive) it tries to find a primitive in my dataset with id == 0 which 77 77 * is semantically equal. If it finds one it merges its technical attributes onto … … 239 239 newNodes.add(targetNode); 240 240 if (targetNode.isDeleted() && !conflicts.hasConflictForMy(targetNode)) { 241 addConflict(new Conflict< OsmPrimitive>(targetNode, sourceNode, true));241 addConflict(new Conflict<>(targetNode, sourceNode, true)); 242 242 targetNode.setDeleted(false); 243 243 } … … 383 383 * Runs the merge operation. Successfully merged {@link OsmPrimitive}s are in 384 384 * {@link #getTargetDataSet()}. 385 * 385 * <p> 386 386 * See {@link #getConflicts()} for a map of conflicts after the merge operation. 387 387 */ … … 393 393 * Runs the merge operation. Successfully merged {@link OsmPrimitive}s are in 394 394 * {@link #getTargetDataSet()}. 395 * 395 * <p> 396 396 * See {@link #getConflicts()} for a map of conflicts after the merge operation. 397 397 * @param progressMonitor The progress monitor … … 404 404 * Runs the merge operation. Successfully merged {@link OsmPrimitive}s are in 405 405 * {@link #getTargetDataSet()}. 406 * 406 * <p> 407 407 * See {@link #getConflicts()} for a map of conflicts after the merge operation. 408 408 * @param progressMonitor The progress monitor -
trunk/src/org/openstreetmap/josm/data/osm/DefaultNameFormatter.java
r18811 r19108 226 226 } 227 227 if (node.isLatLonKnown() && Boolean.TRUE.equals(PROPERTY_SHOW_COOR.get())) { 228 name.append(" \u200E(") ;229 name.append(CoordinateFormatManager.getDefaultFormat().toString(node, ", "));230 name.append(")\u200C");228 name.append(" \u200E(") 229 .append(CoordinateFormatManager.getDefaultFormat().toString(node, ", ")) 230 .append(")\u200C"); 231 231 } 232 232 } -
trunk/src/org/openstreetmap/josm/data/osm/IPrimitive.java
r19078 r19108 299 299 * @deprecated since 17749, use {@link #getInstant} instead 300 300 */ 301 @Deprecated 301 @Deprecated(since = "17749") 302 302 Date getTimestamp(); 303 303 … … 328 328 * @deprecated since 17749, use {@link #setInstant} instead 329 329 */ 330 @Deprecated 330 @Deprecated(since = "17749") 331 331 void setTimestamp(Date timestamp); 332 332 -
trunk/src/org/openstreetmap/josm/data/osm/IRelation.java
r18814 r19108 13 13 * @since 4098 14 14 */ 15 public interface IRelation<M extends IRelationMember<? >> extends IPrimitive {15 public interface IRelation<M extends IRelationMember<? extends IPrimitive>> extends IPrimitive { 16 16 17 17 /** … … 129 129 default Collection<? extends IPrimitive> getIncompleteMembers() { 130 130 return getMembers().stream() 131 . filter(rm -> rm.getMember().isIncomplete())132 . map(rm -> rm.getMember())131 .map(IRelationMember::getMember) 132 .filter(IPrimitive::isIncomplete) 133 133 .collect(Collectors.toSet()); 134 134 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r19078 r19108 33 33 /** 34 34 * The base class for OSM objects ({@link Node}, {@link Way}, {@link Relation}). 35 * 35 * <p> 36 36 * It can be created, deleted and uploaded to the OSM-Server. 37 * 37 * <p> 38 38 * Although OsmPrimitive is designed as a base class, it is not to be meant to subclass 39 39 * it by any other than from the package {@link org.openstreetmap.josm.data.osm}. The available primitives are a fixed … … 96 96 /** 97 97 * Creates a new primitive for the given id. 98 * 98 * <p> 99 99 * If allowNegativeId is set, provided id can be < 0 and will be set to primitive without any processing. 100 100 * If allowNegativeId is not set, then id will have to be 0 (in that case new unique id will be generated) or … … 124 124 /** 125 125 * Creates a new primitive for the given id and version. 126 * 126 * <p> 127 127 * If allowNegativeId is set, provided id can be < 0 and will be set to primitive without any processing. 128 128 * If allowNegativeId is not set, then id will have to be 0 (in that case new unique id will be generated) or 129 129 * positive number. 130 * 130 * <p> 131 131 * If id is not > 0 version is ignored and set to 0. 132 132 * … … 225 225 /** 226 226 * Sets the id and the version of this primitive if it is known to the OSM API. 227 * 227 * <p> 228 228 * Since we know the id and its version it can't be incomplete anymore. incomplete 229 229 * is set to false. … … 261 261 * The id is a new unique id. The version, changeset and timestamp are set to 0. 262 262 * incomplete and deleted are set to false. It's preferred to use copy constructor with clearMetadata set to true instead 263 * 263 * <p> 264 264 * <strong>Caution</strong>: Do not use this method on primitives which are already added to a {@link DataSet}. 265 265 * … … 300 300 } 301 301 302 @Deprecated 302 @Deprecated(since = "17749", forRemoval = true) 303 303 @Override 304 304 public void setTimestamp(Date timestamp) { … … 713 713 714 714 private void doVisitReferrers(Consumer<OsmPrimitive> visitor) { 715 if (this.referrers == null) 716 return; 717 else if (this.referrers instanceof OsmPrimitive) { 718 OsmPrimitive ref = (OsmPrimitive) this.referrers; 719 if (ref.dataSet == dataSet) { 720 visitor.accept(ref); 721 } 722 } else if (this.referrers instanceof OsmPrimitive[]) { 723 OsmPrimitive[] refs = (OsmPrimitive[]) this.referrers; 724 for (OsmPrimitive ref: refs) { 715 if (this.referrers != null) { 716 if (this.referrers instanceof OsmPrimitive) { 717 OsmPrimitive ref = (OsmPrimitive) this.referrers; 725 718 if (ref.dataSet == dataSet) { 726 719 visitor.accept(ref); 720 } 721 } else if (this.referrers instanceof OsmPrimitive[]) { 722 OsmPrimitive[] refs = (OsmPrimitive[]) this.referrers; 723 for (OsmPrimitive ref : refs) { 724 if (ref.dataSet == dataSet) { 725 visitor.accept(ref); 726 } 727 727 } 728 728 } … … 791 791 /** 792 792 * Merges the technical and semantic attributes from <code>other</code> onto this. 793 * 793 * <p> 794 794 * Both this and other must be new, or both must be assigned an OSM ID. If both this and <code>other</code> 795 795 * have an assigned OSM id, the IDs have to be the same. -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitiveType.java
r16626 r19108 161 161 * @since 15820 162 162 */ 163 public finalUniqueIdGenerator getIdGenerator() {163 public UniqueIdGenerator getIdGenerator() { 164 164 return idGenerator; 165 165 } -
trunk/src/org/openstreetmap/josm/data/osm/Storage.java
r18801 r19108 18 18 * It is useful wherever one would use self-mapping construct like 19 19 * <code>Map<T,T>.put(t,t)</code>, that is, for caches, uniqueness filters or similar. 20 * 20 * <p> 21 21 * The semantics of equivalency can be external to the object, using the 22 22 * {@link Hash} interface. The set also supports querying for entries using … … 400 400 */ 401 401 public static <O> Hash<O, O> defaultHash() { 402 return new Hash< O, O>() {402 return new Hash<>() { 403 403 @Override 404 404 public int getHashCode(O t) { -
trunk/src/org/openstreetmap/josm/data/osm/TagMap.java
r18006 r19108 277 277 stringBuilder.append(','); 278 278 } 279 stringBuilder.append(e.getKey()) ;280 stringBuilder.append('=');281 stringBuilder.append(e.getValue());279 stringBuilder.append(e.getKey()) 280 .append('=') 281 .append(e.getValue()); 282 282 first = false; 283 283 } -
trunk/src/org/openstreetmap/josm/data/osm/history/History.java
r17903 r19108 294 294 @Override 295 295 public String toString() { 296 StringBuilder result = new StringBuilder("History [" 297 + (type != null ? ("type=" + type + ", ") : "") + "id=" + id); 296 StringBuilder result = new StringBuilder("History ["); 297 if (type != null) { 298 result.append("type=").append(type).append(", "); 299 } 300 result.append("id=").append(id); 298 301 if (versions != null) { 299 302 result.append(", versions=\n"); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/RenderBenchmarkCollector.java
r16542 r19108 113 113 114 114 public static long getCurrentTimeMilliseconds() { 115 return System.nanoTime() / 1 000000; // System.currentTimeMillis has low accuracy, sometimes multiples of 16ms115 return System.nanoTime() / 1_000_000; // System.currentTimeMillis has low accuracy, sometimes multiples of 16ms 116 116 } 117 117 … … 121 121 */ 122 122 public static class LoggingBenchmark extends RenderBenchmarkCollector.CapturingBenchmark { 123 private final PrintStream outStream = System.err;123 private static final PrintStream outStream = System.err; 124 124 private double circum; 125 125 -
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r18494 r19108 41 41 /** 42 42 * Custom projection. 43 * 43 * <p> 44 44 * Inspired by PROJ.4 and Proj4J. 45 45 * @since 5072 … … 59 59 /** 60 60 * pref String that defines the projection 61 * 61 * <p> 62 62 * null means fall back mode (Mercator) 63 63 */ … … 223 223 * @param pref the string that defines the custom projection 224 224 */ 225 @SuppressWarnings("PMD.PreserveStackTrace") // PMD 7.2.x doesn't like log + new exception here for some reason. 225 226 public CustomProjection(String name, String code, String pref) { 226 227 this.name = name; … … 874 875 /** 875 876 * Return true, if a geographic coordinate reference system is represented. 876 * 877 * <p> 877 878 * I.e. if it returns latitude/longitude values rather than Cartesian 878 879 * east/north coordinates on a flat surface. -
trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2GridShiftFile.java
r17374 r19108 171 171 int topLevelCount = 0; 172 172 Map<String, List<NTV2SubGrid>> subGridMap = new HashMap<>(); 173 for ( int i = 0; i < subGrid.length; i++) {174 if ("NONE".equalsIgnoreCase( subGrid[i].getParentSubGridName())) {173 for (NTV2SubGrid ntv2SubGrid : subGrid) { 174 if ("NONE".equalsIgnoreCase(ntv2SubGrid.getParentSubGridName())) { 175 175 topLevelCount++; 176 176 } 177 subGridMap.put( subGrid[i].getSubGridName(), new ArrayList<NTV2SubGrid>());177 subGridMap.put(ntv2SubGrid.getSubGridName(), new ArrayList<>()); 178 178 } 179 179 NTV2SubGrid[] topLevelSubGrid = new NTV2SubGrid[topLevelCount]; 180 180 topLevelCount = 0; 181 for ( int i = 0; i < subGrid.length; i++) {182 if ("NONE".equalsIgnoreCase( subGrid[i].getParentSubGridName())) {183 topLevelSubGrid[topLevelCount++] = subGrid[i];181 for (NTV2SubGrid ntv2SubGrid : subGrid) { 182 if ("NONE".equalsIgnoreCase(ntv2SubGrid.getParentSubGridName())) { 183 topLevelSubGrid[topLevelCount++] = ntv2SubGrid; 184 184 } else { 185 List<NTV2SubGrid> parent = subGridMap.get( subGrid[i].getParentSubGridName());186 parent.add( subGrid[i]);185 List<NTV2SubGrid> parent = subGridMap.get(ntv2SubGrid.getParentSubGridName()); 186 parent.add(ntv2SubGrid); 187 187 } 188 188 } 189 189 NTV2SubGrid[] nullArray = new NTV2SubGrid[0]; 190 for ( int i = 0; i < subGrid.length; i++) {191 List<NTV2SubGrid> subSubGrids = subGridMap.get( subGrid[i].getSubGridName());190 for (NTV2SubGrid ntv2SubGrid : subGrid) { 191 List<NTV2SubGrid> subSubGrids = subGridMap.get(ntv2SubGrid.getSubGridName()); 192 192 if (!subSubGrids.isEmpty()) { 193 193 NTV2SubGrid[] subGridArray = subSubGrids.toArray(nullArray); 194 subGrid[i].setSubGridArray(subGridArray);194 ntv2SubGrid.setSubGridArray(subGridArray); 195 195 } 196 196 } -
trunk/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java
r19077 r19108 281 281 // The first writeErrors catches anything that was written, for whatever reason. This is probably never 282 282 // going to be called. 283 final var validationTask = new ValidationTask(errors -> writeErrors(geoJSONMapRouletteWriter, fileOutputStream, errors), 283 final ValidationTask validationTask = 284 new ValidationTask(errors -> writeErrors(geoJSONMapRouletteWriter, fileOutputStream, errors), 284 285 progressMonitorFactory.get(), OsmValidator.getEnabledTests(false), 285 286 dataSet.allPrimitives(), Collections.emptyList(), false); -
trunk/src/org/openstreetmap/josm/data/validation/tests/CrossingWays.java
r18963 r19108 342 342 if (this instanceof CrossingWays.Boundaries) { 343 343 List<Relation> relations = ds.searchRelations(wt.getBBox()).stream() 344 .filter( p -> isPrimitiveUsable(p)).collect(Collectors.toList());344 .filter(this::isPrimitiveUsable).collect(Collectors.toList()); 345 345 for (Relation r: relations) { 346 346 for (Way w : r.getMemberPrimitives(Way.class)) { … … 360 360 361 361 static boolean isWaterArea(OsmPrimitive w) { 362 return w.hasTag("natural", "water") || w.hasTag( "waterway", "riverbank") || w.hasTag(LANDUSE, "reservoir");362 return w.hasTag("natural", "water") || w.hasTag(WATERWAY, "riverbank") || w.hasTag(LANDUSE, "reservoir"); 363 363 } 364 364 -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateNode.java
r17665 r19108 80 80 LatLon coorK = getLatLon(k); 81 81 LatLon coorT = getLatLon(t); 82 return coorK == coorT || (coorK != null && coorT != null && coorK.equals(coorT));82 return Objects.equals(coorK, coorT); 83 83 } 84 84 -
trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java
r17896 r19108 21 21 import java.util.stream.Collectors; 22 22 23 import org.openstreetmap.josm.data.osm.IWaySegment; 23 24 import org.openstreetmap.josm.data.osm.Node; 24 25 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 122 123 return; 123 124 124 List<Way> currentWays = duplicated.stream().map( ws -> ws.getWay()).collect(Collectors.toList());125 List<Way> currentWays = duplicated.stream().map(IWaySegment::getWay).collect(Collectors.toList()); 125 126 Collection<WaySegment> highlight; 126 127 if ((highlight = seenWays.get(currentWays)) != null) { -
trunk/src/org/openstreetmap/josm/data/validation/tests/WayConnectedToArea.java
r16445 r19108 52 52 53 53 private void testForError(Way w, Node wayNode, OsmPrimitive p) { 54 if ( wayNode.isOutsideDownloadArea()55 || wayNode.getReferrers().stream().anyMatch(p1 -> p1.hasTag("route", "ferry"))) {56 return;57 } else if (isArea(p)) {58 addPossibleError(w, wayNode, p, p);59 } else {60 p.referrers(Relation.class)61 .filter(r -> r.isMultipolygon() && isArea(r))62 .findFirst()63 .ifPresent(r -> addPossibleError(w, wayNode, p, r));54 if (!wayNode.isOutsideDownloadArea() 55 && wayNode.getReferrers().stream().noneMatch(p1 -> p1.hasTag("route", "ferry"))) { 56 if (isArea(p)) { 57 addPossibleError(w, wayNode, p, p); 58 } else { 59 p.referrers(Relation.class) 60 .filter(r -> r.isMultipolygon() && isArea(r)) 61 .findFirst() 62 .ifPresent(r -> addPossibleError(w, wayNode, p, r)); 63 } 64 64 } 65 65 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/WronglyOrderedWays.java
r13849 r19108 37 37 38 38 String natural = w.get("natural"); 39 if (natural == null) {40 return;41 } else if ("coastline".equals(natural) && Geometry.isClockwise(w)) {42 reportError(w, tr("Reversed coastline: land not on left side"), WRONGLY_ORDERED_COAST);43 } else if ("land".equals(natural) && Geometry.isClockwise(w)) {44 reportError(w, tr("Reversed land: land not on left side"), WRONGLY_ORDERED_LAND);39 if (natural != null) { 40 if ("coastline".equals(natural) && Geometry.isClockwise(w)) { 41 reportError(w, tr("Reversed coastline: land not on left side"), WRONGLY_ORDERED_COAST); 42 } else if ("land".equals(natural) && Geometry.isClockwise(w)) { 43 reportError(w, tr("Reversed land: land not on left side"), WRONGLY_ORDERED_LAND); 44 } 45 45 } 46 46 } -
trunk/src/org/openstreetmap/josm/gui/MapStatus.java
r18815 r19108 14 14 import java.awt.Font; 15 15 import java.awt.GraphicsEnvironment; 16 import java.awt.GridBagConstraints; 16 17 import java.awt.GridBagLayout; 17 18 import java.awt.MouseInfo; … … 56 57 import javax.swing.Popup; 57 58 import javax.swing.PopupFactory; 59 import javax.swing.SwingConstants; 58 60 import javax.swing.UIManager; 59 61 import javax.swing.event.PopupMenuEvent; … … 112 114 * It keeps a status line below the map up to date and displays some tooltip 113 115 * information if the user hold the mouse long enough at some point. 114 * 116 * <p> 115 117 * All this is done in background to not disturb other processes. 116 * 118 * <p> 117 119 * The background thread does not alter any data of the map (read only thread). 118 120 * Also it is rather fail safe. In case of some error in the data, it just does … … 316 318 public void run() { 317 319 // Freeze display when holding down CTRL 318 if ((ms.modifiers & MouseEvent.CTRL_DOWN_MASK) != 0) {320 if ((ms.modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { 319 321 // update the information popup's labels though, because the selection might have changed from the outside 320 322 popupUpdateLabels(); … … 327 329 boolean mouseNotMoved = oldMousePos != null && oldMousePos.equals(ms.mousePos); 328 330 boolean isAtOldPosition = mouseNotMoved && popup != null; 329 boolean middleMouseDown = (ms.modifiers & MouseEvent.BUTTON2_DOWN_MASK) != 0;331 boolean middleMouseDown = (ms.modifiers & InputEvent.BUTTON2_DOWN_MASK) != 0; 330 332 331 333 DataSet ds = mv.getLayerManager().getActiveDataSet(); … … 361 363 "Hold CTRL to select directly from this list with the mouse.<hr>")+"</html>", 362 364 null, 363 JLabel.HORIZONTAL365 SwingConstants.CENTER 364 366 ); 365 lbl.setHorizontalAlignment( JLabel.LEADING);367 lbl.setHorizontalAlignment(SwingConstants.LEADING); 366 368 c.add(lbl, GBC.eol().insets(2, 0, 2, 0)); 367 369 … … 379 381 JLabel l = popupBuildPrimitiveLabels(osm); 380 382 lbls.add(l); 381 c.add(l, GBC.eol().fill(G BC.HORIZONTAL).insets(2, 0, 2, 2));383 c.add(l, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(2, 0, 2, 2)); 382 384 } 383 385 … … 537 539 // pressed. Cannot use "setSelected()" because it will cause a 538 540 // fireSelectionChanged event which is unnecessary at this point. 539 if ((mods & MouseEvent.SHIFT_DOWN_MASK) == 0) {541 if ((mods & InputEvent.SHIFT_DOWN_MASK) == 0) { 540 542 ds.clearSelection(); 541 543 } … … 648 650 "<html>" + text.toString() + "</html>", 649 651 ImageProvider.get(osm.getDisplayType()), 650 JLabel.HORIZONTAL652 SwingConstants.HORIZONTAL 651 653 ) { 652 654 // This is necessary so the label updates its colors when the … … 661 663 popupSetLabelColors(l, osm); 662 664 l.setFont(l.getFont().deriveFont(Font.PLAIN)); 663 l.setVerticalTextPosition( JLabel.TOP);664 l.setHorizontalAlignment( JLabel.LEADING);665 l.setVerticalTextPosition(SwingConstants.TOP); 666 l.setHorizontalAlignment(SwingConstants.LEADING); 665 667 l.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); 666 668 l.addMouseListener(new MouseAdapter() { … … 902 904 return; 903 905 // Do not update the view if ctrl or right button is pressed. 904 if ((e.getModifiersEx() & ( MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON3_DOWN_MASK)) == 0) {906 if ((e.getModifiersEx() & (InputEvent.CTRL_DOWN_MASK | InputEvent.BUTTON3_DOWN_MASK)) == 0) { 905 907 updateLatLonText(e.getX(), e.getY()); 906 908 } … … 951 953 helpText.setEditable(false); 952 954 add(nameText, GBC.std().insets(3, 0, 0, 0)); 953 add(helpText, GBC.std().insets(3, 0, 0, 0).fill(G BC.HORIZONTAL));955 add(helpText, GBC.std().insets(3, 0, 0, 0).fill(GridBagConstraints.HORIZONTAL)); 954 956 955 957 progressBar.setMaximum(PleaseWaitProgressMonitor.PROGRESS_BAR_MAX); … … 1226 1228 } 1227 1229 } 1228 setDist(new SubclassFilteredCollection< OsmPrimitive, Way>(newSelection, Way.class::isInstance));1230 setDist(new SubclassFilteredCollection<>(newSelection, Way.class::isInstance)); 1229 1231 } 1230 1232 -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r19080 r19108 127 127 private boolean ignoreRepaint; 128 128 129 private final Set<MapViewPaintable> invalidatedLayers = Collections.newSetFromMap(new IdentityHashMap< MapViewPaintable, Boolean>());129 private final Set<MapViewPaintable> invalidatedLayers = Collections.newSetFromMap(new IdentityHashMap<>()); 130 130 131 131 @Override … … 176 176 */ 177 177 private synchronized Set<MapViewPaintable> collectInvalidatedLayers() { 178 Set<MapViewPaintable> layers = Collections.newSetFromMap(new IdentityHashMap< MapViewPaintable, Boolean>());178 Set<MapViewPaintable> layers = Collections.newSetFromMap(new IdentityHashMap<>()); 179 179 layers.addAll(invalidatedLayers); 180 180 invalidatedLayers.clear(); … … 299 299 }); 300 300 301 setFocusTraversalKeysEnabled( !Shortcut.findShortcut(KeyEvent.VK_TAB, 0).isPresent());301 setFocusTraversalKeysEnabled(Shortcut.findShortcut(KeyEvent.VK_TAB, 0).isEmpty()); 302 302 303 303 mapNavigationComponents = getMapNavigationComponents(this); … … 321 321 zoomSlider.setSize(size); 322 322 zoomSlider.setLocation(3, 0); 323 zoomSlider.setFocusTraversalKeysEnabled( !Shortcut.findShortcut(KeyEvent.VK_TAB, 0).isPresent());323 zoomSlider.setFocusTraversalKeysEnabled(Shortcut.findShortcut(KeyEvent.VK_TAB, 0).isEmpty()); 324 324 325 325 MapScaler scaler = new MapScaler(forMapView); -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r19050 r19108 21 21 import java.util.stream.Collectors; 22 22 23 import org.junit.jupiter.api.Assumptions;24 23 import org.junit.jupiter.api.Test; 25 24 import org.openstreetmap.josm.JOSMFixture; … … 29 28 import org.openstreetmap.josm.testutils.annotations.ProjectionNadGrids; 30 29 import org.openstreetmap.josm.tools.Pair; 31 import org.openstreetmap.josm.tools.Platform;32 import org.openstreetmap.josm.tools.Utils;33 30 34 31 /** … … 144 141 @Test 145 142 void testNonRegression() throws IOException { 146 // Disable on Github Windows runners + Java 8, minor differences appeared around 2021-07-20147 Assumptions.assumeFalse(148 Utils.getJavaVersion() == 8149 && Platform.determinePlatform() == Platform.WINDOWS150 && System.getenv("GITHUB_WORKFLOW") != null);151 143 List<TestData> allData = readData(); 152 144 Set<String> dataCodes = allData.stream().map(data -> data.code).collect(Collectors.toSet()); … … 160 152 } 161 153 162 final boolean java9 = Utils.getJavaVersion() >= 9;163 154 for (TestData data : allData) { 164 155 Projection proj = Projections.getProjectionByCode(data.code); … … 169 160 EastNorth en = proj.latlon2eastNorth(data.ll); 170 161 LatLon ll2 = proj.eastNorth2latlon(data.en); 171 if (! (java9 ? equalsJava9(en, data.en) : en.equals(data.en))) {162 if (!equalsJava9(en, data.en)) { 172 163 String error = String.format("%s (%s): Projecting latlon(%s,%s):%n" + 173 164 " expected: eastnorth(%s,%s),%n" + … … 176 167 fail.append(error); 177 168 } 178 if (! (java9 ? equalsJava9(ll2, data.ll2) : ll2.equals(data.ll2))) {169 if (!equalsJava9(ll2, data.ll2)) { 179 170 String error = String.format("%s (%s): Inverse projecting eastnorth(%s,%s):%n" + 180 171 " expected: latlon(%s,%s),%n" +
Note:
See TracChangeset
for help on using the changeset viewer.