- Timestamp:
- 2024-04-22T20:59:26+02:00 (7 months ago)
- Location:
- trunk
- Files:
-
- 172 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r19048 r19050 249 249 <!-- Undocumented argument to ignore "Sun internal proprietary API" warning, see http://stackoverflow.com/a/13862308/2257172 --> 250 250 <compilerarg value="-XDignore.symbol.file"/> 251 <compilerarg value="-Xplugin:ErrorProne -XepExcludedPaths:.*/parsergen/.* -Xep:ReferenceEquality:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:JdkObsolete:OFF -Xep:EqualsGetClass:OFF -Xep:UndefinedEquals:OFF -Xep:BadImport:OFF -Xep:AnnotateFormatMethod:OFF -Xep:JavaUtilDate:OFF -Xep:DoNotCallSuggester:OFF -Xep:BanSerializableRead:OFF -Xep:InlineMeSuggester:OFF" unless:set="noErrorProne"/> 251 <!-- -XepExcludedPaths:.*/parsergen/.*: see #16860 - Resolve JavaCC using Apache Ivy --> 252 <!-- ReferenceEquality: see #12472, fix #13230, fix #13225, fix #13228 - disable ReferenceEquality warning + partial revert of r10656 + r10659, causes too much problems --> 253 <!-- FutureReturnValueIgnored: update to error_prone 2.0.18 (disabled on purpose?) --> 254 <!-- JdkObsolete: see #11924 - see #15560 - support jdk10+ in build.xml, update to proguard 6.0beta1 and error_prone 2.1.2 (disabled due to crashes) --> 255 <!-- EqualsGetClass, UndefinedEquals: see #16498 - update to error_prone 2.3.2-20180817.184126-35 to test JDK 12 compatibility. (disabled due to crashes?) --> 256 <!-- BadImport, AnnotateFormatMethod: see #17516 - update to error-prone 2.3.5-SNAPSHOT plus following patches for Java 13 compatibility (disabled due to crashes?) --> 257 <!-- JavaUtilDate, DoNotCallSuggester, BanSerializableRead: see #19724 - update to error-prone 2.5.1, checkstyle 8.36, spotbugs 4.2.1 (disabled due to crashes?) --> 258 <!-- InlineMeSuggester: See #20522 - Disable https://errorprone.info/bugpattern/InlineMeSuggester (maybe it crashed?) --> 259 <!-- LongDoubleConversion: Disable due to conflicting with Sonar settings --> 260 <compilerarg value="-Xplugin:ErrorProne -XepExcludedPaths:.*/parsergen/.* -Xep:ReferenceEquality:OFF -Xep:FutureReturnValueIgnored:OFF -Xep:JdkObsolete:OFF -Xep:EqualsGetClass:OFF -Xep:UndefinedEquals:OFF -Xep:BadImport:OFF -Xep:AnnotateFormatMethod:OFF -Xep:JavaUtilDate:OFF -Xep:DoNotCallSuggester:OFF -Xep:BanSerializableRead:OFF -Xep:InlineMeSuggester:OFF -Xep:LongDoubleConversion:OFF" unless:set="noErrorProne"/> 252 261 <compilerarg line="-Xmaxwarns 1000"/> 253 262 <compilerarg value="-Xplugin:semanticdb -sourceroot:@{srcdir} -targetroot:${build.dir}/semanticdb" if:set="lsif" /> -
trunk/scripts/TagInfoExtract.java
r18801 r19050 1 1 // License: GPL. For details, see LICENSE file. 2 2 3 import java.awt.Graphics2D; 3 4 import java.awt.image.BufferedImage; … … 32 33 33 34 import javax.imageio.ImageIO; 34 import jakarta.json.Json;35 import jakarta.json.JsonArrayBuilder;36 import jakarta.json.JsonObjectBuilder;37 import jakarta.json.JsonWriter;38 import jakarta.json.stream.JsonGenerator;39 35 40 36 import org.openstreetmap.josm.actions.DeleteAction; … … 85 81 import org.xml.sax.SAXException; 86 82 83 import jakarta.json.Json; 84 import jakarta.json.JsonArrayBuilder; 85 import jakarta.json.JsonObjectBuilder; 86 import jakarta.json.JsonWriter; 87 import jakarta.json.stream.JsonGenerator; 88 87 89 /** 88 90 * Extracts tag information for the taginfo project. … … 163 165 } 164 166 165 private static class Options {167 private static final class Options { 166 168 Mode mode; 167 169 int josmSvnRevision = Version.getInstance().getVersion(); … … 314 316 } 315 317 316 private class ExternalPresets extends Presets {318 private final class ExternalPresets extends Presets { 317 319 318 320 @Override … … 341 343 } 342 344 343 private class StyleSheet extends Extractor {345 private final class StyleSheet extends Extractor { 344 346 private MapCSSStyleSource styleSource; 345 347 -
trunk/scripts/TaggingPresetSchemeWikiGenerator.java
r18801 r19050 64 64 } 65 65 66 private static class TaggingNamespaceContext implements NamespaceContext {66 private static final class TaggingNamespaceContext implements NamespaceContext { 67 67 @Override 68 68 public String getNamespaceURI(String prefix) { -
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r19048 r19050 15 15 import java.time.Year; 16 16 import java.time.ZoneOffset; 17 import java.util.Collection; 17 18 import java.util.Collections; 18 19 import java.util.List; … … 26 27 import javax.swing.JScrollPane; 27 28 29 import org.openstreetmap.josm.data.coor.LatLon; 30 import org.openstreetmap.josm.data.imagery.DefaultLayer; 28 31 import org.openstreetmap.josm.data.imagery.ImageryInfo; 29 32 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; … … 60 63 SelectWmsLayersDialog(WMSLayerTree tree, JComboBox<String> formats) { 61 64 super(MainApplication.getMainFrame(), tr("Select WMS layers"), tr("Add layers"), tr("Cancel")); 62 final varscrollPane = new JScrollPane(tree.getLayerTree());65 final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree()); 63 66 scrollPane.setPreferredSize(new Dimension(400, 400)); 64 final varpanel = new JPanel(new GridBagLayout());67 final JPanel panel = new JPanel(new GridBagLayout()); 65 68 panel.add(scrollPane, GBC.eol().fill()); 66 69 panel.add(formats, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); … … 82 85 83 86 // change toolbar icon from if specified 84 varicon = info.getIcon();87 String icon = info.getIcon(); 85 88 if (icon != null) { 86 89 new ImageProvider(icon).setOptional(true).getResourceAsync(result -> { … … 101 104 try { 102 105 if (info.getUrl() != null && info.getUrl().contains("{time}")) { 103 final varinstant = Year.now(ZoneOffset.UTC).atDay(1).atStartOfDay(ZoneOffset.UTC).toInstant().toString();104 final varexample = String.join("/", instant, instant);105 final varinitialSelectionValue = info.getDate() != null ? info.getDate() : example;106 final varuserDate = JOptionPane.showInputDialog(MainApplication.getMainFrame(),106 final String instant = Year.now(ZoneOffset.UTC).atDay(1).atStartOfDay(ZoneOffset.UTC).toInstant().toString(); 107 final String example = String.join("/", instant, instant); 108 final String initialSelectionValue = info.getDate() != null ? info.getDate() : example; 109 final String userDate = JOptionPane.showInputDialog(MainApplication.getMainFrame(), 107 110 tr("Time filter for \"{0}\" such as \"{1}\"", info.getName(), example), 108 111 initialSelectionValue); … … 124 127 // specify which layer to use 125 128 if (Utils.isEmpty(info.getDefaultLayers())) { 126 vartileSource = new WMTSTileSource(info);127 var layerId = tileSource.userSelectLayer();129 WMTSTileSource tileSource = new WMTSTileSource(info); 130 DefaultLayer layerId = tileSource.userSelectLayer(); 128 131 if (layerId != null) { 129 varcopy = new ImageryInfo(info);132 ImageryInfo copy = new ImageryInfo(info); 130 133 copy.setDefaultLayers(Collections.singletonList(layerId)); 131 varlayerName = tileSource.getLayers().stream()134 String layerName = tileSource.getLayers().stream() 132 135 .filter(x -> x.getIdentifier().equals(layerId.getLayerName())) 133 136 .map(Layer::getUserTitle) … … 163 166 ImageryLayer layer = null; 164 167 try { 165 final varinfoToAdd = convertImagery(info);168 final ImageryInfo infoToAdd = convertImagery(info); 166 169 if (infoToAdd != null) { 167 170 layer = ImageryLayer.create(infoToAdd); … … 205 208 206 209 private static LayerSelection askToSelectLayers(WMSImagery wms) { 207 final vartree = new WMSLayerTree();208 209 varwmsFormats = wms.getFormats();210 final var formats = new JComboBox<String>(wmsFormats.toArray(new String[0]));210 final WMSLayerTree tree = new WMSLayerTree(); 211 212 Collection<String> wmsFormats = wms.getFormats(); 213 final JComboBox<String> formats = new JComboBox<>(wmsFormats.toArray(new String[0])); 211 214 formats.setSelectedItem(wms.getPreferredFormat()); 212 215 formats.setToolTipText(tr("Select image format for WMS layer")); 213 216 214 varcheckBounds = new JCheckBox(tr("Show only layers for current view"), true);217 JCheckBox checkBounds = new JCheckBox(tr("Show only layers for current view"), true); 215 218 Runnable updateTree = () -> { 216 varlatLon = checkBounds.isSelected() && MainApplication.isDisplayingMapView()219 LatLon latLon = checkBounds.isSelected() && MainApplication.isDisplayingMapView() 217 220 ? MainApplication.getMap().mapView.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter()) 218 221 : null; … … 225 228 226 229 if (!GraphicsEnvironment.isHeadless()) { 227 vardialog = new ExtendedDialog(MainApplication.getMainFrame(),230 ExtendedDialog dialog = new ExtendedDialog(MainApplication.getMainFrame(), 228 231 tr("Select WMS layers"), tr("Add layers"), tr("Cancel")); 229 final varscrollPane = new JScrollPane(tree.getLayerTree());232 final JScrollPane scrollPane = new JScrollPane(tree.getLayerTree()); 230 233 scrollPane.setPreferredSize(new Dimension(400, 400)); 231 final varpanel = new JPanel(new GridBagLayout());234 final JPanel panel = new JPanel(new GridBagLayout()); 232 235 panel.add(scrollPane, GBC.eol().fill()); 233 236 panel.add(checkBounds, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); … … 281 284 CheckParameterUtil.ensureThat(ImageryType.WMS_ENDPOINT == info.getImageryType(), "wms_endpoint imagery type expected"); 282 285 // We need to get the URL with {apikey} replaced. See #22642. 283 final vartileSource = new TemplatedWMSTileSource(info, ProjectionRegistry.getProjection());284 final varwms = new WMSImagery(tileSource.getBaseUrl(), info.getCustomHttpHeaders());285 varselection = choice.apply(wms);286 final TemplatedWMSTileSource tileSource = new TemplatedWMSTileSource(info, ProjectionRegistry.getProjection()); 287 final WMSImagery wms = new WMSImagery(tileSource.getBaseUrl(), info.getCustomHttpHeaders()); 288 LayerSelection selection = choice.apply(wms); 286 289 if (selection == null) { 287 290 return null; 288 291 } 289 292 290 final varurl = wms.buildGetMapUrl(293 final String url = wms.buildGetMapUrl( 291 294 selection.layers.stream().map(LayerDetails::getName).collect(Collectors.toList()), 292 295 (List<String>) null, … … 295 298 ); 296 299 297 varselectedLayers = selection.layers.stream()300 String selectedLayers = selection.layers.stream() 298 301 .map(LayerDetails::getName) 299 302 .collect(Collectors.joining(", ")); 300 303 // Use full copy of original Imagery info to copy all attributes. Only overwrite what's different 301 varret = new ImageryInfo(info);304 ImageryInfo ret = new ImageryInfo(info); 302 305 ret.setUrl(url); 303 306 ret.setImageryType(ImageryType.WMS); -
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r19048 r19050 8 8 import java.awt.event.ActionEvent; 9 9 import java.awt.event.KeyEvent; 10 import java.awt.geom.Area; 10 11 import java.util.ArrayList; 11 12 import java.util.Collection; … … 22 23 import org.openstreetmap.josm.data.DataSource; 23 24 import org.openstreetmap.josm.data.conflict.Conflict; 25 import org.openstreetmap.josm.data.osm.DataSet; 24 26 import org.openstreetmap.josm.data.osm.IPrimitive; 25 27 import org.openstreetmap.josm.data.osm.OsmData; … … 32 34 import org.openstreetmap.josm.gui.MapView; 33 35 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener; 36 import org.openstreetmap.josm.gui.dialogs.ConflictDialog; 34 37 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 35 38 import org.openstreetmap.josm.gui.dialogs.ValidatorDialog.ValidatorBoundingXYVisitor; … … 143 146 */ 144 147 public static void zoomTo(Collection<? extends IPrimitive> sel) { 145 final var bboxCalculator = new BoundingXYVisitor();148 BoundingXYVisitor bboxCalculator = new BoundingXYVisitor(); 146 149 bboxCalculator.computeBoundingBox(sel); 147 150 if (bboxCalculator.getBounds() != null) { … … 241 244 public void autoScale() { 242 245 if (MainApplication.isDisplayingMapView()) { 243 final varmapView = MainApplication.getMap().mapView;246 MapView mapView = MainApplication.getMap().mapView; 244 247 switch (mode) { 245 248 case PREVIOUS: … … 309 312 private void modeLayer(BoundingXYVisitor v) { 310 313 // try to zoom to the first selected layer 311 final var l = getFirstSelectedLayer();314 Layer l = getFirstSelectedLayer(); 312 315 if (l == null) 313 316 return; … … 324 327 } 325 328 } else { 326 final varconflictDialog = MainApplication.getMap().conflictDialog;329 ConflictDialog conflictDialog = MainApplication.getMap().conflictDialog; 327 330 Conflict<? extends IPrimitive> c = conflictDialog.getSelectedConflict(); 328 331 if (c != null) { … … 356 359 } 357 360 Bounds bbox = null; 358 final vardataset = getLayerManager().getActiveDataSet();361 final DataSet dataset = getLayerManager().getActiveDataSet(); 359 362 if (dataset != null) { 360 363 List<DataSource> dataSources = new ArrayList<>(dataset.getDataSources()); … … 369 372 } else { 370 373 lastZoomArea = -1; 371 final varsourceArea = getLayerManager().getActiveDataSet().getDataSourceArea();374 Area sourceArea = getLayerManager().getActiveDataSet().getDataSourceArea(); 372 375 if (sourceArea != null) { 373 376 bbox = new Bounds(sourceArea.getBounds2D()); -
trunk/src/org/openstreetmap/josm/actions/DownloadOsmInViewAction.java
r19048 r19050 37 37 @Override 38 38 public void actionPerformed(ActionEvent e) { 39 final varbounds = MainApplication.getMap().mapView.getRealBounds();40 final vartask = new DownloadOsmInViewTask();39 final Bounds bounds = MainApplication.getMap().mapView.getRealBounds(); 40 DownloadOsmInViewTask task = new DownloadOsmInViewTask(); 41 41 task.setZoomAfterDownload(false); 42 42 Future<?> future = task.download(bounds); … … 55 55 } 56 56 57 private static class DownloadOsmInViewTask extends DownloadOsmTask {57 private static final class DownloadOsmInViewTask extends DownloadOsmTask { 58 58 Future<?> download(Bounds downloadArea) { 59 59 return download(new DownloadTask(new DownloadParams(), new BoundingBoxDownloader(downloadArea), null, false), downloadArea); -
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r19048 r19050 210 210 211 211 public List<Node> getNodes() { 212 final var nodes = new ArrayList<Node>();212 List<Node> nodes = new ArrayList<>(); 213 213 for (WayInPolygon way : this.ways) { 214 214 //do not add the last node as it will be repeated in the next way 215 215 if (way.insideToTheRight) { 216 for ( varpos = 0; pos < way.way.getNodesCount() - 1; pos++) {216 for (int pos = 0; pos < way.way.getNodesCount() - 1; pos++) { 217 217 nodes.add(way.way.getNode(pos)); 218 218 } … … 343 343 */ 344 344 private static double getAngle(Node n1, Node n2, Node n3) { 345 final varen1 = n1.getEastNorth();346 final varen2 = n2.getEastNorth();347 final varen3 = n3.getEastNorth();345 EastNorth en1 = n1.getEastNorth(); 346 EastNorth en2 = n2.getEastNorth(); 347 EastNorth en3 = n3.getEastNorth(); 348 348 double angle = Math.atan2(en3.getY() - en1.getY(), en3.getX() - en1.getX()) - 349 349 Math.atan2(en2.getY() - en1.getY(), en2.getX() - en1.getX()); … … 362 362 */ 363 363 public WayInPolygon walk() { 364 final varheadNode = getHeadNode();365 final varprevNode = getPrevNode();364 Node headNode = getHeadNode(); 365 Node prevNode = getPrevNode(); 366 366 367 367 double headAngle = Math.atan2(headNode.getEastNorth().east() - prevNode.getEastNorth().east(), … … 371 371 //find best next way 372 372 WayInPolygon bestWay = null; 373 varbestWayReverse = false;373 boolean bestWayReverse = false; 374 374 375 375 for (WayInPolygon way : availableWays) { … … 418 418 */ 419 419 public WayInPolygon leftComingWay() { 420 final varheadNode = getHeadNode();421 final varprevNode = getPrevNode();420 Node headNode = getHeadNode(); 421 Node prevNode = getPrevNode(); 422 422 423 423 WayInPolygon mostLeft = null; // most left way connected to head node 424 varcomingToHead = false; // true if candidate come to head node424 boolean comingToHead = false; // true if candidate come to head node 425 425 double angle = 2*Math.PI; 426 426 … … 649 649 } 650 650 651 varhasChanges = false;652 653 final var allStartingWays = new ArrayList<Way>();654 final var innerStartingWays = new ArrayList<Way>();655 final var outerStartingWays = new ArrayList<Way>();651 boolean hasChanges = false; 652 653 List<Way> allStartingWays = new ArrayList<>(); 654 List<Way> innerStartingWays = new ArrayList<>(); 655 List<Way> outerStartingWays = new ArrayList<>(); 656 656 657 657 for (Multipolygon area : areas) { … … 721 721 if (discardedWays.stream().anyMatch(w -> !w.isNew())) { 722 722 for (AssembledPolygon ring : boundaries) { 723 for ( vark = 0; k < ring.ways.size(); k++) {723 for (int k = 0; k < ring.ways.size(); k++) { 724 724 WayInPolygon ringWay = ring.ways.get(k); 725 725 Way older = keepOlder(ringWay.way, oldestWayMap, discardedWays); 726 726 727 727 if (ringWay.way != older) { 728 final varrepl = new WayInPolygon(older, ringWay.insideToTheRight);728 WayInPolygon repl = new WayInPolygon(older, ringWay.insideToTheRight); 729 729 ring.ways.set(k, repl); 730 730 } … … 769 769 // Delete the discarded inner ways 770 770 if (!discardedWays.isEmpty()) { 771 final vardeleteCmd = DeleteCommand.delete(discardedWays, true);771 Command deleteCmd = DeleteCommand.delete(discardedWays, true); 772 772 if (deleteCmd != null) { 773 773 cmds.add(deleteCmd); … … 796 796 private Way keepOlder(Way way, Map<Node, Way> oldestWayMap, List<Way> discardedWays) { 797 797 Way oldest = null; 798 for ( varn : way.getNodes()) {799 final varorig = oldestWayMap .get(n);798 for (Node n : way.getNodes()) { 799 Way orig = oldestWayMap .get(n); 800 800 if (orig != null && (oldest == null || oldest.getUniqueId() > orig.getUniqueId()) 801 801 && discardedWays.contains(orig)) { … … 830 830 } 831 831 832 final varwayTags = TagCollection.unionOfAllPrimitives(ways);832 TagCollection wayTags = TagCollection.unionOfAllPrimitives(ways); 833 833 try { 834 834 cmds.addAll(CombinePrimitiveResolverDialog.launchIfNecessary(wayTags, ways, ways)); … … 847 847 */ 848 848 private boolean removeDuplicateNodes(List<Way> ways) { 849 final var nodeMap = new TreeMap<Node, Node>(new NodePositionComparator());850 vartotalWaysModified = 0;849 Map<Node, Node> nodeMap = new TreeMap<>(new NodePositionComparator()); 850 int totalWaysModified = 0; 851 851 852 852 for (Way way : ways) { … … 855 855 } 856 856 857 final var newNodes = new ArrayList<Node>();857 List<Node> newNodes = new ArrayList<>(); 858 858 Node prevNode = null; 859 varmodifyWay = false;859 boolean modifyWay = false; 860 860 861 861 for (Node node : way.getNodes()) { 862 varrepresentator = nodeMap.get(node);862 Node representator = nodeMap.get(node); 863 863 if (representator == null) { 864 864 //new node … … 923 923 cmds.clear(); 924 924 if (addUndoRedo && !executedCmds.isEmpty()) { 925 final var ur = UndoRedoHandler.getInstance();925 UndoRedoHandler ur = UndoRedoHandler.getInstance(); 926 926 if (executedCmds.size() == 1) { 927 927 ur.add(executedCmds.getFirst(), false); … … 945 945 Map<Way, Way> nextWayMap = new HashMap<>(); 946 946 947 for ( varpos = 0; pos < parts.size(); pos++) {947 for (int pos = 0; pos < parts.size(); pos++) { 948 948 949 949 if (!parts.get(pos).lastNode().equals(parts.get((pos + 1) % parts.size()).firstNode())) … … 956 956 Way topWay = null; 957 957 Node topNode = null; 958 vartopIndex = 0;958 int topIndex = 0; 959 959 double minY = Double.POSITIVE_INFINITY; 960 960 961 961 for (Way way : parts) { 962 for ( varpos = 0; pos < way.getNodesCount(); pos++) {963 final varnode = way.getNode(pos);962 for (int pos = 0; pos < way.getNodesCount(); pos++) { 963 Node node = way.getNode(pos); 964 964 965 965 if (node.getEastNorth().getY() < minY) { … … 996 996 for (Way way : parts) { 997 997 if (way.firstNode().equals(headNode)) { 998 final varnextNode = way.getNode(1);998 Node nextNode = way.getNode(1); 999 999 1000 1000 if (topWay == null || !Geometry.isToTheRightSideOfLine(prevNode, headNode, bestWayNextNode, nextNode)) { … … 1008 1008 if (way.lastNode().equals(headNode)) { 1009 1009 //end adjacent to headNode 1010 final varnextNode = way.getNode(way.getNodesCount() - 2);1010 Node nextNode = way.getNode(way.getNodesCount() - 2); 1011 1011 1012 1012 if (topWay == null || !Geometry.isToTheRightSideOfLine(prevNode, headNode, bestWayNextNode, nextNode)) { … … 1020 1020 } else { 1021 1021 //node is inside way - pick the clockwise going end. 1022 final varprev = topWay.getNode(topIndex - 1);1023 final varnext = topWay.getNode(topIndex + 1);1022 Node prev = topWay.getNode(topIndex - 1); 1023 Node next = topWay.getNode(topIndex + 1); 1024 1024 1025 1025 //there will be no parallel segments in the middle of way, so all fine. … … 1027 1027 } 1028 1028 1029 varcurWay = topWay;1029 Way curWay = topWay; 1030 1030 boolean curWayInsideToTheRight = wayClockwise ^ isInner; 1031 1031 List<WayInPolygon> result = new ArrayList<>(); … … 1035 1035 1036 1036 //add cur way 1037 final varresultWay = new WayInPolygon(curWay, curWayInsideToTheRight);1037 WayInPolygon resultWay = new WayInPolygon(curWay, curWayInsideToTheRight); 1038 1038 result.add(resultWay); 1039 1039 1040 1040 //process next way 1041 final varnextWay = nextWayMap.get(curWay);1042 final varprevNode = curWay.getNode(curWay.getNodesCount() - 2);1043 final varheadNode = curWay.lastNode();1044 final varnextNode = nextWay.getNode(1);1041 Way nextWay = nextWayMap.get(curWay); 1042 Node prevNode = curWay.getNode(curWay.getNodesCount() - 2); 1043 Node headNode = curWay.lastNode(); 1044 Node nextNode = nextWay.getNode(1); 1045 1045 1046 1046 if (nextWay == topWay) { … … 1068 1068 // | 1069 1069 1070 varintersectionCount = 0;1070 int intersectionCount = 0; 1071 1071 1072 1072 for (Way wayA : parts) { … … 1078 1078 if (wayA.lastNode().equals(headNode)) { 1079 1079 1080 final varwayB = nextWayMap.get(wayA);1080 Way wayB = nextWayMap.get(wayA); 1081 1081 1082 1082 //test if wayA is opposite wayB relative to curWay and nextWay 1083 1083 1084 final varwayANode = wayA.getNode(wayA.getNodesCount() - 2);1085 final varwayBNode = wayB.getNode(1);1084 Node wayANode = wayA.getNode(wayA.getNodesCount() - 2); 1085 Node wayBNode = wayB.getNode(1); 1086 1086 1087 1087 boolean wayAToTheRight = Geometry.isToTheRightSideOfLine(prevNode, headNode, nextNode, wayANode); … … 1117 1117 */ 1118 1118 private static void revertDuplicateTwoNodeWays(List<WayInPolygon> parts) { 1119 for ( vari = 0; i < parts.size(); i++) {1119 for (int i = 0; i < parts.size(); i++) { 1120 1120 WayInPolygon w1 = parts.get(i); 1121 1121 if (w1.way.getNodesCount() != 2) … … 1141 1141 private List<Way> splitWayOnNodes(Way way, Set<Node> nodes, Map<Node, Way> oldestWayMap) { 1142 1142 1143 final var result = new ArrayList<Way>();1143 List<Way> result = new ArrayList<>(); 1144 1144 List<List<Node>> chunks = buildNodeChunks(way, nodes); 1145 1145 1146 1146 if (chunks.size() > 1) { 1147 final varsplit = SplitWayCommand.splitWay(way, chunks,1147 SplitWayCommand split = SplitWayCommand.splitWay(way, chunks, 1148 1148 Collections.emptyList(), SplitWayCommand.Strategy.keepFirstChunk()); 1149 1149 … … 1159 1159 if (!way.isNew() && result.size() > 1) { 1160 1160 for (Way part : result) { 1161 final varn = part.firstNode();1162 final varold = oldestWayMap.get(n);1161 Node n = part.firstNode(); 1162 Way old = oldestWayMap.get(n); 1163 1163 if (old == null || old.getUniqueId() > way.getUniqueId()) { 1164 1164 oldestWayMap.put(n, way); … … 1231 1231 1232 1232 //TODO: bad performance for deep nestings... 1233 final var result = new ArrayList<PolygonLevel>();1233 List<PolygonLevel> result = new ArrayList<>(); 1234 1234 1235 1235 for (AssembledPolygon outerWay : boundaryWays) { 1236 1236 1237 varouterGood = true;1238 final var innerCandidates = new ArrayList<AssembledPolygon>();1237 boolean outerGood = true; 1238 List<AssembledPolygon> innerCandidates = new ArrayList<>(); 1239 1239 1240 1240 for (AssembledPolygon innerWay : boundaryWays) { … … 1256 1256 1257 1257 //add new outer polygon 1258 final varpol = new AssembledMultipolygon(outerWay);1259 final varpolLev = new PolygonLevel(pol, level);1258 AssembledMultipolygon pol = new AssembledMultipolygon(outerWay); 1259 PolygonLevel polLev = new PolygonLevel(pol, level); 1260 1260 1261 1261 //process inner ways … … 1288 1288 // This seems to appear when is apply over invalid way like #9911 test-case 1289 1289 // Remove all of these way to make the next work. 1290 final var cleanMultigonWays = new ArrayList<WayInPolygon>();1290 List<WayInPolygon> cleanMultigonWays = new ArrayList<>(); 1291 1291 for (WayInPolygon way: multigonWays) { 1292 1292 if (way.way.getNodesCount() != 2 || !way.way.isClosed()) 1293 1293 cleanMultigonWays.add(way); 1294 1294 } 1295 final var traverser = new WayTraverser(cleanMultigonWays);1296 final var result = new ArrayList<AssembledPolygon>();1295 WayTraverser traverser = new WayTraverser(cleanMultigonWays); 1296 List<AssembledPolygon> result = new ArrayList<>(); 1297 1297 1298 1298 WayInPolygon startWay; 1299 1299 while ((startWay = traverser.startNewWay()) != null) { 1300 final var path = new ArrayList<WayInPolygon>();1301 final var startWays = new ArrayList<WayInPolygon>();1300 List<WayInPolygon> path = new ArrayList<>(); 1301 List<WayInPolygon> startWays = new ArrayList<>(); 1302 1302 path.add(startWay); 1303 1303 while (true) { … … 1318 1318 if (path.get(0) == nextWay) { 1319 1319 // path is closed -> stop here 1320 final varring = new AssembledPolygon(path);1320 AssembledPolygon ring = new AssembledPolygon(path); 1321 1321 if (ring.getNodes().size() <= 2) { 1322 1322 // Invalid ring (2 nodes) -> remove … … 1357 1357 */ 1358 1358 public static List<AssembledPolygon> fixTouchingPolygons(List<AssembledPolygon> polygons) { 1359 final var newPolygons = new ArrayList<AssembledPolygon>();1359 List<AssembledPolygon> newPolygons = new ArrayList<>(); 1360 1360 1361 1361 for (AssembledPolygon ring : polygons) { 1362 1362 ring.reverse(); 1363 final var traverser = new WayTraverser(ring.ways);1363 WayTraverser traverser = new WayTraverser(ring.ways); 1364 1364 WayInPolygon startWay; 1365 1365 1366 1366 while ((startWay = traverser.startNewWay()) != null) { 1367 final var simpleRingWays = new ArrayList<WayInPolygon>();1367 List<WayInPolygon> simpleRingWays = new ArrayList<>(); 1368 1368 simpleRingWays.add(startWay); 1369 1369 WayInPolygon nextWay; … … 1374 1374 } 1375 1375 traverser.removeWays(simpleRingWays); 1376 final varsimpleRing = new AssembledPolygon(simpleRingWays);1376 AssembledPolygon simpleRing = new AssembledPolygon(simpleRingWays); 1377 1377 simpleRing.reverse(); 1378 1378 newPolygons.add(simpleRing); … … 1411 1411 */ 1412 1412 private Multipolygon joinPolygon(AssembledMultipolygon polygon) throws UserCancelException { 1413 final varresult = new Multipolygon(joinWays(polygon.outerWay.ways));1413 Multipolygon result = new Multipolygon(joinWays(polygon.outerWay.ways)); 1414 1414 1415 1415 for (AssembledPolygon pol : polygon.innerWays) { … … 1429 1429 1430 1430 //leave original orientation, if all paths are reverse. 1431 varallReverse = true;1431 boolean allReverse = true; 1432 1432 for (WayInPolygon way : ways) { 1433 1433 allReverse &= !way.insideToTheRight; … … 1440 1440 } 1441 1441 1442 final varjoinedWay = joinOrientedWays(ways);1442 Way joinedWay = joinOrientedWays(ways); 1443 1443 1444 1444 //should not happen … … 1462 1462 // the user about this. 1463 1463 1464 final var actionWays = new ArrayList<Way>(ways.size());1465 varoldestPos = 0;1464 List<Way> actionWays = new ArrayList<>(ways.size()); 1465 int oldestPos = 0; 1466 1466 Way oldest = ways.get(0).way; 1467 1467 for (WayInPolygon way : ways) { … … 1511 1511 } 1512 1512 1513 varhasKnownOuter = false;1513 boolean hasKnownOuter = false; 1514 1514 outerWays.clear(); 1515 1515 innerWays.clear(); … … 1538 1538 } 1539 1539 1540 final varouterWay = outerWays.get(0);1540 Way outerWay = outerWays.get(0); 1541 1541 1542 1542 //retain only selected inner ways … … 1588 1588 processedInnerWays.addAll(innerWays); 1589 1589 1590 final varpol = new Multipolygon(outerWay);1590 Multipolygon pol = new Multipolygon(outerWay); 1591 1591 pol.innerWays.addAll(innerWays); 1592 1592 … … 1615 1615 OsmDataLayer layer = getLayerManager().getEditLayer(); 1616 1616 // Create new multipolygon relation and add all inner ways to it 1617 final varnewRel = new Relation();1617 Relation newRel = new Relation(); 1618 1618 newRel.put("type", "multipolygon"); 1619 1619 for (Way w : inner) { … … 1650 1650 1651 1651 cmds.add(new ChangeMembersCommand(r, members)); 1652 final varsaverel = new RelationRole(r, rm.getRole());1652 RelationRole saverel = new RelationRole(r, rm.getRole()); 1653 1653 if (!result.contains(saverel)) { 1654 1654 result.add(saverel); … … 1701 1701 default: 1702 1702 // Create a new relation with all previous members and (Way)outer as outer. 1703 final varnewRel = new Relation();1703 Relation newRel = new Relation(); 1704 1704 for (RelationRole r : multiouters) { 1705 1705 // Add members -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r19048 r19050 147 147 148 148 // Finally, applicableWays contains only one perfect way 149 final varselectedWay = applicableWays.get(0);150 final var sel = new ArrayList<OsmPrimitive>(ds.getSelectedRelations());149 final Way selectedWay = applicableWays.get(0); 150 final List<OsmPrimitive> sel = new ArrayList<>(ds.getSelectedRelations()); 151 151 sel.addAll(selectedWays); 152 152 doSplitWayShowSegmentSelection(selectedWay, selectedNodes, sel); … … 165 165 if (wayChunks != null) { 166 166 final List<Way> newWays = SplitWayCommand.createNewWaysFromChunks(splitWay, wayChunks); 167 final varwayToKeep = SplitWayCommand.Strategy.keepLongestChunk().determineWayToKeep(newWays);167 final Way wayToKeep = SplitWayCommand.Strategy.keepLongestChunk().determineWayToKeep(newWays); 168 168 169 169 if (ExpertToggleAction.isExpert() && !splitWay.isNew()) { … … 211 211 212 212 setButtonIcons("ok", "cancel"); 213 final varpane = new JPanel(new GridBagLayout());213 final JPanel pane = new JPanel(new GridBagLayout()); 214 214 pane.add(new JLabel(getTitle()), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 215 215 pane.add(list, GBC.eop().fill(GridBagConstraints.HORIZONTAL)); … … 225 225 final Collection<WaySegment> segments = new ArrayList<>(selected.getNodesCount() - 1); 226 226 final Iterator<Node> it = selected.getNodes().iterator(); 227 varpreviousNode = it.next();227 Node previousNode = it.next(); 228 228 while (it.hasNext()) { 229 final varnode = it.next();229 final Node node = it.next(); 230 230 segments.add(WaySegment.forNodePair(selectedWay, previousNode, node)); 231 231 previousNode = node; … … 238 238 239 239 protected void setHighlightedWaySegments(Collection<WaySegment> segments) { 240 final vards = selectedWay.getDataSet();240 final DataSet ds = selectedWay.getDataSet(); 241 241 if (ds != null) { 242 242 ds.setHighlightedWaySegments(segments); … … 248 248 public void setVisible(boolean visible) { 249 249 super.setVisible(visible); 250 final vards = selectedWay.getDataSet();250 final DataSet ds = selectedWay.getDataSet(); 251 251 if (visible) { 252 252 DISPLAY_COUNT.incrementAndGet(); … … 337 337 @Override 338 338 public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 339 final varc = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);339 final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 340 340 final String name = DefaultNameFormatter.getInstance().format((Way) value); 341 341 // get rid of id from DefaultNameFormatter.decorateNameWithId() … … 360 360 // Special case - one of the selected ways touches (not cross) way that we want to split 361 361 if (selectedNodes.size() == 1) { 362 final varn = selectedNodes.get(0);362 final Node n = selectedNodes.get(0); 363 363 List<Way> referredWays = n.getParentWays(); 364 364 Way inTheMiddle = null; -
trunk/src/org/openstreetmap/josm/actions/corrector/ReverseWayNoTagCorrector.java
r17029 r19050 102 102 null 103 103 ); 104 switch (ret) {104 switch (ret) { 105 105 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: 106 106 case JOptionPane.YES_OPTION: -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTask.java
r16611 r19050 172 172 String msg; 173 173 String id = Long.toString(p.getUniqueId()); 174 switch (p.getType()) {174 switch (p.getType()) { 175 175 case NODE: msg = tr("({0}/{1}) Loading parents of node {2}", i, children.size(), id); break; 176 176 case WAY: msg = tr("({0}/{1}) Loading parents of way {2}", i, children.size(), id); break; -
trunk/src/org/openstreetmap/josm/actions/mapmode/DeleteAction.java
r18801 r19050 91 91 } 92 92 93 private static class DeleteParameters {93 private static final class DeleteParameters { 94 94 private DeleteMode mode; 95 95 private Node nearestNode; -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r18871 r19050 225 225 226 226 private boolean updateModifiersState(int modifiers) { 227 boolean oldAlt = alt, oldShift = shift, oldCtrl = ctrl; 227 boolean oldAlt = alt; 228 boolean oldShift = shift; 229 boolean oldCtrl = ctrl; 228 230 updateKeyModifiersEx(modifiers); 229 231 return oldAlt != alt || oldShift != shift || oldCtrl != ctrl; … … 616 618 } 617 619 618 private class ParallelWayLayer extends AbstractMapViewPaintable {620 private final class ParallelWayLayer extends AbstractMapViewPaintable { 619 621 @Override 620 622 public void paint(Graphics2D g, MapView mv, Bounds bbox) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r18768 r19050 44 44 import org.openstreetmap.josm.data.osm.WaySegment; 45 45 import org.openstreetmap.josm.data.osm.visitor.AllNodesVisitor; 46 import org.openstreetmap.josm.data.osm.visitor.paint. WireframeMapRenderer;46 import org.openstreetmap.josm.data.osm.visitor.paint.AbstractMapRenderer; 47 47 import org.openstreetmap.josm.data.preferences.BooleanProperty; 48 48 import org.openstreetmap.josm.data.preferences.CachingProperty; … … 206 206 super(tr("Select mode"), "move/move", tr("Select, move, scale and rotate objects"), 207 207 Shortcut.registerShortcut("mapmode:select", tr("Mode: {0}", tr("Select mode")), KeyEvent.VK_S, Shortcut.DIRECT), 208 ImageProvider.getCursor( "normal", "selection"));208 ImageProvider.getCursor(NORMAL, "selection")); 209 209 mv = mapFrame.mapView; 210 210 setHelpId(ht("/Action/Select")); … … 316 316 private Cursor getCursor(OsmPrimitive nearbyStuff) { 317 317 String c = "rect"; 318 switch (mode) {318 switch (mode) { 319 319 case MOVE: 320 320 if (virtualManager.hasVirtualNode()) { … … 438 438 determineMapMode(nearestPrimitive != null); 439 439 440 switch (mode) {440 switch (mode) { 441 441 case ROTATE: 442 442 case SCALE: … … 519 519 return; 520 520 521 if (mode != Mode.ROTATE && mode != Mode.SCALE && (e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == 0) {521 if (mode != Mode.ROTATE && mode != Mode.SCALE && (e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) == 0) { 522 522 // button is pressed in rotate mode 523 523 return; … … 1116 1116 private final transient VirtualManager virtualManager = new VirtualManager(); 1117 1117 1118 private class CycleManager {1118 private final class CycleManager { 1119 1119 1120 1120 private Collection<OsmPrimitive> cycleList = Collections.emptyList(); … … 1255 1255 } 1256 1256 1257 private class VirtualManager {1257 private final class VirtualManager { 1258 1258 1259 1259 private Node virtualNode; … … 1294 1294 MapViewPoint p1 = mv.getState().getPointFor(wnp.a); 1295 1295 MapViewPoint p2 = mv.getState().getPointFor(wnp.b); 1296 if ( WireframeMapRenderer.isLargeSegment(p1, p2, virtualSpace)) {1296 if (AbstractMapRenderer.isLargeSegment(p1, p2, virtualSpace)) { 1297 1297 Point2D pc = new Point2D.Double((p1.getInViewX() + p2.getInViewX()) / 2, (p1.getInViewY() + p2.getInViewY()) / 2); 1298 1298 if (p.distanceSq(pc) < virtualSnapDistSq2) { -
trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java
r18871 r19050 84 84 @Override 85 85 public Match get(String keyword, boolean caseSensitive, boolean regexSearch, PushbackTokenizer tokenizer) throws SearchParseError { 86 switch (keyword) {86 switch (keyword) { 87 87 case "inview": 88 88 return new InView(false); … … 291 291 * Select the search result and display a status text for it. 292 292 */ 293 private static class SelectSearchReceiver implements SearchReceiver {293 private static final class SelectSearchReceiver implements SearchReceiver { 294 294 295 295 @Override -
trunk/src/org/openstreetmap/josm/command/AddCommand.java
r13173 r19050 72 72 public String getDescriptionText() { 73 73 String msg; 74 switch (OsmPrimitiveType.from(osm)) {74 switch (OsmPrimitiveType.from(osm)) { 75 75 case NODE: msg = marktr("Add node {0}"); break; 76 76 case WAY: msg = marktr("Add way {0}"); break; -
trunk/src/org/openstreetmap/josm/command/ChangeCommand.java
r16119 r19050 78 78 public String getDescriptionText() { 79 79 String msg; 80 switch (OsmPrimitiveType.from(osm)) {80 switch (OsmPrimitiveType.from(osm)) { 81 81 case NODE: msg = marktr("Change node {0}"); break; 82 82 case WAY: msg = marktr("Change way {0}"); break; -
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r18208 r19050 206 206 Map.Entry<String, String> entry = tags.entrySet().iterator().next(); 207 207 if (Utils.isEmpty(entry.getValue())) { 208 switch (OsmPrimitiveType.from(primitive)) {208 switch (OsmPrimitiveType.from(primitive)) { 209 209 case NODE: msg = marktr("Remove \"{0}\" for node ''{1}''"); break; 210 210 case WAY: msg = marktr("Remove \"{0}\" for way ''{1}''"); break; … … 214 214 text = tr(msg, entry.getKey(), primitive.getDisplayName(DefaultNameFormatter.getInstance())); 215 215 } else { 216 switch (OsmPrimitiveType.from(primitive)) {216 switch (OsmPrimitiveType.from(primitive)) { 217 217 case NODE: msg = marktr("Set {0}={1} for node ''{2}''"); break; 218 218 case WAY: msg = marktr("Set {0}={1} for way ''{2}''"); break; -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r18801 r19050 250 250 OsmPrimitive primitive = toDelete.iterator().next(); 251 251 String msg; 252 switch (OsmPrimitiveType.from(primitive)) {252 switch (OsmPrimitiveType.from(primitive)) { 253 253 case NODE: msg = marktr("Delete node {0}"); break; 254 254 case WAY: msg = marktr("Delete way {0}"); break; … … 265 265 } else { 266 266 OsmPrimitiveType t = typesToDelete.iterator().next(); 267 switch (t) {267 switch (t) { 268 268 case NODE: msg = trn("Delete {0} node", "Delete {0} nodes", toDelete.size(), toDelete.size()); break; 269 269 case WAY: msg = trn("Delete {0} way", "Delete {0} ways", toDelete.size(), toDelete.size()); break; -
trunk/src/org/openstreetmap/josm/command/PurgeCommand.java
r18871 r19050 96 96 // user clears undo/redo buffer after purge 97 97 PrimitiveData empty; 98 switch (osm.getType()) {98 switch (osm.getType()) { 99 99 case NODE: empty = new NodeData(); break; 100 100 case WAY: empty = new WayData(); break; -
trunk/src/org/openstreetmap/josm/command/conflict/ModifiedConflictResolveCommand.java
r15444 r19050 36 36 public String getDescriptionText() { 37 37 String msg; 38 switch (OsmPrimitiveType.from(conflict.getMy())) {38 switch (OsmPrimitiveType.from(conflict.getMy())) { 39 39 case NODE: msg = marktr("Set the ''modified'' flag for node {0}"); break; 40 40 case WAY: msg = marktr("Set the ''modified'' flag for way {0}"); break; -
trunk/src/org/openstreetmap/josm/command/conflict/VersionConflictResolveCommand.java
r17333 r19050 36 36 public String getDescriptionText() { 37 37 String msg; 38 switch (OsmPrimitiveType.from(conflict.getMy())) {38 switch (OsmPrimitiveType.from(conflict.getMy())) { 39 39 case NODE: msg = marktr("Resolve version conflict for node {0}"); break; 40 40 case WAY: msg = marktr("Resolve version conflict for way {0}"); break; -
trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r17399 r19050 40 40 private final LinkedList<CommandQueuePreciseListener> preciseListenerCommands = new LinkedList<>(); 41 41 42 private static class InstanceHolder {42 private static final class InstanceHolder { 43 43 static final UndoRedoHandler INSTANCE = new UndoRedoHandler(); 44 44 } -
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r18832 r19050 77 77 TimeUnit.SECONDS, 78 78 // make queue of LIFO type - so recently requested tiles will be loaded first (assuming that these are which user is waiting to see) 79 new LinkedBlockingDeque< Runnable>(),79 new LinkedBlockingDeque<>(), 80 80 Utils.newThreadFactory("JCS-downloader-%d", Thread.NORM_PRIORITY) 81 81 ); … … 323 323 } 324 324 try (InputStream fileInputStream = Files.newInputStream(file.toPath())) { 325 cacheData = createCacheEntry( Utils.readBytesFromStream(fileInputStream));325 cacheData = createCacheEntry(fileInputStream.readAllBytes()); 326 326 cache.put(getCacheKey(), cacheData, attributes); 327 327 return true; … … 394 394 byte[] raw; 395 395 if (urlConn.getResponseCode() == HttpURLConnection.HTTP_OK) { 396 raw = Utils.readBytesFromStream(urlConn.getContent());396 raw = urlConn.getContent().readAllBytes(); 397 397 } else { 398 398 raw = new byte[]{}; -
trunk/src/org/openstreetmap/josm/data/coor/conversion/LatLonParser.java
r17787 r19050 61 61 private static final Pattern P_DMS = Pattern.compile("^" + DMS + "$"); 62 62 63 private static class LatLonHolder {63 private static final class LatLonHolder { 64 64 private double lat = Double.NaN; 65 65 private double lon = Double.NaN; -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r18211 r19050 152 152 private boolean isNotImage(Map<String, List<String>> headers, int statusCode) { 153 153 if (statusCode == 200 && headers.containsKey("Content-Type") && !headers.get("Content-Type").isEmpty()) { 154 String contentType = headers.get("Content-Type").stream().findAny(). get();154 String contentType = headers.get("Content-Type").stream().findAny().orElse(null); 155 155 if (contentType != null && !contentType.startsWith("image") && !MVTFile.MIMETYPE.contains(contentType.toLowerCase(Locale.ROOT))) { 156 156 Logging.warn("Image not returned for tile: " + url + " content type was: " + contentType); … … 198 198 } 199 199 200 switch (result) {200 switch (result) { 201 201 case SUCCESS: 202 202 handleNoTileAtZoom(); -
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r18911 r19050 74 74 import org.openstreetmap.josm.tools.CheckParameterUtil; 75 75 import org.openstreetmap.josm.tools.Logging; 76 import org.openstreetmap.josm.tools.Utils;77 76 78 77 /** … … 113 112 private int cachedTileSize = -1; 114 113 115 private static class TileMatrix {114 private static final class TileMatrix { 116 115 private String identifier; 117 116 private double scaleDenominator; … … 123 122 } 124 123 125 private static class TileMatrixSetBuilder {124 private static final class TileMatrixSetBuilder { 126 125 // sorted by zoom level 127 126 SortedSet<TileMatrix> tileMatrix = new TreeSet<>((o1, o2) -> -1 * Double.compare(o1.scaleDenominator, o2.scaleDenominator)); … … 194 193 } 195 194 196 private static class Dimension {195 private static final class Dimension { 197 196 private String identifier; 198 197 private String defaultValue; … … 454 453 setCachingStrategy(CachedFile.CachingStrategy.IfModifiedSince). 455 454 getInputStream()) { 456 byte[] data = Utils.readBytesFromStream(in);455 byte[] data = in.readAllBytes(); 457 456 if (data.length == 0) { 458 457 cf.clear(); -
trunk/src/org/openstreetmap/josm/data/oauth/OAuth20Exception.java
r18723 r19050 55 55 : "Unknown error"); 56 56 if (serverMessage != null && serverMessage.containsKey("error")) { 57 switch (serverMessage.getString("error")) {57 switch (serverMessage.getString("error")) { 58 58 case "invalid_request": 59 59 case "invalid_client": -
trunk/src/org/openstreetmap/josm/data/osm/DataSetMerger.java
r18801 r19050 115 115 // 116 116 OsmPrimitive target; 117 switch (source.getType()) {117 switch (source.getType()) { 118 118 case NODE: target = source.isNew() ? new Node() : new Node(source.getId()); break; 119 119 case WAY: target = source.isNew() ? new Way() : new Way(source.getId()); break; -
trunk/src/org/openstreetmap/josm/data/osm/OsmDataManager.java
r18801 r19050 21 21 } 22 22 23 private static class InstanceHolder {23 private static final class InstanceHolder { 24 24 static final OsmDataManager INSTANCE = new OsmDataManager(); 25 25 } -
trunk/src/org/openstreetmap/josm/data/osm/PrimitiveComparator.java
r13803 r19050 58 58 59 59 static <T extends IPrimitive> Comparator<T> doOrderingNodesWaysRelations() { 60 return comparing Int(osm -> osm.getType().ordinal());60 return comparing(PrimitiveId::getType); 61 61 } 62 62 -
trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
r19048 r19050 23 23 import java.util.function.Predicate; 24 24 import java.util.function.Supplier; 25 import java.util.regex.Matcher; 25 26 import java.util.regex.Pattern; 26 27 import java.util.regex.PatternSyntaxException; … … 1139 1140 value = Normalizer.normalize(value, Normalizer.Form.NFC); 1140 1141 1141 final var keyMatcher = searchRegex.matcher(key);1142 final var valMatcher = searchRegex.matcher(value);1142 final Matcher keyMatcher = searchRegex.matcher(key); 1143 final Matcher valMatcher = searchRegex.matcher(value); 1143 1144 1144 1145 boolean keyMatchFound = keyMatcher.find(); … … 1817 1818 if (!(osm instanceof Way)) 1818 1819 return null; 1819 final varway = (Way) osm;1820 final Way way = (Way) osm; 1820 1821 return (long) way.getLength(); 1821 1822 } … … 1970 1971 1971 1972 try { 1972 final vargroupSuffix = name.substring(0, name.length() - 2); // try to remove '/*'1973 String groupSuffix = name.substring(0, name.length() - 2); // try to remove '/*' 1973 1974 TaggingPresetMenu group = preset.group; 1974 1975 … … 2178 2179 } else if (tokenizer.readIfEqual(Token.COLON)) { 2179 2180 // see if we have a Match that takes a data parameter 2180 final varfactory = simpleMatchFactoryMap.get(key);2181 SimpleMatchFactory factory = simpleMatchFactoryMap.get(key); 2181 2182 if (factory != null) 2182 2183 return factory.get(key, caseSensitive, regexSearch, tokenizer); 2183 2184 2184 final varunaryFactory = unaryMatchFactoryMap.get(key);2185 UnaryMatchFactory unaryFactory = unaryMatchFactoryMap.get(key); 2185 2186 if (unaryFactory != null) 2186 2187 return getValidate(unaryFactory, key, tokenizer); … … 2195 2196 return new BooleanMatch(key, false); 2196 2197 else { 2197 final varfactory = simpleMatchFactoryMap.get(key);2198 SimpleMatchFactory factory = simpleMatchFactoryMap.get(key); 2198 2199 if (factory != null) 2199 2200 return factory.get(key, caseSensitive, regexSearch, null).validate(); 2200 2201 2201 final varunaryFactory = unaryMatchFactoryMap.get(key);2202 UnaryMatchFactory unaryFactory = unaryMatchFactoryMap.get(key); 2202 2203 if (unaryFactory != null) 2203 2204 return getValidate(unaryFactory, key, null); … … 2221 2222 2222 2223 private static int regexFlags(boolean caseSensitive) { 2223 varsearchFlags = 0;2224 int searchFlags = 0; 2224 2225 2225 2226 // Enables canonical Unicode equivalence so that e.g. the two -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r18871 r19050 978 978 } 979 979 980 switch (m.getRole()) {980 switch (m.getRole()) { 981 981 case "from": 982 982 if (fromWay == null) { … … 1248 1248 MapViewPath path = new MapViewPath(mapState); 1249 1249 path.appendFromEastNorth(pd.get()); 1250 path.setWindingRule( MapViewPath.WIND_EVEN_ODD);1250 path.setWindingRule(Path2D.WIND_EVEN_ODD); 1251 1251 consumer.accept(path); 1252 1252 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
r18211 r19050 68 68 * above.</p> 69 69 */ 70 private static class MultipolygonRoleMatcher implements PreferenceChangedListener {70 private static final class MultipolygonRoleMatcher implements PreferenceChangedListener { 71 71 private final List<String> outerExactRoles = new ArrayList<>(); 72 72 private final List<String> outerRolePrefixes = new ArrayList<>(); -
trunk/src/org/openstreetmap/josm/data/preferences/JosmBaseDirectories.java
r14153 r19050 26 26 } 27 27 28 private static class InstanceHolder {28 private static final class InstanceHolder { 29 29 static final JosmBaseDirectories INSTANCE = new JosmBaseDirectories(); 30 30 } -
trunk/src/org/openstreetmap/josm/data/preferences/JosmUrls.java
r14208 r19050 36 36 } 37 37 38 private static class InstanceHolder {38 private static final class InstanceHolder { 39 39 static final JosmUrls INSTANCE = new JosmUrls(); 40 40 } -
trunk/src/org/openstreetmap/josm/data/preferences/PreferencesReader.java
r14441 r19050 168 168 if (event == XMLStreamConstants.START_ELEMENT) { 169 169 String localName = parser.getLocalName(); 170 switch (localName) {170 switch (localName) { 171 171 case "tag": 172 172 StringSetting setting; … … 240 240 if (event == XMLStreamConstants.START_ELEMENT) { 241 241 String localName = parser.getLocalName(); 242 switch (localName) {242 switch (localName) { 243 243 case "entry": 244 244 if (entries == null) { -
trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2Proj4DirGridShiftFileSource.java
r18211 r19050 29 29 30 30 // lazy initialization 31 private static class InstanceHolder {31 private static final class InstanceHolder { 32 32 static final NTV2Proj4DirGridShiftFileSource INSTANCE = new NTV2Proj4DirGridShiftFileSource(); 33 33 } -
trunk/src/org/openstreetmap/josm/data/validation/ValidatorCLI.java
r19048 r19050 11 11 import java.nio.charset.StandardCharsets; 12 12 import java.nio.file.Files; 13 import java.nio.file.Path; 13 14 import java.nio.file.Paths; 14 15 import java.util.ArrayList; … … 30 31 import org.openstreetmap.josm.cli.CLIModule; 31 32 import org.openstreetmap.josm.data.Preferences; 33 import org.openstreetmap.josm.data.osm.DataSet; 32 34 import org.openstreetmap.josm.data.preferences.JosmBaseDirectories; 33 35 import org.openstreetmap.josm.data.preferences.JosmUrls; … … 174 176 } 175 177 this.initialize(); 176 final var fileMonitor = progressMonitorFactory.get();178 final ProgressMonitor fileMonitor = progressMonitorFactory.get(); 177 179 fileMonitor.beginTask(tr("Processing files..."), this.input.size()); 178 180 for (String inputFile : this.input) { … … 200 202 */ 201 203 private static void processMapcssFile(final String inputFile) throws ParseException { 202 final varstyleSource = new MapCSSStyleSource(new File(inputFile).toURI().getPath(), inputFile, inputFile);204 final MapCSSStyleSource styleSource = new MapCSSStyleSource(new File(inputFile).toURI().getPath(), inputFile, inputFile); 203 205 styleSource.loadStyleSource(); 204 206 if (!styleSource.getErrors().isEmpty()) { … … 219 221 // Check asserts 220 222 Config.getPref().putBoolean("validator.check_assert_local_rules", true); 221 final var mapCSSTagChecker = new MapCSSTagChecker();222 final var assertionErrors = new ArrayList<String>();223 final MapCSSTagChecker mapCSSTagChecker = new MapCSSTagChecker(); 224 final Collection<String> assertionErrors = new ArrayList<>(); 223 225 final MapCSSTagChecker.ParseResult result = mapCSSTagChecker.addMapCSS(new File(inputFile).toURI().getPath(), 224 226 assertionErrors::add); … … 245 247 */ 246 248 private void processFile(final String inputFile) throws IllegalDataException, IOException { 247 final varinputFileFile = new File(inputFile);249 final File inputFileFile = new File(inputFile); 248 250 final List<FileImporter> inputFileImporters = ExtensionFileFilter.getImporters().stream() 249 251 .filter(importer -> importer.acceptFile(inputFileFile)).collect(Collectors.toList()); 250 final varstopwatch = Stopwatch.createStarted();252 final Stopwatch stopwatch = Stopwatch.createStarted(); 251 253 if (inputFileImporters.stream().noneMatch(fileImporter -> 252 254 fileImporter.importDataHandleExceptions(inputFileFile, progressMonitorFactory.get()))) { … … 261 263 .stream().filter(layer -> inputFileFile.equals(layer.getAssociatedFile())) 262 264 .findFirst().orElseThrow(() -> new JosmRuntimeException(tr("Could not find a layer for {0}", inputFile))); 263 final vardataSet = dataLayer.getDataSet();265 final DataSet dataSet = dataLayer.getDataSet(); 264 266 if (this.changeFiles.containsKey(inputFile)) { 265 final var changeFilesMonitor = progressMonitorFactory.get();267 final ProgressMonitor changeFilesMonitor = progressMonitorFactory.get(); 266 268 for (String changeFile : this.changeFiles.getOrDefault(inputFile, Collections.emptyList())) { 267 try ( varchangeStream = Compression.getUncompressedFileInputStream(Paths.get(changeFile))) {269 try (InputStream changeStream = Compression.getUncompressedFileInputStream(Paths.get(changeFile))) { 268 270 dataSet.mergeFrom(OsmChangeReader.parseDataSet(changeStream, changeFilesMonitor)); 269 271 } 270 272 } 271 273 } 272 final varpath = Paths.get(outputFile);274 final Path path = Paths.get(outputFile); 273 275 if (path.toFile().isFile() && !Files.deleteIfExists(path)) { 274 276 Logging.error("Could not delete {0}, attempting to append", outputFile); 275 277 } 276 final var geoJSONMapRouletteWriter = new GeoJSONMapRouletteWriter(dataSet);278 final GeoJSONMapRouletteWriter geoJSONMapRouletteWriter = new GeoJSONMapRouletteWriter(dataSet); 277 279 OsmValidator.initializeTests(); 278 280 279 try ( varfileOutputStream = Files.newOutputStream(path)) {281 try (OutputStream fileOutputStream = Files.newOutputStream(path)) { 280 282 // The first writeErrors catches anything that was written, for whatever reason. This is probably never 281 283 // going to be called. … … 346 348 /** 347 349 * Initialize everything that might be needed 348 * <p>350 * 349 351 * Arguments may need to be parsed first. 350 352 */ … … 367 369 Logging.setLogLevel(Level.INFO); 368 370 369 final var parser = new OptionParser("JOSM validate");370 final var currentInput = new AtomicReference<String>(null);371 OptionParser parser = new OptionParser("JOSM validate"); 372 final AtomicReference<String> currentInput = new AtomicReference<>(null); 371 373 for (Option o : Option.values()) { 372 374 if (o.requiresArgument()) { … … 423 425 break; 424 426 case LOAD_PREFERENCES: 425 final vartempPreferences = new Preferences();427 final Preferences tempPreferences = new Preferences(); 426 428 tempPreferences.enableSaveOnPut(false); 427 final var config = new CustomConfigurator.XMLCommandProcessor(tempPreferences);429 CustomConfigurator.XMLCommandProcessor config = new CustomConfigurator.XMLCommandProcessor(tempPreferences); 428 430 try (InputStream is = Utils.openStream(new File(argument).toURI().toURL())) { 429 431 config.openAndReadXML(is); … … 433 435 final IPreferences pref = Config.getPref(); 434 436 if (pref instanceof MemoryPreferences) { 435 final varmemoryPreferences = (MemoryPreferences) pref;437 final MemoryPreferences memoryPreferences = (MemoryPreferences) pref; 436 438 tempPreferences.getAllSettings().forEach(memoryPreferences::putSetting); 437 439 } else { … … 452 454 453 455 private static String getHelp() { 454 final varhelpPadding = "\t ";456 final String helpPadding = "\t "; 455 457 // CHECKSTYLE.OFF: SingleSpaceSeparator 456 458 return tr("JOSM Validation command line interface") + "\n\n" + -
trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java
r19039 r19050 1853 1853 .toArray(String[]::new); 1854 1854 Arrays.sort(copy); 1855 switch (table) {1855 switch (table) { 1856 1856 case COUNTRY_CODE_MINUS: 1857 1857 countryCodeTLDsMinus = copy; … … 1885 1885 public static String[] getTLDEntries(ArrayType table) { 1886 1886 final String[] array; 1887 switch (table) {1887 switch (table) { 1888 1888 case COUNTRY_CODE_MINUS: 1889 1889 array = countryCodeTLDsMinus; … … 1943 1943 // (halfwidth ideographic full stop). 1944 1944 char lastChar = input.charAt(length-1); // fetch original last char 1945 switch (lastChar) {1945 switch (lastChar) { 1946 1946 case '.': // "." full stop, AKA U+002E 1947 1947 case '\u3002': // ideographic full stop … … 1958 1958 } 1959 1959 1960 private static class IdnBugHolder {1960 private static final class IdnBugHolder { 1961 1961 private static boolean keepsTrailingDot() { 1962 1962 final String input = "a."; // must be a valid name -
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r18801 r19050 109 109 } 110 110 for (TaggingPreset p : TaggingPresets.getTaggingPresets()) { 111 if (p.data.stream().anyMatch( i -> i instanceof Roles)) {111 if (p.data.stream().anyMatch(Roles.class::isInstance)) { 112 112 relationpresets.add(p); 113 113 } … … 115 115 } 116 116 117 private static class RoleInfo {117 private static final class RoleInfo { 118 118 private int total; 119 119 } -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r19019 r19050 1047 1047 SwingUtilities.invokeLater(new GuiFinalizationWorker(args, proxySelector)); 1048 1048 1049 if ( RemoteControl.PROP_REMOTECONTROL_ENABLED.get()) {1049 if (Boolean.TRUE.equals(RemoteControl.PROP_REMOTECONTROL_ENABLED.get())) { 1050 1050 RemoteControl.start(); 1051 1051 } 1052 1052 1053 if ( MessageNotifier.PROP_NOTIFIER_ENABLED.get()) {1053 if (Boolean.TRUE.equals(MessageNotifier.PROP_NOTIFIER_ENABLED.get())) { 1054 1054 MessageNotifier.start(); 1055 1055 } … … 1478 1478 1479 1479 private static void handleAutosave() { 1480 if ( AutosaveTask.PROP_AUTOSAVE_ENABLED.get()) {1480 if (Boolean.TRUE.equals(AutosaveTask.PROP_AUTOSAVE_ENABLED.get())) { 1481 1481 AutosaveTask autosaveTask = new AutosaveTask(); 1482 1482 List<File> unsavedLayerFiles = autosaveTask.getUnsavedLayersFiles(); … … 1559 1559 } 1560 1560 1561 private static class DefaultNativeOsCallback implements NativeOsCallback {1561 private static final class DefaultNativeOsCallback implements NativeOsCallback { 1562 1562 @Override 1563 1563 public void openFiles(List<File> files) { -
trunk/src/org/openstreetmap/josm/gui/MainFrame.java
r18287 r19050 7 7 import java.awt.Component; 8 8 import java.awt.ComponentOrientation; 9 import java.awt.Frame; 9 10 import java.awt.Image; 10 11 import java.awt.Rectangle; … … 24 25 import javax.swing.JFrame; 25 26 import javax.swing.JPanel; 27 import javax.swing.WindowConstants; 26 28 27 29 import org.openstreetmap.josm.data.UserIdentityManager; … … 55 57 56 58 protected transient WindowGeometry geometry; 57 protected int windowState = JFrame.NORMAL;59 protected int windowState = Frame.NORMAL; 58 60 private final MainPanel panel; 59 61 private MainMenu menu; … … 111 113 setIconImages(l); 112 114 addWindowListener(new ExitWindowAdapter()); 113 setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE);115 setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); 114 116 115 117 // This listener is never removed, since the main frame exists forever. … … 131 133 geometry.remember(WindowGeometry.PREF_KEY_GUI_GEOMETRY); 132 134 } 133 Config.getPref().putBoolean("gui.maximized", (windowState & JFrame.MAXIMIZED_BOTH) != 0);135 Config.getPref().putBoolean("gui.maximized", (windowState & Frame.MAXIMIZED_BOTH) != 0); 134 136 } 135 137 … … 162 164 public void setMaximized(boolean maximized) { 163 165 if (maximized) { 164 if (Toolkit.getDefaultToolkit().isFrameStateSupported( JFrame.MAXIMIZED_BOTH)) {165 windowState = JFrame.MAXIMIZED_BOTH;166 if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) { 167 windowState = Frame.MAXIMIZED_BOTH; 166 168 setExtendedState(windowState); 167 169 } else { … … 229 231 } 230 232 231 private class WindowPositionSizeListener extends WindowAdapter implements ComponentListener {233 private final class WindowPositionSizeListener extends WindowAdapter implements ComponentListener { 232 234 @Override 233 235 public void windowStateChanged(WindowEvent e) { … … 258 260 Component c = e.getComponent(); 259 261 if (c instanceof JFrame && c.isVisible()) { 260 if (windowState == JFrame.NORMAL) {262 if (windowState == Frame.NORMAL) { 261 263 geometry = new WindowGeometry((JFrame) c); 262 264 } else { -
trunk/src/org/openstreetmap/josm/gui/MainInitialization.java
r18985 r19050 158 158 } 159 159 160 private static class JosmSettingsAdapter implements SettingsAdapter {160 private static final class JosmSettingsAdapter implements SettingsAdapter { 161 161 162 162 @Override -
trunk/src/org/openstreetmap/josm/gui/MapMover.java
r17333 r19050 7 7 import java.awt.Point; 8 8 import java.awt.event.ActionEvent; 9 import java.awt.event.InputEvent; 9 10 import java.awt.event.KeyEvent; 10 11 import java.awt.event.MouseAdapter; … … 88 89 EastNorth center = nc.getCenter(); 89 90 EastNorth newcenter = nc.getEastNorth(nc.getWidth()/2+nc.getWidth()/5, nc.getHeight()/2+nc.getHeight()/5); 90 switch (action) {91 switch (action) { 91 92 case "left": 92 93 nc.zoomTo(new EastNorth(2*center.east()-newcenter.east(), center.north())); … … 173 174 @Override 174 175 public void mouseDragged(MouseEvent e) { 175 int offMask = MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON2_DOWN_MASK;176 boolean allowMovement = (e.getModifiersEx() & ( MouseEvent.BUTTON3_DOWN_MASK | offMask)) == MouseEvent.BUTTON3_DOWN_MASK;176 int offMask = InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON2_DOWN_MASK; 177 boolean allowMovement = (e.getModifiersEx() & (InputEvent.BUTTON3_DOWN_MASK | offMask)) == InputEvent.BUTTON3_DOWN_MASK; 177 178 if (PlatformManager.isPlatformOsx()) { 178 179 MapFrame map = MainApplication.getMap(); 179 int macMouseMask = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK;180 int macMouseMask = InputEvent.CTRL_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK; 180 181 boolean macMovement = e.getModifiersEx() == macMouseMask; 181 182 boolean allowedMode = !map.mapModeSelect.equals(map.mapMode) … … 204 205 @Override 205 206 public void mousePressed(MouseEvent e) { 206 int offMask = MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON2_DOWN_MASK;207 int macMouseMask = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK;207 int offMask = InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON2_DOWN_MASK; 208 int macMouseMask = InputEvent.CTRL_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK; 208 209 if ((e.getButton() == MouseEvent.BUTTON3 && (e.getModifiersEx() & offMask) == 0) || 209 210 (PlatformManager.isPlatformOsx() && e.getModifiersEx() == macMouseMask)) { … … 253 254 @Override 254 255 public void mouseWheelMoved(MouseWheelEvent e) { 255 int rotation = PROP_ZOOM_REVERSE_WHEEL.get() ? -e.getWheelRotation() : e.getWheelRotation();256 int rotation = Boolean.TRUE.equals(PROP_ZOOM_REVERSE_WHEEL.get()) ? -e.getWheelRotation() : e.getWheelRotation(); 256 257 nc.zoomManyTimes(e.getX(), e.getY(), rotation); 257 258 } … … 268 269 // Is only the selected mouse button pressed? 269 270 if (PlatformManager.isPlatformOsx()) { 270 if (e.getModifiersEx() == MouseEvent.CTRL_DOWN_MASK) {271 if (e.getModifiersEx() == InputEvent.CTRL_DOWN_MASK) { 271 272 doMoveForDrag(e); 272 273 } else { -
trunk/src/org/openstreetmap/josm/gui/MenuScroller.java
r16913 r19050 350 350 } 351 351 352 private class MenuScrollListener implements PopupMenuListener {352 private final class MenuScrollListener implements PopupMenuListener { 353 353 354 354 @Override … … 453 453 } 454 454 455 private class MouseScrollListener implements MouseWheelListener {455 private final class MouseScrollListener implements MouseWheelListener { 456 456 @Override 457 457 public void mouseWheelMoved(MouseWheelEvent mwe) { -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r18871 r19050 1061 1061 1062 1062 if (ds != null) { 1063 double dist, snapDistanceSq = PROP_SNAP_DISTANCE.get(); 1063 double dist; 1064 double snapDistanceSq = PROP_SNAP_DISTANCE.get(); 1064 1065 snapDistanceSq *= snapDistanceSq; 1065 1066 … … 1192 1193 1193 1194 if (preferredRefs != null && preferredRefs.isEmpty()) preferredRefs = null; 1194 Node ntsel = null, ntnew = null, ntref = null; 1195 Node ntsel = null; 1196 Node ntnew = null; 1197 Node ntref = null; 1195 1198 boolean useNtsel = useSelected; 1196 1199 double minDistSq = nlists.keySet().iterator().next(); … … 1788 1791 * so that registered {@link PrimitiveHoverListener}s can be notified. 1789 1792 */ 1790 private class PrimitiveHoverMouseListener extends MouseAdapter {1793 private final class PrimitiveHoverMouseListener extends MouseAdapter { 1791 1794 @Override 1792 1795 public void mouseMoved(MouseEvent e) { -
trunk/src/org/openstreetmap/josm/gui/NotificationManager.java
r17901 r19050 183 183 } 184 184 185 private class PauseFinishedEvent implements ActionListener {185 private final class PauseFinishedEvent implements ActionListener { 186 186 187 187 @Override … … 194 194 } 195 195 196 private class UnfreezeEvent implements ActionListener {196 private final class UnfreezeEvent implements ActionListener { 197 197 198 198 @Override -
trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
r18456 r19050 79 79 * @author Michael Zangl 80 80 */ 81 private class SelectionHintLayer extends AbstractMapViewPaintable {81 private final class SelectionHintLayer extends AbstractMapViewPaintable { 82 82 @Override 83 83 public void paint(Graphics2D g, MapView mv, Bounds bbox) { … … 186 186 if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() > 1 && MainApplication.getLayerManager().getActiveDataSet() != null) { 187 187 SelectByInternalPointAction.performSelection(MainApplication.getMap().mapView.getEastNorth(e.getX(), e.getY()), 188 (e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0,188 (e.getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) != 0, 189 189 (e.getModifiersEx() & PlatformManager.getPlatform().getMenuShortcutKeyMaskEx()) != 0); 190 190 } else if (e.getButton() == MouseEvent.BUTTON1) { … … 201 201 @Override 202 202 public void mouseDragged(MouseEvent e) { 203 int buttonPressed = e.getModifiersEx() & ( MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON3_DOWN_MASK);203 int buttonPressed = e.getModifiersEx() & (InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON3_DOWN_MASK); 204 204 205 205 if (buttonPressed != 0) { … … 210 210 } 211 211 212 if (buttonPressed == MouseEvent.BUTTON1_DOWN_MASK) {212 if (buttonPressed == InputEvent.BUTTON1_DOWN_MASK) { 213 213 mousePos = e.getPoint(); 214 214 addLassoPoint(e.getPoint()); 215 215 selectionAreaChanged(); 216 } else if (buttonPressed == ( MouseEvent.BUTTON1_DOWN_MASK | MouseEvent.BUTTON3_DOWN_MASK)) {216 } else if (buttonPressed == (InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON3_DOWN_MASK)) { 217 217 moveSelection(e.getX()-mousePos.x, e.getY()-mousePos.y); 218 218 mousePos = e.getPoint(); … … 253 253 254 254 // Left mouse was released while right is still pressed. 255 boolean rightMouseStillPressed = (e.getModifiersEx() & MouseEvent.BUTTON3_DOWN_MASK) != 0;255 boolean rightMouseStillPressed = (e.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0; 256 256 257 257 if (!rightMouseStillPressed) { … … 317 317 @Override 318 318 public void propertyChange(PropertyChangeEvent evt) { 319 if ("active".equals(evt.getPropertyName()) && !(Boolean) evt.getNewValue()) {319 if ("active".equals(evt.getPropertyName()) && Boolean.FALSE.equals(evt.getNewValue())) { 320 320 abortSelecting(); 321 321 } -
trunk/src/org/openstreetmap/josm/gui/bbox/SlippyMapController.java
r17334 r19050 45 45 private static final double ACCELERATION = 0.10; 46 46 47 private static final int MAC_MOUSE_BUTTON3_MASK = MouseEvent.CTRL_DOWN_MASK | MouseEvent.BUTTON1_DOWN_MASK;47 private static final int MAC_MOUSE_BUTTON3_MASK = InputEvent.CTRL_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK; 48 48 49 49 private static final String[] N = { … … 73 73 for (int i = 0; i < N.length; ++i) { 74 74 contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put( 75 KeyStroke.getKeyStroke(K[i], KeyEvent.CTRL_DOWN_MASK), "MapMover.Zoomer." + N[i]);75 KeyStroke.getKeyStroke(K[i], InputEvent.CTRL_DOWN_MASK), "MapMover.Zoomer." + N[i]); 76 76 } 77 77 } … … 130 130 @Override 131 131 public void mouseDragged(MouseEvent e) { 132 if (iStartSelectionPoint != null && (e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) == MouseEvent.BUTTON1_DOWN_MASK132 if (iStartSelectionPoint != null && (e.getModifiersEx() & InputEvent.BUTTON1_DOWN_MASK) == InputEvent.BUTTON1_DOWN_MASK 133 133 && !(PlatformManager.isPlatformOsx() && e.getModifiersEx() == MAC_MOUSE_BUTTON3_MASK)) { 134 134 iEndSelectionPoint = e.getPoint(); … … 195 195 196 196 /** Moves the map depending on which cursor keys are pressed (or not) */ 197 private class MoveTask extends TimerTask {197 private final class MoveTask extends TimerTask { 198 198 /** The current x speed (pixels per timer interval) */ 199 199 private double speedX = 1; … … 212 212 * executed via timer) or disabled 213 213 */ 214 protectedboolean scheduled;215 216 protectedvoid setDirectionX(int directionX) {214 boolean scheduled; 215 216 void setDirectionX(int directionX) { 217 217 this.directionX = directionX; 218 218 updateScheduleStatus(); 219 219 } 220 220 221 protectedvoid setDirectionY(int directionY) {221 void setDirectionY(int directionY) { 222 222 this.directionY = directionY; 223 223 updateScheduleStatus(); … … 301 301 } 302 302 303 private class ZoomInAction extends AbstractAction {303 private final class ZoomInAction extends AbstractAction { 304 304 305 305 @Override … … 309 309 } 310 310 311 private class ZoomOutAction extends AbstractAction {311 private final class ZoomOutAction extends AbstractAction { 312 312 313 313 @Override -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListTableCellRenderer.java
r12663 r19050 111 111 renderEmptyRow(); 112 112 } else { 113 switch (column) {113 switch (column) { 114 114 case 0: 115 115 renderRowId(getModel(table), row); -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/properties/PropertiesMergeModel.java
r18489 r19050 180 180 */ 181 181 public LatLon getMergedCoords() { 182 switch (coordMergeDecision) {182 switch (coordMergeDecision) { 183 183 case KEEP_MINE: return myCoords; 184 184 case KEEP_THEIR: return theirCoords; … … 221 221 */ 222 222 public Boolean getMergedDeletedState() { 223 switch (deletedMergeDecision) {223 switch (deletedMergeDecision) { 224 224 case KEEP_MINE: return myDeletedState; 225 225 case KEEP_THEIR: return theirDeletedState; -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/relation/RelationMemberTableCellRenderer.java
r12663 r19050 125 125 renderBackground(getModel(table), member, row, column, isSelected); 126 126 renderForeground(getModel(table), member, row, column, isSelected); 127 switch (column) {127 switch (column) { 128 128 case 0: 129 129 renderRowId(row); -
trunk/src/org/openstreetmap/josm/gui/conflict/pair/tags/TagMergeTableCellRenderer.java
r12661 r19050 35 35 36 36 TagMergeItem item = (TagMergeItem) value; 37 switch (col) {37 switch (col) { 38 38 case 0: 39 39 renderKey(item, isSelected); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellEditor.java
r18801 r19050 150 150 editorModel.addElement(MultiValueDecisionType.KEEP_ALL); 151 151 } 152 switch (decision.getDecisionType()) {152 switch (decision.getDecisionType()) { 153 153 case UNDECIDED: 154 154 editor.setSelectedItem(MultiValueDecisionType.UNDECIDED); … … 220 220 setText((String) value); 221 221 } else if (value instanceof MultiValueDecisionType) { 222 switch ((MultiValueDecisionType) value) {222 switch ((MultiValueDecisionType) value) { 223 223 case UNDECIDED: 224 224 setText(tr("Choose a value")); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java
r18221 r19050 155 155 renderColors(decision, isSelected, conflict); 156 156 renderToolTipText(decision); 157 switch (column) {157 switch (column) { 158 158 case 0: 159 159 if (decision.isDecided()) { -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueResolutionDecision.java
r17333 r19050 143 143 */ 144 144 public String getChosenValue() { 145 switch (type) {145 switch (type) { 146 146 case UNDECIDED: throw new IllegalStateException(tr("Not decided yet")); 147 147 case KEEP_ONE: return value; … … 294 294 */ 295 295 public Tag getResolution() { 296 switch (type) {296 switch (type) { 297 297 case SUM_ALL_NUMERIC: return new Tag(getKey(), tags.getSummedValues(getKey())); 298 298 case KEEP_ALL: return new Tag(getKey(), tags.getJoinedValues(getKey())); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/PasteTagsConflictResolverDialog.java
r16438 r19050 429 429 } 430 430 String msg; 431 switch (type) {431 switch (type) { 432 432 case NODE: msg = trn("{0} node", "{0} nodes", numPrimitives, numPrimitives); break; 433 433 case WAY: msg = trn("{0} way", "{0} ways", numPrimitives, numPrimitives); break; … … 461 461 StatisticsInfo info = (StatisticsInfo) value; 462 462 463 switch (column) {463 switch (column) { 464 464 case 0: renderNumTags(info); break; 465 465 case 1: renderFrom(info); break; -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java
r17220 r19050 106 106 107 107 RelationMemberConflictDecision d = decisions.get(row); 108 switch (column) {108 switch (column) { 109 109 case 0: /* relation */ return d.getRelation(); 110 110 case 1: /* pos */ return Integer.toString(d.getPos() + 1); // position in "user space" starting at 1 111 111 case 2: /* role */ return d.getRole(); 112 112 case 3: /* original */ return d.getOriginalPrimitive(); 113 case 4: /* decision keep */ return RelationMemberConflictDecisionType.KEEP .equals(d.getDecision());114 case 5: /* decision remove */ return RelationMemberConflictDecisionType.REMOVE .equals(d.getDecision());113 case 4: /* decision keep */ return RelationMemberConflictDecisionType.KEEP == d.getDecision(); 114 case 5: /* decision remove */ return RelationMemberConflictDecisionType.REMOVE == d.getDecision(); 115 115 } 116 116 return null; … … 120 120 public void setValueAt(Object value, int row, int column) { 121 121 RelationMemberConflictDecision d = decisions.get(row); 122 switch (column) {122 switch (column) { 123 123 case 2: /* role */ 124 124 d.setRole((String) value); … … 200 200 decisions.clear(); 201 201 this.relations = new HashSet<>(references.size()); 202 final Collection<OsmPrimitive> primitives = new HashSet<>();202 final Collection<OsmPrimitive> newPrimitives = new HashSet<>(); 203 203 for (RelationToChildReference reference: references) { 204 204 decisions.add(new RelationMemberConflictDecision(reference.getParent(), reference.getPosition())); 205 205 relations.add(reference.getParent()); 206 primitives.add(reference.getChild());207 } 208 this.primitives = primitives;206 newPrimitives.add(reference.getChild()); 207 } 208 this.primitives = newPrimitives; 209 209 refresh(); 210 210 } … … 249 249 final OsmPrimitive primitive = decision.getOriginalPrimitive(); 250 250 if (!decisionsByPrimitive.containsKey(primitive)) { 251 decisionsByPrimitive.put(primitive, new ArrayList< RelationMemberConflictDecision>());251 decisionsByPrimitive.put(primitive, new ArrayList<>()); 252 252 } 253 253 decisionsByPrimitive.get(primitive).add(decision); … … 263 263 .collect(Collectors.toList()); 264 264 while (iterators.stream().allMatch(Iterator::hasNext)) { 265 final List<RelationMemberConflictDecision> decisions = new ArrayList<>();265 final List<RelationMemberConflictDecision> conflictDecisions = new ArrayList<>(); 266 266 final Collection<String> roles = new HashSet<>(); 267 267 final Collection<Integer> indices = new TreeSet<>(); 268 268 for (Iterator<RelationMemberConflictDecision> it : iterators) { 269 269 final RelationMemberConflictDecision decision = it.next(); 270 decisions.add(decision);270 conflictDecisions.add(decision); 271 271 roles.add(decision.getRole()); 272 272 indices.add(decision.getPos()); … … 276 276 continue; 277 277 } 278 decisions.get(0).decide(RelationMemberConflictDecisionType.KEEP);279 for (RelationMemberConflictDecision decision : decisions.subList(1, decisions.size())) {278 conflictDecisions.get(0).decide(RelationMemberConflictDecisionType.KEEP); 279 for (RelationMemberConflictDecision decision : conflictDecisions.subList(1, conflictDecisions.size())) { 280 280 decision.decide(RelationMemberConflictDecisionType.REMOVE); 281 281 } … … 372 372 modifiedMemberList.add(member); 373 373 } else { 374 switch (decision.getDecision()) {374 switch (decision.getDecision()) { 375 375 case KEEP: 376 376 final RelationMember newMember = new RelationMember(decision.getRole(), newPrimitive); … … 410 410 continue; 411 411 } 412 switch (decision.getDecision()) {412 switch (decision.getDecision()) { 413 413 case REMOVE: return true; 414 414 case KEEP: -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverModel.java
r19022 r19050 176 176 } else if (value instanceof MultiValueDecisionType) { 177 177 MultiValueDecisionType type = (MultiValueDecisionType) value; 178 switch (type) {178 switch (type) { 179 179 case KEEP_NONE: 180 180 decision.keepNone(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/CommandStackDialog.java
r18801 r19050 6 6 import java.awt.Component; 7 7 import java.awt.Dimension; 8 import java.awt.GridBagConstraints; 8 9 import java.awt.GridBagLayout; 9 10 import java.awt.event.ActionEvent; … … 120 121 treesPanel.add(spacer, GBC.eol()); 121 122 spacer.setVisible(false); 122 treesPanel.add(undoTree, GBC.eol().fill(G BC.HORIZONTAL));123 treesPanel.add(undoTree, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 123 124 separator.setVisible(false); 124 treesPanel.add(separator, GBC.eol().fill(G BC.HORIZONTAL));125 treesPanel.add(redoTree, GBC.eol().fill(G BC.HORIZONTAL));125 treesPanel.add(separator, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 126 treesPanel.add(redoTree, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 126 127 treesPanel.add(Box.createRigidArea(new Dimension(0, 0)), GBC.std().weight(0, 1)); 127 128 treesPanel.setBackground(redoTree.getBackground()); … … 146 147 } 147 148 148 private static class CommandCellRenderer extends DefaultTreeCellRenderer {149 private static final class CommandCellRenderer extends DefaultTreeCellRenderer { 149 150 @Override 150 151 public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
r14153 r19050 16 16 import javax.swing.JOptionPane; 17 17 import javax.swing.JPanel; 18 import javax.swing.SwingConstants; 18 19 19 20 import org.openstreetmap.josm.data.UndoRedoHandler; … … 34 35 /** the conflict resolver component */ 35 36 private final ConflictResolver resolver = new ConflictResolver(); 36 private final JLabel titleLabel = new JLabel("", null, JLabel.CENTER);37 private final JLabel titleLabel = new JLabel("", null, SwingConstants.CENTER); 37 38 38 39 private final ApplyResolutionAction applyResolutionAction = new ApplyResolutionAction(); … … 196 197 options[1] 197 198 ); 198 switch (ret) {199 switch (ret) { 199 200 case JOptionPane.YES_OPTION: 200 201 buttonAction(1, evt); -
trunk/src/org/openstreetmap/josm/gui/dialogs/DeleteFromRelationConfirmationDialog.java
r18395 r19050 215 215 */ 216 216 public static class RelationMemberTableModel extends DefaultTableModel { 217 private static class RelationToChildReferenceComparator implements Comparator<RelationToChildReference>, Serializable {217 private static final class RelationToChildReferenceComparator implements Comparator<RelationToChildReference>, Serializable { 218 218 private static final long serialVersionUID = 1L; 219 219 @Override … … 292 292 if (data == null) return null; 293 293 RelationToChildReference ref = data.get(rowIndex); 294 switch (columnIndex) {294 switch (columnIndex) { 295 295 case 0: return ref.getChild(); 296 296 case 1: return ref.getParent(); … … 423 423 } 424 424 Pair<Relation, Boolean> ref = this.data.get(rowIndex); 425 switch (columnIndex) {425 switch (columnIndex) { 426 426 case 0: return ref.a; 427 427 case 1: return ref.b; -
trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java
r17773 r19050 695 695 } 696 696 697 private class LayerNameCellRenderer extends DefaultTableCellRenderer {698 699 protectedboolean isActiveLayer(Layer layer) {697 private final class LayerNameCellRenderer extends DefaultTableCellRenderer { 698 699 boolean isActiveLayer(Layer layer) { 700 700 return getLayerManager().getActiveLayer() == layer; 701 701 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r18715 r19050 8 8 import java.awt.Dimension; 9 9 import java.awt.Font; 10 import java.awt.GridBagConstraints; 10 11 import java.awt.GridBagLayout; 11 12 import java.awt.Insets; … … 122 123 123 124 cbWireframe = new JCheckBox(); 124 JLabel wfLabel = new JLabel(tr("Wireframe View"), ImageProvider.get("dialogs/mappaint", "wireframe_small"), JLabel.HORIZONTAL);125 JLabel wfLabel = new JLabel(tr("Wireframe View"), ImageProvider.get("dialogs/mappaint", "wireframe_small"), SwingConstants.HORIZONTAL); 125 126 wfLabel.setFont(wfLabel.getFont().deriveFont(Font.PLAIN)); 126 127 wfLabel.setLabelFor(cbWireframe); … … 296 297 } 297 298 298 private class StyleSourceRenderer extends DefaultTableCellRenderer {299 private final class StyleSourceRenderer extends DefaultTableCellRenderer { 299 300 @Override 300 301 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { … … 575 576 tabs.setEnabledAt(pos, false); 576 577 } else { 577 JLabel lblErrors = new JLabel(tr(title), icon, JLabel.HORIZONTAL);578 JLabel lblErrors = new JLabel(tr(title), icon, SwingConstants.HORIZONTAL); 578 579 lblErrors.setLabelFor(pErrors); 579 580 tabs.setTabComponentAt(pos, lblErrors); … … 601 602 text.append(tableRow(tr("Style is currently active?"), s.active ? tr("Yes") : tr("No"))) 602 603 .append("</table>"); 603 p.add(new JScrollPane(new HtmlPanel(text.toString())), GBC.eol().fill(G BC.BOTH));604 p.add(new JScrollPane(new HtmlPanel(text.toString())), GBC.eol().fill(GridBagConstraints.BOTH)); 604 605 return p; 605 606 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/MenuItemSearchDialog.java
r17188 r19050 93 93 } 94 94 95 private static class CellRenderer implements ListCellRenderer<JMenuItem> {95 private static final class CellRenderer implements ListCellRenderer<JMenuItem> { 96 96 97 97 @Override -
trunk/src/org/openstreetmap/josm/gui/dialogs/SelectionListDialog.java
r18815 r19050 498 498 int numRelations = 0; 499 499 for (OsmPrimitive p: selection) { 500 switch (p.getType()) {500 switch (p.getType()) { 501 501 case NODE: numNodes++; break; 502 502 case WAY: numWays++; break; -
trunk/src/org/openstreetmap/josm/gui/dialogs/UserListDialog.java
r18715 r19050 351 351 public Object getValueAt(int row, int column) { 352 352 UserInfo info = data.get(row); 353 switch (column) {353 switch (column) { 354 354 case 0: /* author */ return info.getName() == null ? "" : info.getName(); 355 355 case 1: /* count */ return info.count; -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetCacheTableCellRenderer.java
r17717 r19050 57 57 renderColors(isSelected); 58 58 Changeset cs = (Changeset) value; 59 switch (column) {59 switch (column) { 60 60 case 0: /* id */ renderId(cs.getId()); break; 61 61 case 1: /* upload comment */ renderUploadComment(cs); break; -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableCellRenderer.java
r13564 r19050 22 22 */ 23 23 protected void renderModificationType(ChangesetModificationType type) { 24 switch (type) {24 switch (type) { 25 25 case CREATED: setText(tr("Created")); break; 26 26 case UPDATED: setText(tr("Updated")); break; … … 37 37 reset(); 38 38 renderColors(isSelected); 39 switch (column) {39 switch (column) { 40 40 case 0: 41 41 if (value instanceof ChangesetModificationType) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java
r16953 r19050 114 114 @Override 115 115 public Object getValueAt(int row, int col) { 116 switch (col) {116 switch (col) { 117 117 case 0: return data.get(row).getModificationType(); 118 118 default: return data.get(row).getPrimitive(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetDiscussionTableCellRenderer.java
r17717 r19050 25 25 reset(comp, true); 26 26 renderColors(comp, isSelected); 27 switch (column) {27 switch (column) { 28 28 case 0: 29 29 renderInstant((Instant) value); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/BasicChangesetQueryPanel.java
r16436 r19050 165 165 } else { 166 166 try { 167 q = BasicQuery.valueOf( BasicQuery.class,value);167 q = BasicQuery.valueOf(value); 168 168 } catch (IllegalArgumentException e) { 169 169 Logging.log(Logging.LEVEL_WARN, tr("Unexpected value for preference ''{0}'', got ''{1}''. Resetting to default query.", … … 194 194 if (q == null) 195 195 return query; 196 switch (q) {196 switch (q) { 197 197 case MOST_RECENT_CHANGESETS: 198 198 break; -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialog.java
r16075 r19050 126 126 if (isCanceled()) 127 127 return null; 128 switch (tpQueryPanels.getSelectedIndex()) {128 switch (tpQueryPanels.getSelectedIndex()) { 129 129 case 0: 130 130 return pnlBasicChangesetQueries.buildChangesetQuery(); … … 186 186 public void actionPerformed(ActionEvent arg0) { 187 187 try { 188 switch (tpQueryPanels.getSelectedIndex()) {188 switch (tpQueryPanels.getSelectedIndex()) { 189 189 case 0: 190 190 // currently, query specifications can't be invalid in the basic query panel. -
trunk/src/org/openstreetmap/josm/gui/dialogs/layer/MergeGpxLayerDialog.java
r16630 r19050 5 5 6 6 import java.awt.Component; 7 import java.awt.GridBagConstraints; 7 8 import java.awt.GridBagLayout; 8 9 import java.awt.event.ActionEvent; … … 58 59 p.add(new JLabel("<html>" + 59 60 tr("Please select the order of the selected layers:<br>Tracks will be cut, when timestamps of higher layers are overlapping.") + 60 "</html>"), GBC.std(0, 0).fill(G BC.HORIZONTAL).span(2));61 "</html>"), GBC.std(0, 0).fill(GridBagConstraints.HORIZONTAL).span(2)); 61 62 62 63 c = new JCheckBox(tr("Connect overlapping tracks on cuts")); 63 64 c.setSelected(Config.getPref().getBoolean("mergelayer.gpx.connect", true)); 64 p.add(c, GBC.std(0, 1).fill(G BC.HORIZONTAL).span(2));65 p.add(c, GBC.std(0, 1).fill(GridBagConstraints.HORIZONTAL).span(2)); 65 66 66 67 model = new GpxLayersTableModel(layers); … … 85 86 btnDown.setIcon(ImageProvider.get("dialogs", "down", ImageSizes.SMALLICON)); 86 87 87 p.add(btnUp, GBC.std(0, 3).fill(G BC.HORIZONTAL));88 p.add(btnDown, GBC.std(1, 3).fill(G BC.HORIZONTAL));88 p.add(btnUp, GBC.std(0, 3).fill(GridBagConstraints.HORIZONTAL)); 89 p.add(btnDown, GBC.std(1, 3).fill(GridBagConstraints.HORIZONTAL)); 89 90 90 91 btnUp.addActionListener(new MoveLayersActionListener(true)); … … 152 153 } 153 154 154 private class RowSelectionChangedListener implements ListSelectionListener {155 private final class RowSelectionChangedListener implements ListSelectionListener { 155 156 156 157 @Override -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r18801 r19050 8 8 import java.awt.Container; 9 9 import java.awt.Font; 10 import java.awt.GridBagConstraints; 10 11 import java.awt.GridBagLayout; 11 12 import java.awt.Point; … … 101 102 import org.openstreetmap.josm.gui.dialogs.relation.RelationPopupMenus; 102 103 import org.openstreetmap.josm.gui.help.HelpUtil; 104 import org.openstreetmap.josm.gui.layer.Layer; 103 105 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 104 106 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 105 import org.openstreetmap.josm.gui.layer.Layer;106 107 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 107 108 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; … … 293 294 boolean presetsVisible = Config.getPref().getBoolean("properties.presets.visible", true); 294 295 if (presetsVisible && top) { 295 bothTables.add(presets, GBC.std().fill(G BC.HORIZONTAL).insets(5, 2, 5, 2).anchor(GBC.NORTHWEST));296 bothTables.add(presets, GBC.std().fill(GridBagConstraints.HORIZONTAL).insets(5, 2, 5, 2).anchor(GridBagConstraints.NORTHWEST)); 296 297 double epsilon = Double.MIN_VALUE; // need to set a weight or else anchor value is ignored 297 bothTables.add(pluginHook, GBC.eol().insets(0, 1, 1, 1).anchor(G BC.NORTHEAST).weight(epsilon, epsilon));298 bothTables.add(pluginHook, GBC.eol().insets(0, 1, 1, 1).anchor(GridBagConstraints.NORTHEAST).weight(epsilon, epsilon)); 298 299 } 299 300 bothTables.add(selectSth, GBC.eol().fill().insets(10, 10, 10, 10)); 300 bothTables.add(tagTableFilter, GBC.eol().fill(G BC.HORIZONTAL));301 bothTables.add(tagTable.getTableHeader(), GBC.eol().fill(G BC.HORIZONTAL));302 bothTables.add(tagTable, GBC.eol().fill(G BC.BOTH));303 bothTables.add(membershipTable.getTableHeader(), GBC.eol().fill(G BC.HORIZONTAL));304 bothTables.add(membershipTable, GBC.eol().fill(G BC.BOTH));301 bothTables.add(tagTableFilter, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 302 bothTables.add(tagTable.getTableHeader(), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 303 bothTables.add(tagTable, GBC.eol().fill(GridBagConstraints.BOTH)); 304 bothTables.add(membershipTable.getTableHeader(), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 305 bothTables.add(membershipTable, GBC.eol().fill(GridBagConstraints.BOTH)); 305 306 if (presetsVisible && !top) { 306 bothTables.add(presets, GBC.eol().fill(G BC.HORIZONTAL).insets(5, 2, 5, 2));307 bothTables.add(presets, GBC.eol().fill(GridBagConstraints.HORIZONTAL).insets(5, 2, 5, 2)); 307 308 } 308 309 … … 1504 1505 * Clears the row selection when it is filtered away by the row sorter. 1505 1506 */ 1506 private class RemoveHiddenSelection implements ListSelectionListener, RowSorterListener {1507 private final class RemoveHiddenSelection implements ListSelectionListener, RowSorterListener { 1507 1508 1508 1509 void removeHiddenSelection() { … … 1527 1528 } 1528 1529 1529 private class HoverPreviewPropListener implements ValueChangeListener<Boolean> {1530 private final class HoverPreviewPropListener implements ValueChangeListener<Boolean> { 1530 1531 @Override 1531 1532 public void valueChanged(ValueChangeEvent<? extends Boolean> e) { … … 1542 1543 * Otherwise user would need to change selection to see the preference change take effect. 1543 1544 */ 1544 private class HoverPreviewPreferSelectionPropListener implements ValueChangeListener<Boolean> {1545 private final class HoverPreviewPreferSelectionPropListener implements ValueChangeListener<Boolean> { 1545 1546 @Override 1546 1547 public void valueChanged(ValueChangeEvent<? extends Boolean> e) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r19014 r19050 33 33 34 34 import javax.swing.AbstractAction; 35 import javax.swing.Action; 35 36 import javax.swing.BorderFactory; 36 37 import javax.swing.InputMap; … … 48 49 import javax.swing.JToolBar; 49 50 import javax.swing.KeyStroke; 51 import javax.swing.SwingConstants; 50 52 import javax.swing.event.TableModelListener; 51 53 … … 670 672 */ 671 673 LeftButtonToolbar(IRelationEditorActionAccess editorAccess) { 672 setOrientation( JToolBar.VERTICAL);674 setOrientation(SwingConstants.VERTICAL); 673 675 setFloatable(false); 674 676 … … 703 705 704 706 705 InputMap inputMap = editorAccess.getMemberTable().getInputMap( MemberTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);707 InputMap inputMap = editorAccess.getMemberTable().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); 706 708 inputMap.put((KeyStroke) new RemoveAction(editorAccess, "removeSelected") 707 .getValue(A bstractAction.ACCELERATOR_KEY), "removeSelected");709 .getValue(Action.ACCELERATOR_KEY), "removeSelected"); 708 710 inputMap.put((KeyStroke) new MoveUpAction(editorAccess, "moveUp") 709 .getValue(A bstractAction.ACCELERATOR_KEY), "moveUp");711 .getValue(Action.ACCELERATOR_KEY), "moveUp"); 710 712 inputMap.put((KeyStroke) new MoveDownAction(editorAccess, "moveDown") 711 .getValue(A bstractAction.ACCELERATOR_KEY), "moveDown");713 .getValue(Action.ACCELERATOR_KEY), "moveDown"); 712 714 inputMap.put((KeyStroke) new DownloadIncompleteMembersAction( 713 editorAccess, "downloadIncomplete").getValue(A bstractAction.ACCELERATOR_KEY), "downloadIncomplete");715 editorAccess, "downloadIncomplete").getValue(Action.ACCELERATOR_KEY), "downloadIncomplete"); 714 716 } 715 717 } … … 722 724 */ 723 725 protected static JToolBar buildSelectionControlButtonToolbar(IRelationEditorActionAccess editorAccess) { 724 JToolBar tb = new JToolBar( JToolBar.VERTICAL);726 JToolBar tb = new JToolBar(SwingConstants.VERTICAL); 725 727 tb.setFloatable(false); 726 728 … … 849 851 tr("Remove them, clean up relation") 850 852 ); 851 switch (ret) {853 switch (ret) { 852 854 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: 853 855 case JOptionPane.CLOSED_OPTION: … … 928 930 null 929 931 ); 930 switch (ret) {932 switch (ret) { 931 933 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: 932 934 case JOptionPane.YES_OPTION: … … 1036 1038 } 1037 1039 1038 private class RelationEditorActionAccess implements IRelationEditorActionAccess {1040 private final class RelationEditorActionAccess implements IRelationEditorActionAccess { 1039 1041 1040 1042 @Override -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/SetRoleAction.java
r18208 r19050 70 70 options[0] 71 71 ); 72 switch (ret) {72 switch (ret) { 73 73 case JOptionPane.YES_OPTION: 74 74 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorter.java
r19048 r19050 173 173 // Dispatch members to the first adequate sorter 174 174 for (RelationMember m : relationMembers) { 175 varwasAdded = false;175 boolean wasAdded = false; 176 176 for (AdditionalSorter sorter : ADDITIONAL_SORTERS) { 177 177 if (sorter.acceptsMember(relationMembers, m)) { -
trunk/src/org/openstreetmap/josm/gui/download/OSMDownloadSource.java
r18728 r19050 9 9 import java.awt.FlowLayout; 10 10 import java.awt.Font; 11 import java.awt.GridBagConstraints; 11 12 import java.awt.GridBagLayout; 12 13 import java.lang.reflect.InvocationTargetException; … … 218 219 219 220 downloadSourcesPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); 220 add(downloadSourcesPanel, GBC.eol().fill(G BC.HORIZONTAL));221 add(downloadSourcesPanel, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 221 222 updateSources(); 222 223 … … 224 225 JPanel sizeCheckPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); 225 226 sizeCheckPanel.add(sizeCheck); 226 add(sizeCheckPanel, GBC.eol().fill(G BC.HORIZONTAL));227 add(sizeCheckPanel, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 227 228 228 229 setMinimumSize(new Dimension(450, 115)); … … 354 355 } 355 356 356 private static class OsmDataDownloadType implements IDownloadSourceType {357 private static final class OsmDataDownloadType implements IDownloadSourceType { 357 358 static final BooleanProperty IS_ENABLED = new BooleanProperty("download.osm.data", true); 358 359 JCheckBox cbDownloadOsmData; … … 394 395 } 395 396 396 private static class GpsDataDownloadType implements IDownloadSourceType {397 private static final class GpsDataDownloadType implements IDownloadSourceType { 397 398 static final BooleanProperty IS_ENABLED = new BooleanProperty("download.osm.gps", false); 398 399 private JCheckBox cbDownloadGpxData; … … 432 433 } 433 434 434 private static class NotesDataDownloadType implements IDownloadSourceType {435 private static final class NotesDataDownloadType implements IDownloadSourceType { 435 436 static final BooleanProperty IS_ENABLED = new BooleanProperty("download.osm.notes", false); 436 437 private JCheckBox cbDownloadNotes; -
trunk/src/org/openstreetmap/josm/gui/download/PlaceSelection.java
r18805 r19050 7 7 import java.awt.Component; 8 8 import java.awt.Dimension; 9 import java.awt.GridBagConstraints; 9 10 import java.awt.GridBagLayout; 10 11 import java.awt.event.ActionEvent; … … 106 107 107 108 lpanel.add(new JLabel(tr("Choose the server for searching:")), GBC.std(0, 0).weight(0, 0).insets(0, 0, 5, 0)); 108 lpanel.add(serverComboBox, GBC.std(1, 0).fill(G BC.HORIZONTAL));109 lpanel.add(serverComboBox, GBC.std(1, 0).fill(GridBagConstraints.HORIZONTAL)); 109 110 String s = Config.getPref().get("namefinder.server", SERVERS[0].name); 110 111 for (int i = 0; i < SERVERS.length; ++i) { … … 118 119 cbSearchExpression.setToolTipText(tr("Enter a place name to search for")); 119 120 cbSearchExpression.getModel().prefs().load(HISTORY_KEY); 120 lpanel.add(cbSearchExpression, GBC.std(1, 1).fill(G BC.HORIZONTAL));121 122 panel.add(lpanel, GBC.std().fill(G BC.HORIZONTAL).insets(5, 5, 0, 5));121 lpanel.add(cbSearchExpression, GBC.std(1, 1).fill(GridBagConstraints.HORIZONTAL)); 122 123 panel.add(lpanel, GBC.std().fill(GridBagConstraints.HORIZONTAL).insets(5, 5, 0, 5)); 123 124 SearchAction searchAction = new SearchAction(); 124 125 JButton btnSearch = new JButton(searchAction); … … 495 496 return this; 496 497 SearchResult sr = (SearchResult) value; 497 switch (column) {498 switch (column) { 498 499 case 0: 499 500 setText(sr.getName()); -
trunk/src/org/openstreetmap/josm/gui/history/RelationMemberListTableCellRenderer.java
r17733 r19050 57 57 RelationMemberData member = (RelationMemberData) diffItem.value; 58 58 if (member != null) { 59 switch (member.getMemberType()) {59 switch (member.getMemberType()) { 60 60 case NODE: text = tr("Node {0}", member.getMemberId()); break; 61 61 case WAY: text = tr("Way {0}", member.getMemberId()); break; … … 78 78 Item member = (TwoColumnDiff.Item) value; 79 79 Item.DiffItemType type = member.state; 80 switch (column) {80 switch (column) { 81 81 case RelationMemberTableColumnModel.INDEX_COLUMN: 82 82 type = Item.DiffItemType.EMPTY; -
trunk/src/org/openstreetmap/josm/gui/history/TagTableCellRenderer.java
r17904 r19050 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.gui.history; 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 3 5 4 6 import java.awt.Color; … … 13 15 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive; 14 16 import org.openstreetmap.josm.gui.util.GuiHelper; 15 16 import static org.openstreetmap.josm.tools.I18n.tr;17 17 18 18 /** … … 51 51 setBorder(null); 52 52 if (model.hasTag(key)) { 53 switch (column) {53 switch (column) { 54 54 case TagTableColumnModel.COLUMN_KEY: 55 55 // the name column -
trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadTask.java
r17841 r19050 41 41 /** 42 42 * Abstract base class for the task of uploading primitives via OSM API. 43 * 43 * <p> 44 44 * Mainly handles conflicts and certain error situations. 45 45 */ … … 98 98 /** 99 99 * Synchronizes the local state of the dataset with the state on the server. 100 * 100 * <p> 101 101 * Reuses the functionality of {@link UpdateDataAction}. 102 102 * … … 121 121 String myVersion) { 122 122 String lbl; 123 switch (primitiveType) {123 switch (primitiveType) { 124 124 // CHECKSTYLE.OFF: SingleSpaceSeparator 125 125 case NODE: lbl = tr("Synchronize node {0} only", id); break; … … 164 164 "/Concepts/Conflict" 165 165 ); 166 switch (ret) {166 switch (ret) { 167 167 case 0: synchronizePrimitive(primitiveType, id); break; 168 168 case 1: synchronizeDataSet(); break; -
trunk/src/org/openstreetmap/josm/gui/io/ChangesetManagementPanel.java
r18801 r19050 195 195 if (e.getItemSelectable() != cbCloseAfterUpload) 196 196 return; 197 switch (e.getStateChange()) {197 switch (e.getStateChange()) { 198 198 case ItemEvent.SELECTED: 199 199 firePropertyChange(CLOSE_CHANGESET_AFTER_UPLOAD, false, true); -
trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java
r14214 r19050 49 49 /** 50 50 * Dialog box to request username and password from the user. 51 * 51 * <p> 52 52 * The credentials can be for the OSM API (basic authentication), a different 53 53 * host or an HTTP proxy. … … 370 370 } 371 371 372 private static class SelectAllOnFocusHandler extends FocusAdapter {372 private static final class SelectAllOnFocusHandler extends FocusAdapter { 373 373 @Override 374 374 public void focusGained(FocusEvent e) { -
trunk/src/org/openstreetmap/josm/gui/io/CustomConfigurator.java
r18972 r19050 467 467 Element elem = (Element) item; 468 468 469 switch (elementName) {469 switch (elementName) { 470 470 case "var": 471 471 setVar(elem.getAttribute("name"), evalVars(elem.getAttribute("value"))); -
trunk/src/org/openstreetmap/josm/gui/io/OnlineResourceMenu.java
r17041 r19050 77 77 } 78 78 79 private class ToggleMenuListener implements MenuListener {79 private final class ToggleMenuListener implements MenuListener { 80 80 @Override 81 81 public void menuSelected(MenuEvent e) { -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r18996 r19050 37 37 import javax.swing.JScrollPane; 38 38 import javax.swing.ListCellRenderer; 39 import javax.swing.SwingConstants; 39 40 import javax.swing.WindowConstants; 40 41 import javax.swing.event.TableModelEvent; … … 132 133 dialog.getModel().populate(layersWithUnsavedChanges); 133 134 dialog.setVisible(true); 134 switch (dialog.getUserAction()) {135 switch (dialog.getUserAction()) { 135 136 case PROCEED: return true; 136 137 case CANCEL: … … 182 183 183 184 model.addPropertyChangeListener(saveAndProceedAction); 184 pnl.add(saveAndProceedActionButton, GBC.std(0, 0).insets(5, 5, 0, 0).fill(G BC.HORIZONTAL));185 186 pnl.add(new JButton(saveSessionAction), GBC.std(1, 0).insets(5, 5, 5, 0).fill(G BC.HORIZONTAL));185 pnl.add(saveAndProceedActionButton, GBC.std(0, 0).insets(5, 5, 0, 0).fill(GridBagConstraints.HORIZONTAL)); 186 187 pnl.add(new JButton(saveSessionAction), GBC.std(1, 0).insets(5, 5, 5, 0).fill(GridBagConstraints.HORIZONTAL)); 187 188 188 189 model.addPropertyChangeListener(discardAndProceedAction); 189 pnl.add(new JButton(discardAndProceedAction), GBC.std(0, 1).insets(5, 5, 0, 5).fill(G BC.HORIZONTAL));190 191 pnl.add(new JButton(cancelAction), GBC.std(1, 1).insets(5, 5, 5, 5).fill(G BC.HORIZONTAL));190 pnl.add(new JButton(discardAndProceedAction), GBC.std(0, 1).insets(5, 5, 0, 5).fill(GridBagConstraints.HORIZONTAL)); 191 192 pnl.add(new JButton(cancelAction), GBC.std(1, 1).insets(5, 5, 5, 5).fill(GridBagConstraints.HORIZONTAL)); 192 193 193 194 JPanel pnl2 = new JPanel(new BorderLayout()); … … 267 268 gc.weighty = 0.0; 268 269 add(lblMessage, gc); 269 lblMessage.setHorizontalAlignment( JLabel.LEADING);270 lblMessage.setHorizontalAlignment(SwingConstants.LEADING); 270 271 lstLayers.setCellRenderer(new LayerCellRenderer()); 271 272 gc.gridx = 0; … … 377 378 378 379 public void cancel() { 379 switch (model.getMode()) {380 switch (model.getMode()) { 380 381 case EDITING_DATA: cancelWhenInEditingModel(); 381 382 break; … … 426 427 if (evt.getPropertyName().equals(SaveLayersModel.MODE_PROP)) { 427 428 Mode mode = (Mode) evt.getNewValue(); 428 switch (mode) {429 switch (mode) { 429 430 case EDITING_DATA: setEnabled(true); 430 431 break; … … 523 524 if (evt.getPropertyName().equals(SaveLayersModel.MODE_PROP)) { 524 525 SaveLayersModel.Mode mode = (SaveLayersModel.Mode) evt.getNewValue(); 525 switch (mode) {526 switch (mode) { 526 527 case EDITING_DATA: setEnabled(true); 527 528 break; -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersModel.java
r18972 r19050 103 103 public void setValueAt(Object value, int row, int column) { 104 104 final SaveLayerInfo info = this.layerInfo.get(row); 105 switch (column) {105 switch (column) { 106 106 case columnFilename: 107 107 info.setFile((File) value); -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTable.java
r12452 r19050 26 26 if (evt.getPropertyName().equals(SaveLayersModel.MODE_PROP)) { 27 27 Mode mode = (Mode) evt.getNewValue(); 28 switch (mode) {28 switch (mode) { 29 29 case EDITING_DATA: setEnabled(true); 30 30 break; -
trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java
r19048 r19050 170 170 switch (strategy.getPolicy()) { 171 171 case AUTOMATICALLY_OPEN_NEW_CHANGESETS: 172 final varnewChangeSet = new Changeset();172 final Changeset newChangeSet = new Changeset(); 173 173 newChangeSet.setKeys(changeset.getKeys()); 174 174 closeChangeset(); … … 372 372 if (uploadCanceled) return; 373 373 if (lastException == null) { 374 final varpanel = new HtmlPanel(374 final HtmlPanel panel = new HtmlPanel( 375 375 "<h3><a href=\"" + Config.getUrls().getBaseBrowseUrl() + "/changeset/" + changeset.getId() + "\">" 376 376 + tr("Upload successful!") + "</a></h3>"); -
trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java
r18283 r19050 212 212 UploadStrategySpecification spec = new UploadStrategySpecification(); 213 213 if (strategy != null) { 214 switch (strategy) {214 switch (strategy) { 215 215 case CHUNKED_DATASET_STRATEGY: 216 216 spec.setStrategy(strategy).setChunkSize(getChunkSize()); … … 389 389 if (strategy == null) 390 390 return; 391 switch (strategy) {391 switch (strategy) { 392 392 case CHUNKED_DATASET_STRATEGY: 393 393 tfChunkSize.setEnabled(true); -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r18926 r19050 1481 1481 * Data container to hold information about a {@code TileSet} class. 1482 1482 */ 1483 private static class TileSetInfo {1483 private static final class TileSetInfo { 1484 1484 boolean hasVisibleTiles; 1485 1485 boolean hasOverzoomedTiles; … … 2026 2026 } 2027 2027 2028 private class TileSourcePainter extends CompatibilityModeLayerPainter {2028 private final class TileSourcePainter extends CompatibilityModeLayerPainter { 2029 2029 /** The memory handle that will hold our tile source. */ 2030 2030 private MemoryHandle<?> memory; … … 2072 2072 } 2073 2073 2074 pr otectedlong getEstimatedCacheSize() {2074 private long getEstimatedCacheSize() { 2075 2075 return 4L * tileSource.getTileSize() * tileSource.getTileSize() * estimateTileCacheSize(); 2076 2076 } -
trunk/src/org/openstreetmap/josm/gui/layer/ImageryLayer.java
r18972 r19050 161 161 */ 162 162 public static ImageryLayer create(ImageryInfo info) { 163 switch (info.getImageryType()) {163 switch (info.getImageryType()) { 164 164 case WMS: 165 165 case WMS_ENDPOINT: -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r19048 r19050 67 67 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 68 68 import org.openstreetmap.josm.gui.layer.geoimage.AdjustTimezoneAndOffsetDialog.AdjustListener; 69 import org.openstreetmap.josm.gui.layer.geoimage.SynchronizeTimeFromPhotoDialog.TimeZoneItem; 69 70 import org.openstreetmap.josm.gui.layer.gpx.GpxDataHelper; 70 71 import org.openstreetmap.josm.gui.widgets.JosmComboBox; … … 172 173 // Search whether an other layer has yet defined some bounding box. 173 174 // If none, we'll zoom to the bounding box of the layer with the photos. 174 varboundingBoxedLayerFound = false;175 boolean boundingBoxedLayerFound = false; 175 176 for (Layer l: MainApplication.getLayerManager().getLayers()) { 176 177 if (l != yLayer) { 177 final var bbox = new BoundingXYVisitor();178 BoundingXYVisitor bbox = new BoundingXYVisitor(); 178 179 l.visitBoundingBox(bbox); 179 180 if (bbox.getBounds() != null) { … … 184 185 } 185 186 if (!boundingBoxedLayerFound) { 186 final var bbox = new BoundingXYVisitor();187 BoundingXYVisitor bbox = new BoundingXYVisitor(); 187 188 yLayer.visitBoundingBox(bbox); 188 189 MainApplication.getMap().mapView.zoomTo(bbox); … … 264 265 @Override 265 266 public void actionPerformed(ActionEvent e) { 266 final varsel = GpxDataHelper.chooseGpxDataFile();267 File sel = GpxDataHelper.chooseGpxDataFile(); 267 268 if (sel != null) { 268 269 try { 269 270 outerPanel.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); 270 271 removeDuplicates(sel); 271 final vardata = GpxDataHelper.loadGpxData(sel);272 GpxData data = GpxDataHelper.loadGpxData(sel); 272 273 if (data != null) { 273 final var elem = new GpxDataWrapper(sel.getName(), data, sel);274 GpxDataWrapper elem = new GpxDataWrapper(sel.getName(), data, sel); 274 275 gpxModel.addElement(elem); 275 276 gpxModel.setSelectedItem(elem); … … 299 300 @Override 300 301 public void actionPerformed(ActionEvent e) { 301 final vared = new AdvancedCorrelationSettingsDialog(MainApplication.getMainFrame(), forceTags);302 AdvancedCorrelationSettingsDialog ed = new AdvancedCorrelationSettingsDialog(MainApplication.getMainFrame(), forceTags); 302 303 if (ed.showDialog().getValue() == 1) { 303 304 forceTags = ed.isForceTaggingSelected(); // This setting is not supposed to be saved permanently … … 320 321 @Override 321 322 public void actionPerformed(ActionEvent e) { 322 varisOk = false;323 boolean isOk = false; 323 324 while (!isOk) { 324 final var ed = new SynchronizeTimeFromPhotoDialog(MainApplication.getMainFrame(), yLayer.getImageData().getImages()); 325 SynchronizeTimeFromPhotoDialog ed = new SynchronizeTimeFromPhotoDialog( 326 MainApplication.getMainFrame(), yLayer.getImageData().getImages()); 325 327 int answer = ed.showDialog().getValue(); 326 328 if (answer != 1) … … 338 340 } 339 341 340 final varselectedTz = ed.getTimeZoneItem();342 TimeZoneItem selectedTz = ed.getTimeZoneItem(); 341 343 342 344 Config.getPref().put("geoimage.timezoneid", selectedTz.getID()); … … 355 357 @Override 356 358 public void layerAdded(LayerAddEvent e) { 357 final var layer = e.getAddedLayer();359 Layer layer = e.getAddedLayer(); 358 360 if (layer instanceof GpxDataContainer) { 359 final vargpx = ((GpxDataContainer) layer).getGpxData();360 final varfile = gpx.storageFile;361 GpxData gpx = ((GpxDataContainer) layer).getGpxData(); 362 File file = gpx.storageFile; 361 363 removeDuplicates(file); 362 final var gdw = new GpxDataWrapper(layer.getName(), gpx, file);364 GpxDataWrapper gdw = new GpxDataWrapper(layer.getName(), gpx, file); 363 365 layer.addPropertyChangeListener(new GpxLayerRenamedListener(gdw)); 364 366 gpxModel.addElement(gdw); … … 374 376 @Override 375 377 public void layerRemoving(LayerRemoveEvent e) { 376 final var layer = e.getRemovedLayer();378 Layer layer = e.getRemovedLayer(); 377 379 if (layer instanceof GpxDataContainer) { 378 final varremovedGpxData = ((GpxDataContainer) layer).getGpxData();380 GpxData removedGpxData = ((GpxDataContainer) layer).getGpxData(); 379 381 for (int i = gpxModel.getSize() - 1; i >= 0; i--) { 380 382 GpxData data = gpxModel.getElementAt(i).data; … … 426 428 for (AbstractModifiableLayer cur : MainApplication.getLayerManager().getLayersOfType(AbstractModifiableLayer.class)) { 427 429 if (cur instanceof GpxDataContainer) { 428 final vardata = ((GpxDataContainer) cur).getGpxData();429 final var gdw = new GpxDataWrapper(cur.getName(), data, data.storageFile);430 GpxData data = ((GpxDataContainer) cur).getGpxData(); 431 GpxDataWrapper gdw = new GpxDataWrapper(cur.getName(), data, data.storageFile); 430 432 cur.addPropertyChangeListener(new GpxLayerRenamedListener(gdw)); 431 433 gpxModel.addElement(gdw); … … 469 471 @Override 470 472 public void actionPerformed(ActionEvent ae) { 471 final var nogdw = new NoGpxDataWrapper();473 NoGpxDataWrapper nogdw = new NoGpxDataWrapper(); 472 474 if (gpxModel == null) { 473 475 constructGpxModel(nogdw); 474 476 } 475 477 476 final varpanelCb = new JPanel();478 JPanel panelCb = new JPanel(); 477 479 478 480 panelCb.add(new JLabel(tr("GPX track: "))); … … 483 485 panelCb.add(cbGpx); 484 486 485 final varbuttonOpen = new JButton(tr("Open another GPX trace"));487 JButton buttonOpen = new JButton(tr("Open another GPX trace")); 486 488 buttonOpen.addActionListener(new LoadGpxDataActionListener()); 487 489 panelCb.add(buttonOpen); … … 491 493 panelCb.add(buttonSupport); 492 494 493 final varpanelTf = new JPanel(new GridBagLayout());495 JPanel panelTf = new JPanel(new GridBagLayout()); 494 496 495 497 timezone = loadTimezone(); … … 503 505 tfOffset.setText(delta.formatOffset()); 504 506 505 final varbuttonViewGpsPhoto = new JButton(tr("<html>Use photo of an accurate clock,<br>e.g. GPS receiver display</html>"));507 JButton buttonViewGpsPhoto = new JButton(tr("<html>Use photo of an accurate clock,<br>e.g. GPS receiver display</html>")); 506 508 buttonViewGpsPhoto.setIcon(ImageProvider.get("clock")); 507 509 buttonViewGpsPhoto.addActionListener(new SetOffsetActionListener()); 508 510 509 final varbuttonAutoGuess = new JButton(tr("Auto-Guess"));511 JButton buttonAutoGuess = new JButton(tr("Auto-Guess")); 510 512 buttonAutoGuess.setToolTipText(tr("Matches first photo with first gpx point")); 511 513 buttonAutoGuess.addActionListener(new AutoGuessActionListener()); 512 514 513 final varbuttonAdjust = new JButton(tr("Manual adjust"));515 JButton buttonAdjust = new JButton(tr("Manual adjust")); 514 516 buttonAdjust.addActionListener(new AdjustActionListener()); 515 517 516 final varbuttonAdvanced = new JButton(tr("Advanced settings..."));518 JButton buttonAdvanced = new JButton(tr("Advanced settings...")); 517 519 buttonAdvanced.addActionListener(new AdvancedSettingsActionListener()); 518 520 519 final varlabelPosition = new JLabel(tr("Override position for: "));521 JLabel labelPosition = new JLabel(tr("Override position for: ")); 520 522 521 523 int numAll = yLayer.getSortedImgList(true, true).size(); … … 535 537 cbShowThumbs.setEnabled(!yLayer.thumbsLoaded); 536 538 537 vary = 0;538 vargbc = GBC.eol();539 int y = 0; 540 GBC gbc = GBC.eol(); 539 541 gbc.gridx = 0; 540 542 gbc.gridy = y++; … … 625 627 expertChanged(ExpertToggleAction.isExpert()); 626 628 627 final varstatusBar = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));629 final JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); 628 630 statusBar.setBorder(BorderFactory.createLoweredBevelBorder()); 629 631 statusBarText = new JLabel(" "); … … 631 633 statusBar.add(statusBarText); 632 634 633 final var repaintTheMap = new RepaintTheMapListener(yLayer);635 RepaintTheMapListener repaintTheMap = new RepaintTheMapListener(yLayer); 634 636 pDirectionPosition.addFocusListenerOnComponent(repaintTheMap); 635 637 tfTimezone.addFocusListener(repaintTheMap); … … 811 813 public void actionPerformed(ActionEvent e) { 812 814 813 final varoffset = GpxTimeOffset.milliseconds(815 final GpxTimeOffset offset = GpxTimeOffset.milliseconds( 814 816 delta.getMilliseconds() + Math.round(timezone.getHours() * TimeUnit.HOURS.toMillis(1))); 815 817 final int dayOffset = offset.getDayOffset(); -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageDisplay.java
r18947 r19050 119 119 private boolean destroyed; 120 120 121 private class UpdateImageThread extends Thread {121 private final class UpdateImageThread extends Thread { 122 122 private boolean restart; 123 123 … … 146 146 if (e == null || 147 147 e.getKey().equals(AGPIFO_STYLE.getKey())) { 148 dragButton = AGPIFO_STYLE.get() ? 1 : 3;148 dragButton = Boolean.TRUE.equals(AGPIFO_STYLE.get()) ? 1 : 3; 149 149 zoomButton = dragButton == 1 ? 3 : 1; 150 150 } … … 320 320 } 321 321 322 private class ImgDisplayMouseListener extends MouseAdapter {322 private final class ImgDisplayMouseListener extends MouseAdapter { 323 323 324 324 private MouseEvent lastMouseEvent; … … 434 434 return; 435 435 436 if ( ZOOM_ON_CLICK.get()) {436 if (Boolean.TRUE.equals(ZOOM_ON_CLICK.get())) { 437 437 // click notions are less coherent than wheel, refresh mousePointInImg on each click 438 438 lastMouseEvent = null; -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/RemoteEntry.java
r19048 r19050 296 296 @Override 297 297 public InputStream getInputStream() throws IOException { 298 final varu = getImageURI();298 final URI u = getImageURI(); 299 299 if (u.getScheme().contains("file")) { 300 300 return Files.newInputStream(Paths.get(u)); 301 301 } 302 final varclient = HttpClient.create(u.toURL());302 final HttpClient client = HttpClient.create(u.toURL()); 303 303 InputStream actual = client.connect().getContent(); 304 304 return new BufferedInputStream(actual) { -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
r18801 r19050 60 60 } 61 61 62 private static class Markers {62 private static final class Markers { 63 63 public boolean timedMarkersOmitted; 64 64 public boolean untimedMarkersOmitted; -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r18871 r19050 715 715 @Override 716 716 public String toString() { 717 return "LinkSelector{conditions=" + getConditions() + '}';717 return "LinkSelector{conditions=" + super.getConditions() + '}'; 718 718 } 719 719 } … … 761 761 */ 762 762 private static String checkBase(String base) { 763 switch (base) {763 switch (base) { 764 764 case "*": return BASE_ANY; 765 765 case "node": return BASE_NODE; … … 844 844 return base 845 845 + (Range.ZERO_TO_INFINITY.equals(range) ? "" : range) 846 + getConditions().stream().map(String::valueOf).collect(Collectors.joining(""))846 + super.getConditions().stream().map(String::valueOf).collect(Collectors.joining("")) 847 847 + (subpart != null && subpart != Subpart.DEFAULT_SUBPART ? ("::" + subpart) : ""); 848 848 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LabelCompositionStrategy.java
r19048 r19050 167 167 /* Is joining an array really that complicated in Java? */ 168 168 private static String[] getDefaultNameTags() { 169 final var tags = new ArrayList< String>(Arrays.asList(LanguageInfo.getOSMLocaleCodes("name:")));169 final var tags = new ArrayList<>(Arrays.asList(LanguageInfo.getOSMLocaleCodes("name:"))); 170 170 tags.addAll(Arrays.asList("name", 171 171 "int_name", … … 249 249 250 250 private String getPrimitiveName(IPrimitive n) { 251 final var name = new StringBuilder();251 StringBuilder name = new StringBuilder(); 252 252 if (!n.hasKeys()) return null; 253 253 nameTags.stream().map(n::get).filter(Objects::nonNull).findFirst() -
trunk/src/org/openstreetmap/josm/gui/oauth/AuthorizationProcedure.java
r17600 r19050 36 36 */ 37 37 public String getText() { 38 switch (this) {38 switch (this) { 39 39 case FULLY_AUTOMATIC: 40 40 return tr("Fully automatic"); … … 52 52 */ 53 53 public String getDescription() { 54 switch (this) {54 switch (this) { 55 55 case FULLY_AUTOMATIC: 56 56 return tr( -
trunk/src/org/openstreetmap/josm/gui/oauth/OAuthAuthorizationWizard.java
r19008 r19050 9 9 import java.awt.FlowLayout; 10 10 import java.awt.Font; 11 import java.awt.GridBagConstraints; 11 12 import java.awt.GridBagLayout; 12 13 import java.awt.event.ActionEvent; … … 170 171 ); 171 172 pnlMessage.enableClickableHyperlinks(); 172 pnl.add(pnlMessage, GBC.eol().fill(G BC.HORIZONTAL));173 pnl.add(pnlMessage, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 173 174 174 175 // the authorisation procedure … … 201 202 */ 202 203 protected void refreshAuthorisationProcedurePanel() { 203 switch (procedure) {204 switch (procedure) { 204 205 case FULLY_AUTOMATIC: 205 206 spAuthorisationProcedureUI.getViewport().setView(pnlFullyAutomaticAuthorisationUI); … … 290 291 291 292 protected AbstractAuthorizationUI getCurrentAuthorisationUI() { 292 switch (procedure) {293 switch (procedure) { 293 294 case FULLY_AUTOMATIC: return pnlFullyAutomaticAuthorisationUI; 294 295 case MANUALLY: return pnlManualAuthorisationUI; -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r18972 r19050 409 409 } 410 410 411 private static class ActionParametersTableModel extends AbstractTableModel {411 private static final class ActionParametersTableModel extends AbstractTableModel { 412 412 413 413 private transient ActionDefinition currentAction = ActionDefinition.getSeparator(); … … 494 494 } 495 495 496 private class ToolbarPopupMenu extends JPopupMenu {496 private final class ToolbarPopupMenu extends JPopupMenu { 497 497 private transient ActionDefinition act; 498 498 … … 750 750 } 751 751 752 private class ActionDefinitionModel extends DefaultListModel<ActionDefinition> implements ReorderableTableModel<ActionDefinition> {752 private final class ActionDefinitionModel extends DefaultListModel<ActionDefinition> implements ReorderableTableModel<ActionDefinition> { 753 753 @Override 754 754 public ListSelectionModel getSelectionModel() { -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/AbstractTableListEditor.java
r18801 r19050 18 18 import javax.swing.JTable; 19 19 import javax.swing.JToolBar; 20 import javax.swing.SwingConstants; 20 21 import javax.swing.event.ListSelectionEvent; 21 22 import javax.swing.event.ListSelectionListener; … … 103 104 } 104 105 105 private class EntryListener implements ListSelectionListener {106 private final class EntryListener implements ListSelectionListener { 106 107 @Override 107 108 public void valueChanged(ListSelectionEvent e) { … … 132 133 left.add(scroll, GBC.eol().fill()); 133 134 134 JToolBar sideButtonTB = new JToolBar( JToolBar.HORIZONTAL);135 JToolBar sideButtonTB = new JToolBar(SwingConstants.HORIZONTAL); 135 136 sideButtonTB.setBorderPainted(false); 136 137 sideButtonTB.setOpaque(false); -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/ListListEditor.java
r12881 r19050 50 50 } 51 51 52 private class EntryListModel extends AbstractEntryListModel {52 private final class EntryListModel extends AbstractEntryListModel { 53 53 54 54 @Override … … 64 64 @Override 65 65 public void add() { 66 data.add(new ArrayList< String>());66 data.add(new ArrayList<>()); 67 67 fireIntervalAdded(this, getSize() - 1, getSize() - 1); 68 68 } … … 75 75 } 76 76 77 private class ListTableModel extends AbstractTableModel {77 private final class ListTableModel extends AbstractTableModel { 78 78 79 79 private List<String> data() { -
trunk/src/org/openstreetmap/josm/gui/preferences/advanced/MapListEditor.java
r18224 r19050 78 78 } 79 79 80 private class EntryListModel extends AbstractEntryListModel {80 private final class EntryListModel extends AbstractEntryListModel { 81 81 82 82 @Override … … 92 92 @Override 93 93 public void add() { 94 dataKeys.add(new ArrayList< String>());95 dataValues.add(new ArrayList< String>());94 dataKeys.add(new ArrayList<>()); 95 dataValues.add(new ArrayList<>()); 96 96 dataLabels.add(""); 97 97 fireIntervalAdded(this, getSize() - 1, getSize() - 1); … … 107 107 } 108 108 109 private class MapTableModel extends AbstractTableModel {109 private final class MapTableModel extends AbstractTableModel { 110 110 111 111 private List<List<String>> data() { 112 return entryIdx == null ? Collections. <List<String>>emptyList() : Arrays.asList(dataKeys.get(entryIdx), dataValues.get(entryIdx));112 return entryIdx == null ? Collections.emptyList() : Arrays.asList(dataKeys.get(entryIdx), dataValues.get(entryIdx)); 113 113 } 114 114 -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/WMSLayerTree.java
r17602 r19050 107 107 } 108 108 109 private static class LayerTreeCellRenderer extends DefaultTreeCellRenderer {109 private static final class LayerTreeCellRenderer extends DefaultTreeCellRenderer { 110 110 @Override 111 111 public Component getTreeCellRendererComponent(JTree tree, Object value, … … 124 124 } 125 125 126 private class WMSTreeSelectionListener implements TreeSelectionListener {126 private final class WMSTreeSelectionListener implements TreeSelectionListener { 127 127 128 128 @Override -
trunk/src/org/openstreetmap/josm/gui/preferences/projection/CodeSelectionPanel.java
r17768 r19050 5 5 6 6 import java.awt.Dimension; 7 import java.awt.GridBagConstraints; 7 8 import java.awt.GridBagLayout; 8 9 import java.awt.event.ActionListener; … … 60 61 * List model for the filtered view on the list of all codes. 61 62 */ 62 private class ProjectionCodeModel extends AbstractTableModel {63 private final class ProjectionCodeModel extends AbstractTableModel { 63 64 @Override 64 65 public int getRowCount() { … … 105 106 106 107 this.setLayout(new GridBagLayout()); 107 this.add(filter, GBC.eol().fill(G BC.HORIZONTAL).weight(1.0, 0.0));108 this.add(scroll, GBC.eol().fill(G BC.HORIZONTAL));108 this.add(filter, GBC.eol().fill(GridBagConstraints.HORIZONTAL).weight(1.0, 0.0)); 109 this.add(scroll, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 109 110 } 110 111 -
trunk/src/org/openstreetmap/josm/gui/preferences/server/OsmApiUrlInputPanel.java
r18173 r19050 5 5 6 6 import java.awt.Font; 7 import java.awt.GridBagConstraints; 7 8 import java.awt.GridBagLayout; 8 9 import java.awt.event.ActionEvent; … … 83 84 84 85 // the checkbox for the default UL 85 add(buildDefaultServerUrlPanel(), GBC.eop().fill(G BC.HORIZONTAL));86 add(buildDefaultServerUrlPanel(), GBC.eop().fill(GridBagConstraints.HORIZONTAL)); 86 87 87 88 // the input field for the URL 88 89 add(lblApiUrl, GBC.std().insets(0, 0, 3, 0)); 89 add(tfOsmServerUrl, GBC.std().fill(G BC.HORIZONTAL).insets(0, 0, 3, 0));90 add(tfOsmServerUrl, GBC.std().fill(GridBagConstraints.HORIZONTAL).insets(0, 0, 3, 0)); 90 91 lblApiUrl.setLabelFor(tfOsmServerUrl); 91 92 SelectAllOnFocusGainedDecorator.decorate(tfOsmServerUrl.getEditorComponent()); … … 257 258 @Override 258 259 public void itemStateChanged(ItemEvent e) { 259 switch (e.getStateChange()) {260 switch (e.getStateChange()) { 260 261 case ItemEvent.SELECTED: 261 262 setApiUrlInputEnabled(false); -
trunk/src/org/openstreetmap/josm/gui/progress/AbstractProgressMonitor.java
r18365 r19050 12 12 public abstract class AbstractProgressMonitor implements ProgressMonitor { 13 13 14 private static class Request {14 private static final class Request { 15 15 private AbstractProgressMonitor originator; 16 16 private int childTicks; -
trunk/src/org/openstreetmap/josm/gui/tagging/TagCellRenderer.java
r17595 r19050 98 98 } 99 99 100 switch (vColIndex) {100 switch (vColIndex) { 101 101 case 0: renderTagName((TagModel) value); break; 102 102 case 1: renderTagValue((TagModel) value); break; -
trunk/src/org/openstreetmap/josm/gui/tagging/TagEditorModel.java
r18801 r19050 60 60 * Creates a new tag editor model. Internally allocates two selection models 61 61 * for row selection and column selection. 62 * 62 * <p> 63 63 * To create a {@link javax.swing.JTable} with this model: 64 64 * <pre> … … 157 157 TagModel tag = get(row); 158 158 if (tag != null) { 159 switch (col) {159 switch (col) { 160 160 case 0: 161 161 updateTagName(tag, (String) value); … … 219 219 /** 220 220 * adds a tag given by a name/value pair to the tag editor model. 221 * 221 * <p> 222 222 * If there is no tag with name <code>name</code> yet, a new {@link TagModel} is created 223 223 * and append to this model. 224 * 224 * <p> 225 225 * If there is a tag with name <code>name</code>, <code>value</code> is merged to the list 226 226 * of values for this tag. -
trunk/src/org/openstreetmap/josm/gui/tagging/TagTable.java
r18283 r19050 9 9 import java.awt.Window; 10 10 import java.awt.event.ActionEvent; 11 import java.awt.event.InputEvent; 11 12 import java.awt.event.KeyEvent; 12 13 import java.beans.PropertyChangeEvent; … … 134 135 * Action to be run when the user invokes a delete action on the table, for 135 136 * instance by pressing DEL. 136 * 137 * <p> 137 138 * Depending on the shape on the current selection the action deletes individual 138 139 * values or entire tags from the model. 139 * 140 * <p> 140 141 * If the current selection consists of cells in the second column only, the keys of 141 142 * the selected tags are set to the empty string. 142 * 143 * <p> 143 144 * If the current selection consists of cell in the third column only, the values of the 144 145 * selected tags are set to the empty string. 145 * 146 * <p> 146 147 * If the current selection consists of cells in the second and the third column, 147 148 * the selected tags are removed from the model. 148 * 149 * <p> 149 150 * This action listens to the table selection. It becomes enabled when the selection 150 151 * is non-empty, otherwise it is disabled. 151 *152 *153 152 */ 154 153 class DeleteAction extends AbstractAction implements ListSelectionListener { … … 190 189 if (!isEnabled()) 191 190 return; 192 switch (getSelectedColumnCount()) {191 switch (getSelectedColumnCount()) { 193 192 case 1: 194 193 if (getSelectedColumn() == 0) { … … 351 350 addAction = new AddAction(); 352 351 getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) 353 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, KeyEvent.CTRL_DOWN_MASK), "addTag");352 .put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, InputEvent.CTRL_DOWN_MASK), "addTag"); 354 353 getActionMap().put("addTag", addAction); 355 354 … … 566 565 * This is a custom implementation of the CellEditorRemover used in JTable 567 566 * to handle the client property <code>terminateEditOnFocusLost</code>. 568 * 567 * <p> 569 568 * This implementation also checks whether focus is transferred to one of a list 570 569 * of dedicated components, see {@link TagTable#doNotStopCellEditingWhenFocused}. -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompEvent.java
r18801 r19050 80 80 public String paramString() { 81 81 String typeStr; 82 switch (id) {82 switch (id) { 83 83 case AUTOCOMP_BEFORE: 84 84 typeStr = "AUTOCOMP_BEFORE"; -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetMenu.java
r18871 r19050 38 38 public JMenu menu; // set by TaggingPresets 39 39 40 private static class PresetTextComparator implements Comparator<JMenuItem>, Serializable {40 private static final class PresetTextComparator implements Comparator<JMenuItem>, Serializable { 41 41 private static final long serialVersionUID = 1L; 42 42 @Override -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetSelector.java
r18824 r19050 75 75 private final transient PresetClassifications classifications = new PresetClassifications(); 76 76 77 private static class ResultListCellRenderer implements ListCellRenderer<TaggingPreset> {77 private static final class ResultListCellRenderer implements ListCellRenderer<TaggingPreset> { 78 78 private final DefaultListCellRenderer def = new DefaultListCellRenderer(); 79 79 @Override -
trunk/src/org/openstreetmap/josm/gui/util/AdjustmentSynchronizer.java
r10611 r19050 59 59 @Override 60 60 public void adjustmentValueChanged(AdjustmentEvent e) { 61 if ( !enabledMap.get(e.getAdjustable()))61 if (Boolean.FALSE.equals(enabledMap.get(e.getAdjustable()))) 62 62 return; 63 63 for (Adjustable a : synchronizedAdjustables) { … … 123 123 // 124 124 view.addItemListener(e -> { 125 switch (e.getStateChange()) {125 switch (e.getStateChange()) { 126 126 case ItemEvent.SELECTED: 127 127 if (!isParticipatingInSynchronizedScrolling(adjustable)) { -
trunk/src/org/openstreetmap/josm/gui/util/MultikeyActionsHandler.java
r14248 r19050 111 111 } 112 112 113 private class MyKeyEventDispatcher implements KeyEventDispatcher {113 private final class MyKeyEventDispatcher implements KeyEventDispatcher { 114 114 @Override 115 115 public boolean dispatchKeyEvent(KeyEvent e) { -
trunk/src/org/openstreetmap/josm/gui/widgets/JosmTextField.java
r19048 r19050 5 5 import java.awt.ComponentOrientation; 6 6 import java.awt.Font; 7 import java.awt.FontMetrics; 7 8 import java.awt.Graphics; 8 9 import java.awt.Graphics2D; … … 18 19 19 20 import javax.swing.Icon; 21 import javax.swing.JTextField; 22 import javax.swing.RepaintManager; 20 23 import javax.swing.JMenuItem; 21 24 import javax.swing.JPopupMenu; 22 import javax.swing.JTextField;23 import javax.swing.RepaintManager;24 25 import javax.swing.UIManager; 25 26 import javax.swing.text.BadLocationException; … … 254 255 */ 255 256 public static Color getHintTextColor() { 256 var color = UIManager.getColor("TextField[Disabled].textForeground"); // Nimbus?257 Color color = UIManager.getColor("TextField[Disabled].textForeground"); // Nimbus? 257 258 if (color == null) 258 259 color = UIManager.getColor("TextField.inactiveForeground"); … … 305 306 g.drawString(getHint(), x, getBaseline(getWidth(), getHeight())); 306 307 } else { 307 final varmetrics = g.getFontMetrics(g.getFont());308 FontMetrics metrics = g.getFontMetrics(g.getFont()); 308 309 int dx = metrics.stringWidth(getHint()); 309 310 g.drawString(getHint(), x - dx, getBaseline(getWidth(), getHeight())); -
trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitPane.java
r12445 r19050 154 154 } 155 155 156 private class DefaultDividerPainter implements DividerPainter {156 private final class DefaultDividerPainter implements DividerPainter { 157 157 @Override 158 158 public void paint(Graphics g, Divider divider) { … … 344 344 } 345 345 346 private class InputHandler extends MouseInputAdapter implements KeyListener {346 private final class InputHandler extends MouseInputAdapter implements KeyListener { 347 347 348 348 @Override -
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r17787 r19050 243 243 */ 244 244 public byte[] getByteContent() throws IOException { 245 return Utils.readBytesFromStream(getInputStream());245 return getInputStream().readAllBytes(); 246 246 } 247 247 -
trunk/src/org/openstreetmap/josm/io/ChangesetQuery.java
r18801 r19050 500 500 for (Entry<String, String> entry: queryParams.entrySet()) { 501 501 String k = entry.getKey(); 502 switch (k) {502 switch (k) { 503 503 case "uid": 504 504 if (queryParams.containsKey("display_name")) … … 521 521 case "time": 522 522 Instant[] dates = parseTime(entry.getValue()); 523 switch (dates.length) {523 switch (dates.length) { 524 524 case 1: 525 525 csQuery.closedAfter(dates[0]); -
trunk/src/org/openstreetmap/josm/io/ChangesetUpdater.java
r17717 r19050 35 35 private static volatile ScheduledFuture<?> task; 36 36 37 private static class Worker implements Runnable {37 private static final class Worker implements Runnable { 38 38 39 39 private long lastTimeInMillis; -
trunk/src/org/openstreetmap/josm/io/DiffResultProcessor.java
r18801 r19050 167 167 } 168 168 169 private class Parser extends DefaultHandler {169 private final class Parser extends DefaultHandler { 170 170 private Locator locator; 171 171 … … 175 175 } 176 176 177 protectedvoid throwException(String msg) throws XmlParsingException {177 void throwException(String msg) throws XmlParsingException { 178 178 throw new XmlParsingException(msg).rememberLocation(locator); 179 179 } -
trunk/src/org/openstreetmap/josm/io/FileWatcher.java
r17526 r19050 35 35 private final Map<Path, SourceEntry> sourceMap = new HashMap<>(); 36 36 37 private static class InstanceHolder {37 private static final class InstanceHolder { 38 38 static final FileWatcher INSTANCE = new FileWatcher(); 39 39 } -
trunk/src/org/openstreetmap/josm/io/GpxParser.java
r19049 r19050 142 142 public void startElement(String namespaceURI, String localName, String qName, Attributes attributes) throws SAXException { 143 143 elements.push(new String[] {namespaceURI, localName, qName}); 144 switch (currentState) {144 switch (currentState) { 145 145 case INIT: 146 146 startElementInit(attributes); -
trunk/src/org/openstreetmap/josm/io/GpxWriter.java
r18399 r19050 388 388 private void wayPoint(WayPoint pnt, int mode) { 389 389 String type; 390 switch (mode) {390 switch (mode) { 391 391 case WAY_POINT: 392 392 type = "wpt"; -
trunk/src/org/openstreetmap/josm/io/MessageNotifier.java
r18991 r19050 70 70 private static volatile ScheduledFuture<?> task; 71 71 72 private static class Worker implements Runnable {72 private static final class Worker implements Runnable { 73 73 74 74 private int lastUnreadCount; -
trunk/src/org/openstreetmap/josm/io/MultiFetchServerObjectReader.java
r18821 r19050 135 135 public void append(PrimitiveId id) { 136 136 if (id.isNew()) return; 137 switch (id.getType()) {137 switch (id.getType()) { 138 138 case NODE: nodes.add(id.getUniqueId()); break; 139 139 case WAY: ways.add(id.getUniqueId()); break; -
trunk/src/org/openstreetmap/josm/io/NameFinder.java
r16643 r19050 238 238 * Structure of xml described here: http://wiki.openstreetmap.org/index.php/Name_finder 239 239 */ 240 private static class NameFinderResultParser extends DefaultHandler {240 private static final class NameFinderResultParser extends DefaultHandler { 241 241 private SearchResult currentResult; 242 242 private StringBuilder description; -
trunk/src/org/openstreetmap/josm/io/NoteReader.java
r19048 r19050 82 82 notes = new ArrayList<>(10_000); 83 83 return; 84 default: // Keep going 84 85 } 85 86 … … 169 170 case "comment": 170 171 break; 172 default: // Keep going (return) 171 173 } 172 174 } … … 179 181 180 182 static LatLon parseLatLon(UnaryOperator<String> attrs) { 181 final varlat = Double.parseDouble(attrs.apply("lat"));182 final varlon = Double.parseDouble(attrs.apply("lon"));183 final double lat = Double.parseDouble(attrs.apply("lat")); 184 final double lon = Double.parseDouble(attrs.apply("lon")); 183 185 return new LatLon(lat, lon); 184 186 } … … 197 199 198 200 static Note parseNoteFull(UnaryOperator<String> attrs) { 199 final varnote = parseNoteBasic(attrs);201 final Note note = parseNoteBasic(attrs); 200 202 String id = attrs.apply("id"); 201 203 if (id != null) { -
trunk/src/org/openstreetmap/josm/io/OsmApi.java
r18991 r19050 809 809 errorHeader = errorHeader == null ? null : errorHeader.trim(); 810 810 String errorBody = responseBody.isEmpty() ? null : responseBody.trim(); 811 switch (retCode) {811 switch (retCode) { 812 812 case HttpURLConnection.HTTP_OK: 813 813 return responseBody; -
trunk/src/org/openstreetmap/josm/io/OsmChangesetParser.java
r17720 r19050 59 59 } 60 60 61 private class Parser extends DefaultHandler {61 private final class Parser extends DefaultHandler { 62 62 private Locator locator; 63 63 … … 67 67 } 68 68 69 protectedvoid throwException(String msg) throws XmlParsingException {69 void throwException(String msg) throws XmlParsingException { 70 70 throw new XmlParsingException(msg).rememberLocation(locator); 71 71 } … … 80 80 private StringBuilder text; 81 81 82 protectedvoid parseChangesetAttributes(Attributes atts) throws XmlParsingException {82 void parseChangesetAttributes(Attributes atts) throws XmlParsingException { 83 83 // -- id 84 84 String value = atts.getValue("id"); … … 248 248 } 249 249 250 protectedUser createUser(Attributes atts) throws XmlParsingException {250 User createUser(Attributes atts) throws XmlParsingException { 251 251 String name = atts.getValue("user"); 252 252 String uid = atts.getValue("uid"); -
trunk/src/org/openstreetmap/josm/io/OsmHistoryReader.java
r18871 r19050 35 35 private final HistoryDataSet data; 36 36 37 private class Parser extends AbstractParser {37 private final class Parser extends AbstractParser { 38 38 39 protectedString getCurrentPosition() {39 String getCurrentPosition() { 40 40 if (locator == null) 41 41 return ""; -
trunk/src/org/openstreetmap/josm/io/OsmPbfReader.java
r19048 r19050 94 94 inputStream = new BoundedInputStream(new BufferedInputStream(source)); 95 95 } 96 try ( var parser = new ProtobufParser(inputStream)) {97 final varbaos = new ByteArrayOutputStream();96 try (ProtobufParser parser = new ProtobufParser(inputStream)) { 97 final ByteArrayOutputStream baos = new ByteArrayOutputStream(); 98 98 HeaderBlock headerBlock = null; 99 99 BlobHeader blobHeader = null; … … 106 106 } 107 107 // OSM PBF is fun -- it has *nested* pbf data 108 final varblob = parseBlob(blobHeader, inputStream, parser, baos);108 final Blob blob = parseBlob(blobHeader, inputStream, parser, baos); 109 109 headerBlock = parseHeaderBlock(blob, baos); 110 110 checkRequiredFeatures(headerBlock); … … 114 114 throw new IllegalStateException("A header block must occur before the first data block"); 115 115 } 116 final varblob = parseBlob(blobHeader, inputStream, parser, baos);116 final Blob blob = parseBlob(blobHeader, inputStream, parser, baos); 117 117 parseDataBlock(baos, headerBlock, blob); 118 118 blobHeader = null; … … 138 138 byte[] indexData = null; 139 139 int datasize = Integer.MIN_VALUE; 140 varlength = 0;140 int length = 0; 141 141 long start = cis.getCount(); 142 142 while (parser.hasNext() && (length == 0 || cis.getCount() - start < length)) { 143 final varcurrent = new ProtobufRecord(baos, parser);143 final ProtobufRecord current = new ProtobufRecord(baos, parser); 144 144 switch (current.getField()) { 145 145 case 1: … … 239 239 @Nonnull 240 240 private static HeaderBlock parseHeaderBlock(Blob blob, ByteArrayOutputStream baos) throws IOException { 241 try ( varblobInput = blob.inputStream();242 var parser = new ProtobufParser(blobInput)) {241 try (InputStream blobInput = blob.inputStream(); 242 ProtobufParser parser = new ProtobufParser(blobInput)) { 243 243 BBox bbox = null; 244 final var required = new ArrayList<String>();245 final var optional = new ArrayList<String>();244 List<String> required = new ArrayList<>(); 245 List<String> optional = new ArrayList<>(); 246 246 String program = null; 247 247 String source = null; … … 250 250 String osmosisReplicationBaseUrl = null; 251 251 while (parser.hasNext()) { 252 final varcurrent = new ProtobufRecord(baos, parser);252 final ProtobufRecord current = new ProtobufRecord(baos, parser); 253 253 switch (current.getField()) { 254 254 case 1: // bbox … … 311 311 String[] stringTable = null; // field 1, note that stringTable[0] is a delimiter, so it is always blank and unused 312 312 // field 2 -- we cannot parse these live just in case the following fields come later 313 final var primitiveGroups = new ArrayList<ProtobufRecord>();314 vargranularity = 100; // field 17313 final List<ProtobufRecord> primitiveGroups = new ArrayList<>(); 314 int granularity = 100; // field 17 315 315 long latOffset = 0; // field 19 316 316 long lonOffset = 0; // field 20 317 vardateGranularity = 1000; // field 18, default is milliseconds since the 1970 epoch318 try ( varinputStream = blob.inputStream();319 var parser = new ProtobufParser(inputStream)) {317 int dateGranularity = 1000; // field 18, default is milliseconds since the 1970 epoch 318 try (InputStream inputStream = blob.inputStream(); 319 ProtobufParser parser = new ProtobufParser(inputStream)) { 320 320 while (parser.hasNext()) { 321 final varprotobufRecord = new ProtobufRecord(baos, parser);321 final ProtobufRecord protobufRecord = new ProtobufRecord(baos, parser); 322 322 switch (protobufRecord.getField()) { 323 323 case 1: … … 343 343 } 344 344 } 345 final varprimitiveBlockRecord = new PrimitiveBlockRecord(stringTable, granularity, latOffset, lonOffset,345 final PrimitiveBlockRecord primitiveBlockRecord = new PrimitiveBlockRecord(stringTable, granularity, latOffset, lonOffset, 346 346 dateGranularity); 347 final vards = getDataSet();347 final DataSet ds = getDataSet(); 348 348 if (!primitiveGroups.isEmpty() && headerBlock.bbox() != null) { 349 349 try { … … 375 375 @Nullable 376 376 private static BBox parseBBox(ByteArrayOutputStream baos, ProtobufRecord current) throws IOException { 377 try ( varbboxInputStream = new ByteArrayInputStream(current.getBytes());378 var bboxParser = new ProtobufParser(bboxInputStream)) {377 try (ByteArrayInputStream bboxInputStream = new ByteArrayInputStream(current.getBytes()); 378 ProtobufParser bboxParser = new ProtobufParser(bboxInputStream)) { 379 379 double left = Double.NaN; 380 380 double right = Double.NaN; … … 382 382 double bottom = Double.NaN; 383 383 while (bboxParser.hasNext()) { 384 final varprotobufRecord = new ProtobufRecord(baos, bboxParser);384 final ProtobufRecord protobufRecord = new ProtobufRecord(baos, bboxParser); 385 385 if (protobufRecord.getType() == WireType.VARINT) { 386 386 double value = protobufRecord.asSignedVarInt().longValue() * NANO_DEGREES; … … 419 419 @Nonnull 420 420 private static String[] parseStringTable(ByteArrayOutputStream baos, byte[] bytes) throws IOException { 421 try ( varis = new ByteArrayInputStream(bytes);422 var parser = new ProtobufParser(is)) {423 final var list = new ArrayList<String>();421 try (ByteArrayInputStream is = new ByteArrayInputStream(bytes); 422 ProtobufParser parser = new ProtobufParser(is)) { 423 final List<String> list = new ArrayList<>(); 424 424 while (parser.hasNext()) { 425 final varprotobufRecord = new ProtobufRecord(baos, parser);425 final ProtobufRecord protobufRecord = new ProtobufRecord(baos, parser); 426 426 if (protobufRecord.getField() == 1) { 427 427 list.add(protobufRecord.asString().intern()); // field is technically repeated bytes … … 444 444 private void parsePrimitiveGroup(ByteArrayOutputStream baos, byte[] bytes, PrimitiveBlockRecord primitiveBlockRecord) 445 445 throws IllegalDataException, IOException { 446 try ( varbais = new ByteArrayInputStream(bytes);447 var parser = new ProtobufParser(bais)) {446 try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 447 ProtobufParser parser = new ProtobufParser(bais)) { 448 448 while (parser.hasNext()) { 449 final varprotobufRecord = new ProtobufRecord(baos, parser);449 final ProtobufRecord protobufRecord = new ProtobufRecord(baos, parser); 450 450 switch (protobufRecord.getField()) { 451 451 case 1: // Nodes, repeated … … 480 480 private void parseNode(ByteArrayOutputStream baos, byte[] bytes, PrimitiveBlockRecord primitiveBlockRecord) 481 481 throws IllegalDataException, IOException { 482 try ( varbais = new ByteArrayInputStream(bytes);483 var parser = new ProtobufParser(bais)) {482 try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 483 ProtobufParser parser = new ProtobufParser(bais)) { 484 484 long id = Long.MIN_VALUE; 485 final var keys = new ArrayList<String>();486 final var values = new ArrayList<String>();485 final List<String> keys = new ArrayList<>(); 486 final List<String> values = new ArrayList<>(); 487 487 Info info = null; 488 488 long lat = Long.MIN_VALUE; 489 489 long lon = Long.MIN_VALUE; 490 490 while (parser.hasNext()) { 491 final varprotobufRecord = new ProtobufRecord(baos, parser);491 final ProtobufRecord protobufRecord = new ProtobufRecord(baos, parser); 492 492 switch (protobufRecord.getField()) { 493 493 case 1: … … 519 519 throw new IllegalDataException("OSM PBF did not provide all the required node information"); 520 520 } 521 final varnode = new NodeData(id);521 final NodeData node = new NodeData(id); 522 522 node.setCoor(calculateLatLon(primitiveBlockRecord, lat, lon)); 523 523 addTags(node, keys, values); … … 547 547 long[] keyVals = EMPTY_LONG; // technically can be int 548 548 Info[] denseInfo = null; 549 try ( varbais = new ByteArrayInputStream(bytes);550 var parser = new ProtobufParser(bais)) {549 try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 550 ProtobufParser parser = new ProtobufParser(bais)) { 551 551 while (parser.hasNext()) { 552 final varprotobufRecord = new ProtobufRecord(baos, parser);552 final ProtobufRecord protobufRecord = new ProtobufRecord(baos, parser); 553 553 switch (protobufRecord.getField()) { 554 554 case 1: // packed node ids, DELTA encoded … … 576 576 } 577 577 578 varkeyValIndex = 0; // This index must not reset between nodes, and must always increment578 int keyValIndex = 0; // This index must not reset between nodes, and must always increment 579 579 if (ids.length == lats.length && lats.length == lons.length && (denseInfo == null || denseInfo.length == lons.length)) { 580 580 long id = 0; 581 581 long lat = 0; 582 582 long lon = 0; 583 for ( vari = 0; i < ids.length; i++) {583 for (int i = 0; i < ids.length; i++) { 584 584 final NodeData node; 585 585 id += ids[i]; 586 586 node = new NodeData(id); 587 587 if (denseInfo != null) { 588 final varinfo = denseInfo[i];588 final Info info = denseInfo[i]; 589 589 setOsmPrimitiveData(primitiveBlockRecord, node, info); 590 590 } else { … … 638 638 // We don't do live drawing, so we don't care about lats and lons (we essentially throw them away with the current parser) 639 639 // This is for the optional feature "LocationsOnWays" 640 try ( varbais = new ByteArrayInputStream(bytes);641 var parser = new ProtobufParser(bais)) {640 try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 641 ProtobufParser parser = new ProtobufParser(bais)) { 642 642 while (parser.hasNext()) { 643 final varprotobufRecord = new ProtobufRecord(baos, parser);643 final ProtobufRecord protobufRecord = new ProtobufRecord(baos, parser); 644 644 switch (protobufRecord.getField()) { 645 645 case 1: … … 672 672 throw new IllegalDataException("A way with either no id or no nodes was found"); 673 673 } 674 final varwayData = new WayData(id);675 final var nodeIds = new ArrayList<Long>(refs.length);674 final WayData wayData = new WayData(id); 675 final List<Long> nodeIds = new ArrayList<>(refs.length); 676 676 long ref = 0; 677 677 for (long tRef : refs) { … … 701 701 throws IllegalDataException, IOException { 702 702 long id = Long.MIN_VALUE; 703 final var keys = new ArrayList<String>();704 final var values = new ArrayList<String>();703 final List<String> keys = new ArrayList<>(); 704 final List<String> values = new ArrayList<>(); 705 705 Info info = null; 706 706 long[] rolesStringId = EMPTY_LONG; // Technically int 707 707 long[] memids = EMPTY_LONG; 708 708 long[] types = EMPTY_LONG; // Technically an enum 709 try ( varbais = new ByteArrayInputStream(bytes);710 var parser = new ProtobufParser(bais)) {709 try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 710 ProtobufParser parser = new ProtobufParser(bais)) { 711 711 while (parser.hasNext()) { 712 final varprotobufRecord = new ProtobufRecord(baos, parser);712 final ProtobufRecord protobufRecord = new ProtobufRecord(baos, parser); 713 713 switch (protobufRecord.getField()) { 714 714 case 1: … … 747 747 throw new IllegalDataException("OSM PBF contains a bad relation definition"); 748 748 } 749 final vardata = new RelationData(id);749 final RelationData data = new RelationData(id); 750 750 if (info != null) { 751 751 setOsmPrimitiveData(primitiveBlockRecord, data, info); … … 757 757 List<RelationMemberData> members = new ArrayList<>(rolesStringId.length); 758 758 long memberId = 0; 759 for ( vari = 0; i < rolesStringId.length; i++) {759 for (int i = 0; i < rolesStringId.length; i++) { 760 760 String role = primitiveBlockRecord.stringTable[(int) rolesStringId[i]]; 761 761 memberId += memids[i]; … … 777 777 @Nonnull 778 778 private static Info parseInfo(ByteArrayOutputStream baos, byte[] bytes) throws IOException { 779 try ( varbais = new ByteArrayInputStream(bytes);780 var parser = new ProtobufParser(bais)) {779 try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 780 ProtobufParser parser = new ProtobufParser(bais)) { 781 781 int version = -1; 782 782 Long timestamp = null; … … 784 784 Integer uid = null; 785 785 Integer userSid = null; 786 varvisible = true;786 boolean visible = true; 787 787 while (parser.hasNext()) { 788 final varprotobufRecord = new ProtobufRecord(baos, parser);788 final ProtobufRecord protobufRecord = new ProtobufRecord(baos, parser); 789 789 switch (protobufRecord.getField()) { 790 790 case 1: … … 839 839 } 840 840 Map<String, String> tagMap = new HashMap<>(keys.size()); 841 for ( vari = 0; i < keys.size(); i++) {841 for (int i = 0; i < keys.size(); i++) { 842 842 tagMap.put(keys.get(i), values.get(i)); 843 843 } … … 879 879 @Nonnull 880 880 private static long[] decodePackedSInt64(long[] numbers) { 881 for ( vari = 0; i < numbers.length; i++) {881 for (int i = 0; i < numbers.length; i++) { 882 882 numbers[i] = ProtobufParser.decodeZigZag(numbers[i]); 883 883 } … … 922 922 long[] userSid = EMPTY_LONG; // technically int 923 923 long[] visible = EMPTY_LONG; // optional, true if not set, technically booleans 924 try ( varbais = new ByteArrayInputStream(bytes);925 var parser = new ProtobufParser(bais)) {924 try (ByteArrayInputStream bais = new ByteArrayInputStream(bytes); 925 ProtobufParser parser = new ProtobufParser(bais)) { 926 926 while (parser.hasNext()) { 927 final varprotobufRecord = new ProtobufRecord(baos, parser);927 final ProtobufRecord protobufRecord = new ProtobufRecord(baos, parser); 928 928 switch (protobufRecord.getField()) { 929 929 case 1: … … 956 956 } 957 957 if (version.length > 0) { 958 final varinfos = new Info[version.length];958 final Info[] infos = new Info[version.length]; 959 959 long lastTimestamp = 0; // delta encoded 960 960 long lastChangeset = 0; // delta encoded 961 961 long lastUid = 0; // delta encoded, 962 962 long lastUserSid = 0; // delta encoded, string id for username 963 for ( vari = 0; i < version.length; i++) {963 for (int i = 0; i < version.length; i++) { 964 964 if (timestamp.length > i) 965 965 lastTimestamp += timestamp[i]; -
trunk/src/org/openstreetmap/josm/io/OsmServerWriter.java
r12743 r19050 99 99 for (OsmPrimitive osm : primitives) { 100 100 String msg; 101 switch (OsmPrimitiveType.from(osm)) {101 switch (OsmPrimitiveType.from(osm)) { 102 102 case NODE: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading node ''{4}'' (id: {5})"); break; 103 103 case WAY: msg = marktr("{0}% ({1}/{2}), {3} left. Uploading way ''{4}'' (id: {5})"); break; … … 207 207 } 208 208 api.setChangeset(changeset); 209 switch (strategy.getStrategy()) {209 switch (strategy.getStrategy()) { 210 210 case SINGLE_REQUEST_STRATEGY: 211 211 uploadChangesAsDiffUpload(primitives, monitor.createSubTaskMonitor(0, false)); -
trunk/src/org/openstreetmap/josm/io/UploadStrategySpecification.java
r18283 r19050 137 137 if (numObjects <= 0) 138 138 return 0; 139 switch (strategy) {139 switch (strategy) { 140 140 case INDIVIDUAL_OBJECTS_STRATEGY: return numObjects; 141 141 case SINGLE_REQUEST_STRATEGY: return 1; -
trunk/src/org/openstreetmap/josm/io/auth/JosmPreferencesCredentialAgent.java
r18991 r19050 11 11 import java.util.Set; 12 12 13 import jakarta.json.JsonException;14 13 import javax.swing.text.html.HTMLEditorKit; 15 14 … … 24 23 import org.openstreetmap.josm.spi.preferences.Config; 25 24 import org.openstreetmap.josm.tools.Utils; 25 26 import jakarta.json.JsonException; 26 27 27 28 /** … … 41 42 String user; 42 43 String password; 43 switch (requestorType) {44 switch (requestorType) { 44 45 case SERVER: 45 46 if (Objects.equals(OsmApi.getOsmApi().getHost(), host)) { … … 73 74 if (requestorType == null) 74 75 return; 75 switch (requestorType) {76 switch (requestorType) { 76 77 case SERVER: 77 78 if (Objects.equals(OsmApi.getOsmApi().getHost(), host)) { -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r18871 r19050 112 112 } 113 113 114 private static class Parser extends DefaultHandler {114 private static final class Parser extends DefaultHandler { 115 115 private static final String MAX_ZOOM = "max-zoom"; 116 116 private static final String MIN_ZOOM = "min-zoom"; … … 366 366 case MIRROR_ATTRIBUTE: 367 367 if (mirrorEntry != null) { 368 switch (qName) {368 switch (qName) { 369 369 case "type": 370 370 Optional<ImageryType> type = Arrays.stream(ImageryType.values()) … … 412 412 break; 413 413 case ENTRY_ATTRIBUTE: 414 switch (qName) {414 switch (qName) { 415 415 case "name": 416 416 entry.setName(lang == null ? LanguageInfo.getJOSMLocaleCode(null) : lang, accumulator.toString()); -
trunk/src/org/openstreetmap/josm/io/nmea/NmeaParser.java
r18787 r19050 387 387 if (!accu.isEmpty()) { 388 388 int fixtype = Integer.parseInt(accu); 389 switch (fixtype) {389 switch (fixtype) { 390 390 case 0: 391 391 currentwp.put(GpxConstants.PT_FIX, "none"); -
trunk/src/org/openstreetmap/josm/io/session/GeoImageSessionImporter.java
r17715 r19050 74 74 private static void handleElement(GpxImageEntry entry, Element attrElem) { 75 75 try { 76 switch (attrElem.getTagName()) {76 switch (attrElem.getTagName()) { 77 77 case "file": 78 78 entry.setFile(new File(attrElem.getTextContent())); -
trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
r18975 r19050 574 574 tr("Unable to load layer"), 575 575 tr("Cannot load layer of type ''{0}'' because no suitable importer was found.", type), 576 JOptionPane.WARNING_MESSAGE, 577 progressMonitor 578 ); 576 JOptionPane.WARNING_MESSAGE 577 ); 579 578 if (dialog.isCancel()) { 580 579 progressMonitor.cancel(); … … 593 592 tr("Unable to load layer"), 594 593 tr("Cannot load layer {0} because it depends on layer {1} which has been skipped.", idx, d), 595 JOptionPane.WARNING_MESSAGE, 596 progressMonitor 597 ); 594 JOptionPane.WARNING_MESSAGE 595 ); 598 596 if (dialog.isCancel()) { 599 597 progressMonitor.cancel(); … … 625 623 Utils.escapeReservedCharactersHTML(name), 626 624 Utils.escapeReservedCharactersHTML(exception.getMessage())), 627 JOptionPane.ERROR_MESSAGE, 628 progressMonitor 629 ); 625 JOptionPane.ERROR_MESSAGE 626 ); 630 627 if (dialog.isCancel()) { 631 628 progressMonitor.cancel(); … … 735 732 * needed to block the current thread and wait for the result of the modal dialog from EDT. 736 733 */ 737 private static class CancelOrContinueDialog {734 private static final class CancelOrContinueDialog { 738 735 739 736 private boolean cancel; 740 737 741 public void show(final String title, final String message, final int icon, final ProgressMonitor progressMonitor) {738 void show(final String title, final String message, final int icon) { 742 739 try { 743 740 SwingUtilities.invokeAndWait(() -> { -
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r16553 r19050 24 24 * For all purposes of loading dynamic resources, the Plugin's class loader should be used 25 25 * (or else, the plugin jar will not be within the class path). 26 * 26 * <p> 27 27 * A plugin may subclass this abstract base class (but it is optional). 28 * 28 * <p> 29 29 * The actual implementation of this class is optional, as all functions will be called 30 30 * via reflection. This is to be able to change this interface without the need of … … 32 32 * function here (or does provide a function with a mismatching signature), it will not 33 33 * be called. That simple. 34 * 34 * <p> 35 35 * Or in other words: See this base class as an documentation of what automatic callbacks 36 36 * are provided (you can register yourself to more callbacks in your plugin class 37 37 * constructor). 38 * 38 * <p> 39 39 * Subclassing Plugin and overriding some functions makes it easy for you to keep sync 40 40 * with the correct actual plugin architecture of JOSM. … … 47 47 * This is the info available for this plugin. You can access this from your 48 48 * constructor. 49 * 49 * <p> 50 50 * (The actual implementation to request the info from a static variable 51 51 * is a bit hacky, but it works). … … 55 55 private final IBaseDirectories pluginBaseDirectories = new PluginBaseDirectories(); 56 56 57 private class PluginBaseDirectories implements IBaseDirectories {57 private final class PluginBaseDirectories implements IBaseDirectories { 58 58 private File preferencesDir; 59 59 private File cacheDir; -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r18833 r19050 501 501 // 502 502 String policy = Config.getPref().get(togglePreferenceKey, "ask").trim().toLowerCase(Locale.ENGLISH); 503 switch (policy) {503 switch (policy) { 504 504 case "never": 505 505 if ("pluginmanager.version-based-update.policy".equals(togglePreferenceKey)) { … … 552 552 553 553 if (pnlMessage.isRememberDecision()) { 554 switch (ret) {554 switch (ret) { 555 555 case 0: 556 556 Config.getPref().put(togglePreferenceKey, "always"); … … 1644 1644 + (!Utils.isEmpty(info.localversion) ? " Version: " + info.localversion : ""); 1645 1645 pluginTab.add(new JLabel(name), GBC.std()); 1646 pluginTab.add(Box.createHorizontalGlue(), GBC.std().fill(G BC.HORIZONTAL));1646 pluginTab.add(Box.createHorizontalGlue(), GBC.std().fill(GridBagConstraints.HORIZONTAL)); 1647 1647 pluginTab.add(new JButton(new PluginInformationAction(info)), GBC.eol()); 1648 1648 … … 1657 1657 description.setCaretPosition(0); 1658 1658 1659 pluginTab.add(description, GBC.eop().fill(G BC.HORIZONTAL));1659 pluginTab.add(description, GBC.eop().fill(GridBagConstraints.HORIZONTAL)); 1660 1660 } 1661 1661 return pluginTab; -
trunk/src/org/openstreetmap/josm/tools/CopyList.java
r10314 r19050 139 139 } 140 140 141 private class Itr implements Iterator<E> {141 private final class Itr implements Iterator<E> { 142 142 /** 143 143 * Index of element to be returned by subsequent call to next. … … 198 198 } 199 199 200 finalvoid checkForComodification() {200 void checkForComodification() { 201 201 if (modCount != expectedModCount) 202 202 throw new ConcurrentModificationException(); -
trunk/src/org/openstreetmap/josm/tools/I18n.java
r19043 r19050 646 646 647 647 private static int pluralEval(long n) { 648 switch (pluralMode) {648 switch (pluralMode) { 649 649 case MODE_NOTONE: /* bg, da, de, el, en, en_AU, en_CA, en_GB, es, et, eu, fi, gl, is, it, iw_IL, mr, nb, nl, sv */ 650 650 return (n != 1) ? 1 : 0; -
trunk/src/org/openstreetmap/josm/tools/ImageResizeMode.java
r19048 r19050 87 87 */ 88 88 BufferedImage createBufferedImage(Dimension dim, Dimension icon, Consumer<Graphics2D> renderer, Image sourceIcon) { 89 final varreal = computeDimension(dim, icon);90 final varbufferedImage = new BufferedImage(real.width, real.height, BufferedImage.TYPE_INT_ARGB);89 final Dimension real = computeDimension(dim, icon); 90 final BufferedImage bufferedImage = new BufferedImage(real.width, real.height, BufferedImage.TYPE_INT_ARGB); 91 91 final Graphics2D g = bufferedImage.createGraphics(); 92 92 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); -
trunk/src/org/openstreetmap/josm/tools/ListenerList.java
r18466 r19050 224 224 } 225 225 226 private static class UncheckedListenerList<T> extends ListenerList<T> {226 private static final class UncheckedListenerList<T> extends ListenerList<T> { 227 227 @Override 228 228 protected void failAdd(T listener) { -
trunk/src/org/openstreetmap/josm/tools/Logging.java
r17820 r19050 130 130 131 131 @Override 132 public synchronized void publish(LogRecord record) {133 if (this.prioritizedHandler == null || !this.prioritizedHandler.isLoggable( record)) {134 super.publish( record);132 public synchronized void publish(LogRecord logRecord) { 133 if (this.prioritizedHandler == null || !this.prioritizedHandler.isLoggable(logRecord)) { 134 super.publish(logRecord); 135 135 } 136 136 } … … 481 481 } 482 482 483 private static class RememberWarningHandler extends Handler {483 private static final class RememberWarningHandler extends Handler { 484 484 private final String[] log = new String[10]; 485 485 private int messagesLogged; … … 491 491 492 492 @Override 493 public synchronized void publish(LogRecord record) {493 public synchronized void publish(LogRecord logRecord) { 494 494 // We don't use setLevel + isLoggable to work in WebStart Sandbox mode 495 if ( record.getLevel().intValue() < LEVEL_WARN.intValue()) {495 if (logRecord.getLevel().intValue() < LEVEL_WARN.intValue()) { 496 496 return; 497 497 } 498 498 499 String msg = String.format(Locale.ROOT, "%09.3f %s%s", startup.elapsed() / 1000., getPrefix( record), record.getMessage());499 String msg = String.format(Locale.ROOT, "%09.3f %s%s", startup.elapsed() / 1000., getPrefix(logRecord), logRecord.getMessage()); 500 500 501 501 // Only remember first line of message … … 508 508 } 509 509 510 private static String getPrefix(LogRecord record) {511 if ( record.getLevel().equals(LEVEL_WARN)) {510 private static String getPrefix(LogRecord logRecord) { 511 if (logRecord.getLevel().equals(LEVEL_WARN)) { 512 512 return "W: "; 513 513 } else { -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r18871 r19050 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.event.InputEvent; 6 7 import java.awt.event.KeyEvent; 7 8 import java.util.ArrayList; … … 246 247 public void setAccelerator(AbstractAction action) { 247 248 if (getKeyStroke() != null) { 248 action.putValue(A bstractAction.ACCELERATOR_KEY, getKeyStroke());249 action.putValue(Action.ACCELERATOR_KEY, getKeyStroke()); 249 250 } 250 251 } … … 266 267 public static String getKeyText(KeyStroke keyStroke) { 267 268 if (keyStroke == null) return ""; 268 String modifText = KeyEvent.getModifiersExText(keyStroke.getModifiers());269 String modifText = InputEvent.getModifiersExText(keyStroke.getModifiers()); 269 270 if (modifText.isEmpty()) return KeyEvent.getKeyText(keyStroke.getKeyCode()); 270 271 return modifText + '+' + KeyEvent.getKeyText(keyStroke.getKeyCode()); … … 307 308 private static final ShortcutCollection shortcuts = new ShortcutCollection(); 308 309 309 private static class ShortcutCollection extends CopyOnWriteArrayList<Shortcut> {310 private static final class ShortcutCollection extends CopyOnWriteArrayList<Shortcut> { 310 311 private static final long serialVersionUID = 1L; 311 312 @Override … … 398 399 int commandDownMask = PlatformManager.getPlatform().getMenuShortcutKeyMaskEx(); 399 400 groups.put(NONE, -1); 400 groups.put(MNEMONIC, KeyEvent.ALT_DOWN_MASK);401 groups.put(MNEMONIC, InputEvent.ALT_DOWN_MASK); 401 402 groups.put(DIRECT, 0); 402 groups.put(ALT, KeyEvent.ALT_DOWN_MASK);403 groups.put(SHIFT, KeyEvent.SHIFT_DOWN_MASK);403 groups.put(ALT, InputEvent.ALT_DOWN_MASK); 404 groups.put(SHIFT, InputEvent.SHIFT_DOWN_MASK); 404 405 groups.put(CTRL, commandDownMask); 405 groups.put(ALT_SHIFT, KeyEvent.ALT_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);406 groups.put(ALT_CTRL, KeyEvent.ALT_DOWN_MASK | commandDownMask);407 groups.put(CTRL_SHIFT, commandDownMask | KeyEvent.SHIFT_DOWN_MASK);408 groups.put(ALT_CTRL_SHIFT, KeyEvent.ALT_DOWN_MASK | commandDownMask | KeyEvent.SHIFT_DOWN_MASK);406 groups.put(ALT_SHIFT, InputEvent.ALT_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK); 407 groups.put(ALT_CTRL, InputEvent.ALT_DOWN_MASK | commandDownMask); 408 groups.put(CTRL_SHIFT, commandDownMask | InputEvent.SHIFT_DOWN_MASK); 409 groups.put(ALT_CTRL_SHIFT, InputEvent.ALT_DOWN_MASK | commandDownMask | InputEvent.SHIFT_DOWN_MASK); 409 410 410 411 // (1) System reserved shortcuts … … 567 568 private static int findNewOsxModifier(int requestedGroup) { 568 569 switch (requestedGroup) { 569 case CTRL: return KeyEvent.CTRL_DOWN_MASK;570 case ALT_CTRL: return KeyEvent.ALT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK;571 case CTRL_SHIFT: return KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK;572 case ALT_CTRL_SHIFT: return KeyEvent.ALT_DOWN_MASK | KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK;570 case CTRL: return InputEvent.CTRL_DOWN_MASK; 571 case ALT_CTRL: return InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK; 572 case CTRL_SHIFT: return InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK; 573 case ALT_CTRL_SHIFT: return InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK; 573 574 default: return 0; 574 575 } -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r19048 r19050 9 9 import java.awt.font.FontRenderContext; 10 10 import java.awt.font.GlyphVector; 11 import java.io.ByteArrayOutputStream;12 11 import java.io.Closeable; 13 12 import java.io.File; … … 30 29 import java.nio.file.StandardCopyOption; 31 30 import java.nio.file.attribute.BasicFileAttributes; 31 import java.nio.file.attribute.FileTime; 32 32 import java.security.MessageDigest; 33 33 import java.security.NoSuchAlgorithmException; … … 152 152 */ 153 153 public static <T> int indexOf(Iterable<? extends T> collection, Predicate<? super T> predicate) { 154 vari = 0;155 for ( varitem : collection) {154 int i = 0; 155 for (T item : collection) { 156 156 if (predicate.test(item)) 157 157 return i; … … 168 168 * @throws AssertionError if the condition is not met 169 169 */ 170 public static void ensure(boolean condition, String message, Object... data) {170 public static void ensure(boolean condition, String message, Object... data) { 171 171 if (!condition) 172 172 throw new AssertionError( … … 185 185 if (n <= 0) 186 186 throw new IllegalArgumentException("n must be <= 0 but is " + n); 187 varres = a % n;187 int res = a % n; 188 188 if (res < 0) { 189 189 res += n; … … 303 303 Logging.warn("Unable to create directory "+out.getPath()); 304 304 } 305 varfiles = in.listFiles();305 File[] files = in.listFiles(); 306 306 if (files != null) { 307 for ( varf : files) {308 vartarget = new File(out, f.getName());307 for (File f : files) { 308 File target = new File(out, f.getName()); 309 309 if (f.isDirectory()) { 310 310 copyDirectory(f, target); … … 324 324 public static boolean deleteDirectory(File path) { 325 325 if (path.exists()) { 326 varfiles = path.listFiles();326 File[] files = path.listFiles(); 327 327 if (files != null) { 328 for ( varfile : files) {328 for (File file : files) { 329 329 if (file.isDirectory()) { 330 330 deleteDirectory(file); … … 371 371 */ 372 372 public static boolean deleteFile(File file, String warnMsg) { 373 varresult = file.delete();373 boolean result = file.delete(); 374 374 if (!result) { 375 375 Logging.warn(tr(warnMsg, file.getPath())); … … 397 397 */ 398 398 public static boolean mkDirs(File dir, String warnMsg) { 399 varresult = dir.mkdirs();399 boolean result = dir.mkdirs(); 400 400 if (!result) { 401 401 Logging.warn(tr(warnMsg, dir.getPath())); … … 497 497 throw new JosmRuntimeException(e); 498 498 } 499 varbyteData = data.getBytes(StandardCharsets.UTF_8);500 varbyteDigest = md.digest(byteData);499 byte[] byteData = data.getBytes(StandardCharsets.UTF_8); 500 byte[] byteDigest = md.digest(byteData); 501 501 return toHexString(byteDigest); 502 502 } … … 517 517 } 518 518 519 final varlen = bytes.length;519 final int len = bytes.length; 520 520 if (len == 0) { 521 521 return ""; 522 522 } 523 523 524 varhexChars = new char[len * 2];525 varj = 0;524 char[] hexChars = new char[len * 2]; 525 int j = 0; 526 526 for (final int v : bytes) { 527 527 hexChars[j++] = HEX_ARRAY[(v & 0xf0) >> 4]; … … 541 541 */ 542 542 public static <T> List<T> topologicalSort(final MultiMap<T, T> dependencies) { 543 var deps = new MultiMap<T, T>();544 for ( varkey : dependencies.keySet()) {543 MultiMap<T, T> deps = new MultiMap<>(); 544 for (T key : dependencies.keySet()) { 545 545 deps.putVoid(key); 546 for ( varval : dependencies.get(key)) {546 for (T val : dependencies.get(key)) { 547 547 deps.putVoid(val); 548 548 deps.put(key, val); … … 550 550 } 551 551 552 varsize = deps.size();552 int size = deps.size(); 553 553 List<T> sorted = new ArrayList<>(); 554 for ( vari = 0; i < size; ++i) {555 varparentless = deps.keySet().stream()554 for (int i = 0; i < size; ++i) { 555 T parentless = deps.keySet().stream() 556 556 .filter(key -> deps.get(key).isEmpty()) 557 557 .findFirst().orElse(null); … … 559 559 sorted.add(parentless); 560 560 deps.remove(parentless); 561 for ( varkey : deps.keySet()) {561 for (T key : deps.keySet()) { 562 562 deps.remove(key, parentless); 563 563 } … … 679 679 return Collections.emptyMap(); 680 680 } else if (map.size() == 1) { 681 final varentry = map.entrySet().iterator().next();681 final Map.Entry<K, V> entry = map.entrySet().iterator().next(); 682 682 return Collections.singletonMap(entry.getKey(), entry.getValue()); 683 683 } else if (mapOfEntries != null) { … … 795 795 } 796 796 797 varstart = 0;798 varend = str.length();799 varleadingSkipChar = true;797 int start = 0; 798 int end = str.length(); 799 boolean leadingSkipChar = true; 800 800 while (leadingSkipChar && start < end) { 801 801 leadingSkipChar = isStrippedChar(str.charAt(start), skipChars); … … 804 804 } 805 805 } 806 vartrailingSkipChar = true;806 boolean trailingSkipChar = true; 807 807 while (trailingSkipChar && end > start) { 808 808 trailingSkipChar = isStrippedChar(str.charAt(end - 1), skipChars); … … 866 866 Logging.debug(String.join(" ", command)); 867 867 } 868 varout = Files.createTempFile("josm_exec_" + command.get(0) + "_", ".txt");868 Path out = Files.createTempFile("josm_exec_" + command.get(0) + "_", ".txt"); 869 869 try { 870 varp = new ProcessBuilder(command).redirectErrorStream(true).redirectOutput(out.toFile()).start();870 Process p = new ProcessBuilder(command).redirectErrorStream(true).redirectOutput(out.toFile()).start(); 871 871 if (!p.waitFor(timeout, unit) || p.exitValue() != 0) { 872 872 throw new ExecutionException(command.toString(), null); … … 888 888 */ 889 889 public static File getJosmTempDir() { 890 vartmpDir = getSystemProperty("java.io.tmpdir");890 String tmpDir = getSystemProperty("java.io.tmpdir"); 891 891 if (tmpDir == null) { 892 892 return null; 893 893 } 894 final varjosmTmpDir = new File(tmpDir, "JOSM");894 final File josmTmpDir = new File(tmpDir, "JOSM"); 895 895 if (!josmTmpDir.exists() && !josmTmpDir.mkdirs()) { 896 896 Logging.warn("Unable to create temp directory " + josmTmpDir); … … 920 920 // Is it less than 1 hour ? 921 921 if (elapsedTime < MILLIS_OF_HOUR) { 922 final varmin = elapsedTime / MILLIS_OF_MINUTE;922 final long min = elapsedTime / MILLIS_OF_MINUTE; 923 923 return String.format("%d %s %d %s", min, tr("min"), (elapsedTime - min * MILLIS_OF_MINUTE) / MILLIS_OF_SECOND, tr("s")); 924 924 } 925 925 // Is it less than 1 day ? 926 926 if (elapsedTime < MILLIS_OF_DAY) { 927 final varhour = elapsedTime / MILLIS_OF_HOUR;927 final long hour = elapsedTime / MILLIS_OF_HOUR; 928 928 return String.format("%d %s %d %s", hour, tr("h"), (elapsedTime - hour * MILLIS_OF_HOUR) / MILLIS_OF_MINUTE, tr("min")); 929 929 } 930 vardays = elapsedTime / MILLIS_OF_DAY;930 long days = elapsedTime / MILLIS_OF_DAY; 931 931 return String.format("%d %s %d %s", days, trn("day", "days", days), (elapsedTime - days * MILLIS_OF_DAY) / MILLIS_OF_HOUR, tr("h")); 932 932 } … … 943 943 throw new IllegalArgumentException("bytes must be >= 0"); 944 944 } 945 varunitIndex = 0;945 int unitIndex = 0; 946 946 double value = bytes; 947 947 while (value >= 1024 && unitIndex < SIZE_UNITS.length) { … … 967 967 public static String getPositionListString(List<Integer> positionList) { 968 968 Collections.sort(positionList); 969 final var sb = new StringBuilder(32);969 final StringBuilder sb = new StringBuilder(32); 970 970 sb.append(positionList.get(0)); 971 varcnt = 0;971 int cnt = 0; 972 972 int last = positionList.get(0); 973 for ( vari = 1; i < positionList.size(); ++i) {973 for (int i = 1; i < positionList.size(); ++i) { 974 974 int cur = positionList.get(i); 975 975 if (cur == last + 1) { … … 1030 1030 */ 1031 1031 public static Throwable getRootCause(Throwable t) { 1032 varresult = t;1032 Throwable result = t; 1033 1033 if (result != null) { 1034 varcause = result.getCause();1034 Throwable cause = result.getCause(); 1035 1035 while (cause != null && !cause.equals(result)) { 1036 1036 result = cause; … … 1050 1050 */ 1051 1051 public static <T> T[] addInArrayCopy(T[] array, T item) { 1052 varbiggerCopy = Arrays.copyOf(array, array.length + 1);1052 T[] biggerCopy = Arrays.copyOf(array, array.length + 1); 1053 1053 biggerCopy[array.length] = item; 1054 1054 return biggerCopy; … … 1063 1063 */ 1064 1064 public static String shortenString(String s, int maxLength) { 1065 final varellipses = "...";1065 final String ellipses = "..."; 1066 1066 CheckParameterUtil.ensureThat(maxLength >= ellipses.length(), "maxLength is shorter than " + ellipses.length()); 1067 1067 if (s != null && s.length() > maxLength) { … … 1101 1101 if (elements.size() > maxElements) { 1102 1102 final Collection<T> r = new ArrayList<>(maxElements); 1103 final varit = elements.iterator();1103 final Iterator<T> it = elements.iterator(); 1104 1104 while (r.size() < maxElements - 1) { 1105 1105 r.add(it.next()); … … 1126 1126 return url; 1127 1127 1128 final varquery = url.substring(url.indexOf('?') + 1);1129 1130 final var sb = new StringBuilder(url.substring(0, url.indexOf('?') + 1));1131 1132 for ( vari = 0; i < query.length(); i++) {1133 final varc = query.substring(i, i + 1);1128 final String query = url.substring(url.indexOf('?') + 1); 1129 1130 final StringBuilder sb = new StringBuilder(url.substring(0, url.indexOf('?') + 1)); 1131 1132 for (int i = 0; i < query.length(); i++) { 1133 final String c = query.substring(i, i + 1); 1134 1134 if (URL_CHARS.contains(c)) { 1135 1135 sb.append(c); … … 1152 1152 */ 1153 1153 public static String encodeUrl(String s) { 1154 final varenc = StandardCharsets.UTF_8.name();1154 final String enc = StandardCharsets.UTF_8.name(); 1155 1155 try { 1156 1156 return URLEncoder.encode(s, enc); … … 1172 1172 */ 1173 1173 public static String decodeUrl(String s) { 1174 final varenc = StandardCharsets.UTF_8.name();1174 final String enc = StandardCharsets.UTF_8.name(); 1175 1175 try { 1176 1176 return URLDecoder.decode(s, enc); … … 1220 1220 @Override 1221 1221 public Thread newThread(final Runnable runnable) { 1222 final varthread = new Thread(runnable, String.format(Locale.ENGLISH, nameFormat, count.getAndIncrement()));1222 final Thread thread = new Thread(runnable, String.format(Locale.ENGLISH, nameFormat, count.getAndIncrement())); 1223 1223 thread.setPriority(threadPriority); 1224 1224 return thread; … … 1298 1298 public static boolean isSimilar(String string1, String string2) { 1299 1299 // check plain strings 1300 vardistance = getLevenshteinDistance(string1, string2);1300 int distance = getLevenshteinDistance(string1, string2); 1301 1301 1302 1302 // check if only the case differs, so we don't consider large distance as different strings … … 1339 1339 } 1340 1340 1341 for ( varlength : values) {1341 for (double length : values) { 1342 1342 standardDeviation += Math.pow(length - mean, 2); 1343 1343 } … … 1360 1360 } 1361 1361 List<int[]> groups = new ArrayList<>(); 1362 var current = new int[]{Integer.MIN_VALUE, Integer.MIN_VALUE};1362 int[] current = {Integer.MIN_VALUE, Integer.MIN_VALUE}; 1363 1363 groups.add(current); 1364 for ( varrow : integers) {1364 for (int row : integers) { 1365 1365 if (current[0] == Integer.MIN_VALUE) { 1366 1366 current[0] = row; … … 1397 1397 @SuppressWarnings("ThreadPriorityCheck") 1398 1398 public static ForkJoinPool newForkJoinPool(String pref, final String nameFormat, final int threadPriority) { 1399 final varnoThreads = Config.getPref().getInt(pref, Runtime.getRuntime().availableProcessors());1399 final int noThreads = Config.getPref().getInt(pref, Runtime.getRuntime().availableProcessors()); 1400 1400 return new ForkJoinPool(noThreads, new ForkJoinPool.ForkJoinWorkerThreadFactory() { 1401 1401 final AtomicLong count = new AtomicLong(0); … … 1467 1467 if (value != null) { 1468 1468 try { 1469 varold = System.setProperty(key, value);1469 String old = System.setProperty(key, value); 1470 1470 if (Logging.isDebugEnabled() && !value.equals(old)) { 1471 1471 if (!key.toLowerCase(Locale.ENGLISH).contains("password")) { … … 1493 1493 */ 1494 1494 public static boolean hasExtension(String filename, String... extensions) { 1495 varname = filename.toLowerCase(Locale.ENGLISH).replace("?format=raw", "");1495 String name = filename.toLowerCase(Locale.ENGLISH).replace("?format=raw", ""); 1496 1496 return Arrays.stream(extensions) 1497 1497 .anyMatch(ext -> name.endsWith('.' + ext.toLowerCase(Locale.ENGLISH))); … … 1516 1516 * @return byte array of data in input stream (empty if stream is null) 1517 1517 * @throws IOException if any I/O error occurs 1518 */ 1518 * @deprecated since xxx -- use {@link InputStream#readAllBytes()} instead 1519 */ 1520 @Deprecated 1519 1521 public static byte[] readBytesFromStream(InputStream stream) throws IOException { 1520 // TODO: remove this method when switching to Java 11 and use InputStream.readAllBytes1521 1522 if (stream == null) { 1522 1523 return new byte[0]; 1523 1524 } 1524 try (stream; var bout = new ByteArrayOutputStream(stream.available())) { 1525 final var buffer = new byte[8192]; 1526 var finished = false; 1527 do { 1528 var read = stream.read(buffer); 1529 if (read >= 0) { 1530 bout.write(buffer, 0, read); 1531 } else { 1532 finished = true; 1533 } 1534 } while (!finished); 1535 if (bout.size() == 0) 1536 return new byte[0]; 1537 return bout.toByteArray(); 1538 } 1525 return stream.readAllBytes(); 1539 1526 } 1540 1527 … … 1600 1587 */ 1601 1588 public static List<GlyphVector> getGlyphVectorsBidi(String string, Font font, FontRenderContext frc) { 1602 final var gvs = new ArrayList<GlyphVector>();1603 final varbidi = new Bidi(string, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT);1604 final varlevels = new byte[bidi.getRunCount()];1605 final vardirStrings = new DirectionString[levels.length];1606 for ( vari = 0; i < levels.length; ++i) {1589 final List<GlyphVector> gvs = new ArrayList<>(); 1590 final Bidi bidi = new Bidi(string, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); 1591 final byte[] levels = new byte[bidi.getRunCount()]; 1592 final DirectionString[] dirStrings = new DirectionString[levels.length]; 1593 for (int i = 0; i < levels.length; ++i) { 1607 1594 levels[i] = (byte) bidi.getRunLevel(i); 1608 final varsubstr = string.substring(bidi.getRunStart(i), bidi.getRunLimit(i));1609 final vardir = levels[i] % 2 == 0 ? Bidi.DIRECTION_LEFT_TO_RIGHT : Bidi.DIRECTION_RIGHT_TO_LEFT;1595 final String substr = string.substring(bidi.getRunStart(i), bidi.getRunLimit(i)); 1596 final int dir = levels[i] % 2 == 0 ? Bidi.DIRECTION_LEFT_TO_RIGHT : Bidi.DIRECTION_RIGHT_TO_LEFT; 1610 1597 dirStrings[i] = new DirectionString(dir, substr); 1611 1598 } 1612 1599 Bidi.reorderVisually(levels, 0, dirStrings, 0, levels.length); 1613 for ( vardirString : dirStrings) {1614 varchars = dirString.str.toCharArray();1600 for (DirectionString dirString : dirStrings) { 1601 final char[] chars = dirString.str.toCharArray(); 1615 1602 gvs.add(font.layoutGlyphVector(frc, chars, 0, chars.length, dirString.direction)); 1616 1603 } … … 1709 1696 public static int getJavaVersion() { 1710 1697 // Switch to Runtime.version() once we move past Java 8 1711 varversion = Objects.requireNonNull(getSystemProperty("java.version"));1698 String version = Objects.requireNonNull(getSystemProperty("java.version")); 1712 1699 if (version.startsWith("1.")) { 1713 1700 version = version.substring(2); … … 1718 1705 // 9 1719 1706 // 9.0.1 1720 vardotPos = version.indexOf('.');1721 vardashPos = version.indexOf('-');1707 int dotPos = version.indexOf('.'); 1708 int dashPos = version.indexOf('-'); 1722 1709 return Integer.parseInt(version.substring(0, 1723 1710 dotPos > -1 ? dotPos : dashPos > -1 ? dashPos : version.length())); … … 1731 1718 public static int getJavaUpdate() { 1732 1719 // Switch to Runtime.version() once we move past Java 8 1733 varversion = Objects.requireNonNull(getSystemProperty("java.version"));1720 String version = Objects.requireNonNull(getSystemProperty("java.version")); 1734 1721 if (version.startsWith("1.")) { 1735 1722 version = version.substring(2); … … 1742 1729 // 17.0.4.1+1-LTS 1743 1730 // $MAJOR.$MINOR.$SECURITY.$PATCH 1744 varundePos = version.indexOf('_');1745 vardashPos = version.indexOf('-');1731 int undePos = version.indexOf('_'); 1732 int dashPos = version.indexOf('-'); 1746 1733 if (undePos > -1) { 1747 1734 return Integer.parseInt(version.substring(undePos + 1, 1748 1735 dashPos > -1 ? dashPos : version.length())); 1749 1736 } 1750 varfirstDotPos = version.indexOf('.');1751 varsecondDotPos = version.indexOf('.', firstDotPos + 1);1737 int firstDotPos = version.indexOf('.'); 1738 int secondDotPos = version.indexOf('.', firstDotPos + 1); 1752 1739 if (firstDotPos == secondDotPos) { 1753 1740 return 0; … … 1764 1751 public static int getJavaBuild() { 1765 1752 // Switch to Runtime.version() once we move past Java 8 1766 varversion = Objects.requireNonNull(getSystemProperty("java.runtime.version"));1767 varbPos = version.indexOf('b');1768 varpPos = version.indexOf('+');1753 String version = Objects.requireNonNull(getSystemProperty("java.runtime.version")); 1754 int bPos = version.indexOf('b'); 1755 int pPos = version.indexOf('+'); 1769 1756 try { 1770 1757 return Integer.parseInt(version.substring(bPos > -1 ? bPos + 1 : pPos + 1)); … … 1783 1770 try { 1784 1771 Object value; 1785 varc = Class.forName("com.sun.deploy.config.BuiltInProperties");1772 Class<?> c = Class.forName("com.sun.deploy.config.BuiltInProperties"); 1786 1773 try { 1787 1774 value = c.getDeclaredField("JRE_EXPIRATION_DATE").get(null); … … 1807 1794 public static String getJavaLatestVersion() { 1808 1795 try { 1809 varversions = HttpClient.create(1796 String[] versions = HttpClient.create( 1810 1797 new URL(Config.getPref().get( 1811 1798 "java.baseline.version.url", … … 1813 1800 .connect().fetchContent().split("\n", -1); 1814 1801 if (getJavaVersion() <= 11 && isRunningWebStart()) { // OpenWebStart currently only has Java 11 1815 for ( varversion : versions) {1802 for (String version : versions) { 1816 1803 if (version.startsWith("11")) { 1817 1804 return version; … … 1819 1806 } 1820 1807 } else if (getJavaVersion() <= 17) { 1821 for ( varversion : versions) {1808 for (String version : versions) { 1822 1809 if (version.startsWith("17")) { // Use current Java LTS 1823 1810 return version; … … 1942 1929 return url.openStream(); 1943 1930 } catch (FileNotFoundException | InvalidPathException e) { 1944 final varbetterUrl = betterJarUrl(url);1931 final URL betterUrl = betterJarUrl(url); 1945 1932 if (betterUrl != null) { 1946 1933 try { … … 1979 1966 public static URL betterJarUrl(URL jarUrl, URL defaultUrl) throws IOException { 1980 1967 // Workaround to https://bugs.openjdk.java.net/browse/JDK-4523159 1981 varurlPath = jarUrl.getPath().replace("%20", " ");1968 String urlPath = jarUrl.getPath().replace("%20", " "); 1982 1969 if (urlPath.startsWith("file:/") && urlPath.split("!", -1).length > 2) { 1983 1970 // Locate jar file 1984 varindex = urlPath.lastIndexOf("!/");1985 final varjarFile = Paths.get(urlPath.substring("file:/".length(), index));1986 varfilename = jarFile.getFileName();1987 varjarTime = Files.readAttributes(jarFile, BasicFileAttributes.class).lastModifiedTime();1971 int index = urlPath.lastIndexOf("!/"); 1972 final Path jarFile = Paths.get(urlPath.substring("file:/".length(), index)); 1973 Path filename = jarFile.getFileName(); 1974 FileTime jarTime = Files.readAttributes(jarFile, BasicFileAttributes.class).lastModifiedTime(); 1988 1975 // Copy it to temp directory (hopefully free of exclamation mark) if needed (missing or older jar) 1989 final varjarCopy = Paths.get(getSystemProperty("java.io.tmpdir")).resolve(filename);1976 final Path jarCopy = Paths.get(getSystemProperty("java.io.tmpdir")).resolve(filename); 1990 1977 if (!jarCopy.toFile().exists() || 1991 1978 Files.readAttributes(jarCopy, BasicFileAttributes.class).lastModifiedTime().compareTo(jarTime) < 0) { … … 2026 2013 Logging.trace(e); 2027 2014 try { 2028 final varbetterUrl = betterJarUrl(cl.getResource(path));2015 final URL betterUrl = betterJarUrl(cl.getResource(path)); 2029 2016 if (betterUrl != null) { 2030 2017 return betterUrl.openStream(); -
trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java
r18796 r19050 65 65 } 66 66 67 private class Parser extends DefaultHandler {67 private final class Parser extends DefaultHandler { 68 68 private final Stack<Object> current = new Stack<>(); 69 69 private StringBuilder characters = new StringBuilder(64); … … 78 78 } 79 79 80 protectedvoid throwException(Exception e) throws XmlParsingException {80 void throwException(Exception e) throws XmlParsingException { 81 81 throw new XmlParsingException(e).rememberLocation(locator); 82 82 } -
trunk/src/org/openstreetmap/josm/tools/bugreport/BugReportQueue.java
r16916 r19050 89 89 } 90 90 91 private class BugReportDisplayRunnable implements Runnable {91 private final class BugReportDisplayRunnable implements Runnable { 92 92 93 93 private volatile boolean running = true; -
trunk/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java
r18888 r19050 180 180 } 181 181 182 private static class PerformanceTester {182 private static final class PerformanceTester { 183 183 public double scale = 0; 184 184 public LatLon center = LL_CITY; -
trunk/test/unit/org/openstreetmap/josm/actions/UploadActionTest.java
r18870 r19050 85 85 } 86 86 87 private static class UploadDialogMock extends MockUp<UploadDialog> {87 private static final class UploadDialogMock extends MockUp<UploadDialog> { 88 88 @Mock 89 89 public void pack(final Invocation invocation) { … … 101 101 102 102 @Mock 103 public finalboolean isCanceled(final Invocation invocation) {103 public boolean isCanceled(final Invocation invocation) { 104 104 if (!GraphicsEnvironment.isHeadless()) { 105 105 return Boolean.TRUE.equals(invocation.proceed()); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyActionTest.java
r18965 r19050 51 51 private static final int HEIGHT = 600; 52 52 53 private static class AlwaysDeleteCallback implements DeleteCommand.DeletionCallback {53 private static final class AlwaysDeleteCallback implements DeleteCommand.DeletionCallback { 54 54 @Override 55 55 public boolean checkAndConfirmOutlyingDelete(Collection<? extends OsmPrimitive> primitives, Collection<? extends OsmPrimitive> ignore) { -
trunk/test/unit/org/openstreetmap/josm/actions/upload/UploadNotesTaskTest.java
r18870 r19050 157 157 } 158 158 159 private static class FakeOsmApiMocker extends MockUp<FakeOsmApi> {159 private static final class FakeOsmApiMocker extends MockUp<FakeOsmApi> { 160 160 Collection<Note> closed = new ArrayList<>(); 161 161 Collection<Note> commented = new ArrayList<>(); -
trunk/test/unit/org/openstreetmap/josm/command/CommandTest.java
r18037 r19050 4 4 import java.util.Arrays; 5 5 6 import org.junit.jupiter.api.Test; 6 7 import org.openstreetmap.josm.TestUtils; 7 8 import org.openstreetmap.josm.data.coor.LatLon; … … 19 20 import nl.jqno.equalsverifier.EqualsVerifier; 20 21 import nl.jqno.equalsverifier.Warning; 21 import org.junit.jupiter.api.Test;22 22 23 23 /** … … 100 100 * @return The way. 101 101 */ 102 public Way createWay(int id, Node... nodes) {102 public Way createWay(int id, Node... nodes) { 103 103 Way way = new Way(); 104 104 way.setOsmId(id, 1); … … 115 115 * @return The relation. 116 116 */ 117 public Relation createRelation(int id, RelationMember... members) {117 public Relation createRelation(int id, RelationMember... members) { 118 118 Relation relation = new Relation(id, 1); 119 119 for (RelationMember member : members) { -
trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJobTest.java
r18106 r19050 85 85 } 86 86 87 private static class Listener implements ICachedLoaderListener {87 private static final class Listener implements ICachedLoaderListener { 88 88 private CacheEntryAttributes attributes; 89 89 private boolean ready; … … 513 513 */ 514 514 @Test 515 publicvoid testCheckUsing304() throws IOException {515 void testCheckUsing304() throws IOException { 516 516 ICacheAccess<String, CacheEntry> cache = getCache(); 517 517 long expires = TimeUnit.DAYS.toMillis(1); -
trunk/test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java
r18870 r19050 457 457 } 458 458 459 private static class TestChangeListener implements GpxDataChangeListener {459 private static final class TestChangeListener implements GpxDataChangeListener { 460 460 461 461 private GpxDataChangeEvent lastEvent; -
trunk/test/unit/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJobTest.java
r18106 r19050 99 99 } 100 100 101 private static class Listener implements TileLoaderListener {101 private static final class Listener implements TileLoaderListener { 102 102 private CacheEntryAttributes attributes; 103 103 private boolean ready; -
trunk/test/unit/org/openstreetmap/josm/data/imagery/vectortile/mapbox/MapboxVectorTileSourceTest.java
r18766 r19050 27 27 */ 28 28 class MapboxVectorTileSourceTest implements TileSourceTest { 29 private static class SelectLayerDialogMocker extends ExtendedDialogMocker {29 private static final class SelectLayerDialogMocker extends ExtendedDialogMocker { 30 30 int index; 31 31 @Override -
trunk/test/unit/org/openstreetmap/josm/data/oauth/OAuth20AuthorizationTest.java
r18991 r19050 17 17 import java.util.stream.Stream; 18 18 19 import com.github.tomakehurst.wiremock.client.WireMock;20 import com.github.tomakehurst.wiremock.common.FileSource;21 import com.github.tomakehurst.wiremock.core.WireMockConfiguration;22 import com.github.tomakehurst.wiremock.extension.Parameters;23 import com.github.tomakehurst.wiremock.extension.ResponseTransformer;24 import com.github.tomakehurst.wiremock.http.FixedDelayDistribution;25 import com.github.tomakehurst.wiremock.http.HttpHeader;26 import com.github.tomakehurst.wiremock.http.HttpHeaders;27 import com.github.tomakehurst.wiremock.http.QueryParameter;28 import com.github.tomakehurst.wiremock.http.Request;29 import com.github.tomakehurst.wiremock.http.Response;30 import com.github.tomakehurst.wiremock.junit5.WireMockExtension;31 import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;32 import com.github.tomakehurst.wiremock.matching.AnythingPattern;33 import com.github.tomakehurst.wiremock.matching.EqualToPattern;34 import com.github.tomakehurst.wiremock.matching.StringValuePattern;35 import mockit.Mock;36 import mockit.MockUp;37 19 import org.junit.jupiter.api.AfterEach; 38 20 import org.junit.jupiter.api.BeforeEach; … … 50 32 import org.openstreetmap.josm.tools.Logging; 51 33 34 import com.github.tomakehurst.wiremock.client.WireMock; 35 import com.github.tomakehurst.wiremock.core.WireMockConfiguration; 36 import com.github.tomakehurst.wiremock.extension.ResponseTransformerV2; 37 import com.github.tomakehurst.wiremock.http.FixedDelayDistribution; 38 import com.github.tomakehurst.wiremock.http.HttpHeader; 39 import com.github.tomakehurst.wiremock.http.HttpHeaders; 40 import com.github.tomakehurst.wiremock.http.QueryParameter; 41 import com.github.tomakehurst.wiremock.http.Request; 42 import com.github.tomakehurst.wiremock.http.Response; 43 import com.github.tomakehurst.wiremock.junit5.WireMockExtension; 44 import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo; 45 import com.github.tomakehurst.wiremock.matching.AnythingPattern; 46 import com.github.tomakehurst.wiremock.matching.EqualToPattern; 47 import com.github.tomakehurst.wiremock.matching.StringValuePattern; 48 import com.github.tomakehurst.wiremock.stubbing.ServeEvent; 49 import mockit.Mock; 50 import mockit.MockUp; 51 52 52 @BasicPreferences 53 53 @HTTP … … 70 70 } 71 71 72 private static class OAuthServerWireMock extends ResponseTransformer{72 private static final class OAuthServerWireMock implements ResponseTransformerV2 { 73 73 String stateToReturn; 74 74 ConnectionProblems connectionProblems = ConnectionProblems.NONE; 75 75 76 @Override 76 public Response transform(Request request, Response response, FileSource files, Parameters parameters) { 77 public Response transform(Response response, ServeEvent serveEvent) { 78 final var request = serveEvent.getRequest(); 77 79 try { 78 80 if (request.getUrl().startsWith("/oauth2/authorize")) { … … 158 160 /** 159 161 * Set up the default wiremock information 160 * @param wireMockRuntimeInfo The info to set up161 162 */ 162 163 @BeforeEach 163 void setupWireMock(WireMockRuntimeInfo wireMockRuntimeInfo) { 164 void setupWireMock() { 165 final WireMockRuntimeInfo wireMockRuntimeInfo = wml.getRuntimeInfo(); 164 166 Config.getPref().put("osm-server.url", wireMockRuntimeInfo.getHttpBaseUrl() + "/api/"); 165 167 new MockUp<JosmUrls>() { … … 195 197 196 198 @Test 197 void testAuthorize( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {199 void testAuthorize() throws IOException { 198 200 final AtomicReference<Optional<IOAuthToken>> consumer = new AtomicReference<>(); 199 final HttpClient client = generateClient(w ireMockRuntimeInfo, consumer);201 final HttpClient client = generateClient(wml.getRuntimeInfo(), consumer); 200 202 try { 201 203 HttpClient.Response response = client.connect(); … … 212 214 213 215 @Test 214 void testAuthorizeBadState( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {216 void testAuthorizeBadState() throws IOException { 215 217 oauthServer.stateToReturn = "Bad_State"; 216 218 final AtomicReference<Optional<IOAuthToken>> consumer = new AtomicReference<>(); 217 final HttpClient client = generateClient(w ireMockRuntimeInfo, consumer);219 final HttpClient client = generateClient(wml.getRuntimeInfo(), consumer); 218 220 try { 219 221 HttpClient.Response response = client.connect(); … … 228 230 229 231 @Test 230 void testSocketTimeout( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {232 void testSocketTimeout() throws Exception { 231 233 // 1s before timeout 232 234 Config.getPref().putInt("socket.timeout.connect", 1); … … 235 237 236 238 final AtomicReference<Optional<IOAuthToken>> consumer = new AtomicReference<>(); 237 final HttpClient client = generateClient(w ireMockRuntimeInfo, consumer)239 final HttpClient client = generateClient(wml.getRuntimeInfo(), consumer) 238 240 .setConnectTimeout(15_000).setReadTimeout(30_000); 239 241 try { -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r18870 r19050 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.data.projection; 3 4 import static org.junit.jupiter.api.Assertions.fail; 3 5 4 6 import java.io.BufferedReader; … … 45 47 private static final String PROJECTION_DATA_FILE = "nodist/data/projection/projection-regression-test-data"; 46 48 47 private static class TestData {49 private static final class TestData { 48 50 public String code; 49 51 public LatLon ll; … … 185 187 if (fail.length() > 0) { 186 188 System.err.println(fail); 187 throw new AssertionError(fail.toString());189 fail(fail.toString()); 188 190 } 189 191 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java
r18866 r19050 324 324 } 325 325 326 private static class PasteMembersActionMock extends MockUp<PasteMembersAction> {326 private static final class PasteMembersActionMock extends MockUp<PasteMembersAction> { 327 327 @Mock 328 p rotectedvoid updateEnabledState() {328 public void updateEnabledState() { 329 329 // Do nothing 330 330 } -
trunk/test/unit/org/openstreetmap/josm/gui/io/SaveLayersDialogTest.java
r19011 r19050 162 162 } 163 163 164 private static class GraphicsEnvironmentMock extends MockUp<GraphicsEnvironment> {164 private static final class GraphicsEnvironmentMock extends MockUp<GraphicsEnvironment> { 165 165 @Mock 166 166 public static boolean isHeadless(Invocation invocation) { … … 169 169 } 170 170 171 private static class SaveLayersDialogMock extends MockUp<SaveLayersDialog> {171 private static final class SaveLayersDialogMock extends MockUp<SaveLayersDialog> { 172 172 private final SaveLayersModel model = new SaveLayersModel(); 173 173 private int getUserActionCalled = 0; -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
r18694 r19050 19 19 import javax.swing.JOptionPane; 20 20 21 import com.github.tomakehurst.wiremock.client.WireMock;22 import com.github.tomakehurst.wiremock.junit5.WireMockExtension;23 import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;24 import mockit.MockUp;25 21 import org.awaitility.Awaitility; 26 22 import org.junit.jupiter.api.AfterEach; … … 44 40 import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker; 45 41 42 import com.github.tomakehurst.wiremock.client.WireMock; 43 import com.github.tomakehurst.wiremock.junit5.WireMockExtension; 44 import mockit.MockUp; 45 46 46 /** 47 47 * Higher level tests of {@link PluginPreference} class. … … 132 132 */ 133 133 @Test 134 void testInstallWithoutUpdate( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {134 void testInstallWithoutUpdate() throws Exception { 135 135 final PluginServer pluginServer = new PluginServer( 136 136 new PluginServer.RemotePlugin(this.referenceDummyJarNew), … … 138 138 new PluginServer.RemotePlugin(null, Collections.singletonMap("Plugin-Version", "2"), "irrelevant_plugin") 139 139 ); 140 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);140 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 141 141 Config.getPref().putList("plugins", Collections.singletonList("dummy_plugin")); 142 142 … … 238 238 */ 239 239 @Test 240 void testDisablePluginWithUpdatesAvailable( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {240 void testDisablePluginWithUpdatesAvailable() throws Exception { 241 241 final PluginServer pluginServer = new PluginServer( 242 242 new PluginServer.RemotePlugin(this.referenceDummyJarNew), … … 244 244 new PluginServer.RemotePlugin(null, null, "irrelevant_plugin") 245 245 ); 246 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);246 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 247 247 Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin")); 248 248 … … 346 346 */ 347 347 @Test 348 void testUpdateOnlySelectedPlugin( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {348 void testUpdateOnlySelectedPlugin() throws Exception { 349 349 TestUtils.assumeWorkingJMockit(); 350 350 final PluginServer pluginServer = new PluginServer( … … 352 352 new PluginServer.RemotePlugin(this.referenceBazJarNew) 353 353 ); 354 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);354 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 355 355 Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin")); 356 356 … … 516 516 */ 517 517 @Test 518 void testUpdateWithNoAvailableUpdates( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {518 void testUpdateWithNoAvailableUpdates() throws Exception { 519 519 TestUtils.assumeWorkingJMockit(); 520 520 final PluginServer pluginServer = new PluginServer( … … 523 523 new PluginServer.RemotePlugin(null, Collections.singletonMap("Plugin-Version", "123"), "irrelevant_plugin") 524 524 ); 525 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);525 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 526 526 Config.getPref().putList("plugins", Arrays.asList("baz_plugin", "dummy_plugin")); 527 527 … … 644 644 */ 645 645 @Test 646 void testInstallWithoutRestartRequired( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {646 void testInstallWithoutRestartRequired() throws Exception { 647 647 TestUtils.assumeWorkingJMockit(); 648 648 final boolean[] loadPluginsCalled = new boolean[] {false}; … … 665 665 new PluginServer.RemotePlugin(this.referenceBazJarNew) 666 666 ); 667 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);667 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 668 668 Config.getPref().putList("plugins", Collections.emptyList()); 669 669 … … 756 756 @AssumeRevision("Revision: 7000\n") 757 757 @Test 758 void testInstallMultiVersion( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {758 void testInstallMultiVersion() throws Exception { 759 759 TestUtils.assumeWorkingJMockit(); 760 760 … … 766 766 )) 767 767 ); 768 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);768 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 769 769 // need to actually serve this older jar from somewhere 770 770 pluginServerRule.stubFor( -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AuthorizationHandlerTest.java
r18650 r19050 20 20 */ 21 21 class AuthorizationHandlerTest { 22 private static class TestAuthorizationConsumer implements AuthorizationHandler.AuthorizationConsumer {22 private static final class TestAuthorizationConsumer implements AuthorizationHandler.AuthorizationConsumer { 23 23 boolean validated; 24 24 boolean handled; -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java
r18870 r19050 34 34 import com.github.tomakehurst.wiremock.client.WireMock; 35 35 import com.github.tomakehurst.wiremock.junit5.WireMockExtension; 36 import com.github.tomakehurst.wiremock.junit5.WireMockRuntimeInfo;37 36 38 37 /** … … 110 109 */ 111 110 @Test 112 void testUpdatePluginsDownloadBoth( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {111 void testUpdatePluginsDownloadBoth() throws IOException { 113 112 TestUtils.assumeWorkingJMockit(); 114 113 final PluginServer pluginServer = new PluginServer( … … 116 115 new PluginServer.RemotePlugin(this.referenceBazJarNew) 117 116 ); 118 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);117 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 119 118 Config.getPref().putList("plugins", Arrays.asList("dummy_plugin", "baz_plugin")); 120 119 … … 172 171 */ 173 172 @Test 174 void testUpdatePluginsSkipOne( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {173 void testUpdatePluginsSkipOne() throws IOException { 175 174 TestUtils.assumeWorkingJMockit(); 176 175 final PluginServer pluginServer = new PluginServer( … … 178 177 new PluginServer.RemotePlugin(this.referenceBazJarNew) 179 178 ); 180 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);179 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 181 180 Config.getPref().putList("plugins", Arrays.asList("dummy_plugin", "baz_plugin")); 182 181 … … 244 243 */ 245 244 @Test 246 void testUpdatePluginsUnexpectedlyJOSMTooOld( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {245 void testUpdatePluginsUnexpectedlyJOSMTooOld() throws IOException { 247 246 TestUtils.assumeWorkingJMockit(); 248 247 final PluginServer pluginServer = new PluginServer( … … 250 249 new PluginServer.RemotePlugin(this.referenceBazJarNew, Collections.singletonMap("Plugin-Mainversion", "5500")) 251 250 ); 252 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);251 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 253 252 Config.getPref().putList("plugins", Collections.singletonList("baz_plugin")); 254 253 … … 299 298 @Test 300 299 @AssumeRevision("Revision: 7200\n") 301 void testUpdatePluginsMultiVersionInsufficient( WireMockRuntimeInfo wireMockRuntimeInfo) throws IOException {300 void testUpdatePluginsMultiVersionInsufficient() throws IOException { 302 301 TestUtils.assumeWorkingJMockit(); 303 302 … … 308 307 )) 309 308 ); 310 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);309 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 311 310 Config.getPref().putList("plugins", Arrays.asList("qux_plugin", "baz_plugin")); 312 311 -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java
r18870 r19050 91 91 @AssumeRevision("Revision: 7501\n") 92 92 @Test 93 void testUpdatePluginsOneMultiVersion( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {93 void testUpdatePluginsOneMultiVersion() throws Exception { 94 94 TestUtils.assumeWorkingJMockit(); 95 95 96 96 final String quxNewerServePath = "/qux/newer.jar"; 97 final Map<String, String> attrOverrides = new HashMap< String, String>() {{97 final Map<String, String> attrOverrides = new HashMap<>() {{ 98 98 put("7500_Plugin-Url", "432;" + pluginServerRule.url(quxNewerServePath)); 99 99 put("7499_Plugin-Url", "346;" + pluginServerRule.url("/not/served.jar")); … … 104 104 new PluginServer.RemotePlugin(this.referenceQuxJarNewest, attrOverrides) 105 105 ); 106 final WireMockRuntimeInfo wireMockRuntimeInfo = pluginServerRule.getRuntimeInfo(); 106 107 pluginServer.applyToWireMockServer(wireMockRuntimeInfo); 107 108 // need to actually serve this older jar from somewhere … … 158 159 @AssumeRevision("Revision: 7000\n") 159 160 @Test 160 void testUpdatePluginsExistingVersionLatestPossible( WireMockRuntimeInfo wireMockRuntimeInfo) throws Exception {161 void testUpdatePluginsExistingVersionLatestPossible() throws Exception { 161 162 TestUtils.assumeWorkingJMockit(); 162 163 163 final Map<String, String> attrOverrides = new HashMap< String, String>() {{164 final Map<String, String> attrOverrides = new HashMap<>() {{ 164 165 put("7500_Plugin-Url", "432;" + pluginServerRule.url("/dont.jar")); 165 166 put("7499_Plugin-Url", "346;" + pluginServerRule.url("/even.jar")); … … 170 171 new PluginServer.RemotePlugin(this.referenceQuxJarNewest, attrOverrides) 171 172 ); 172 pluginServer.applyToWireMockServer( wireMockRuntimeInfo);173 pluginServer.applyToWireMockServer(pluginServerRule.getRuntimeInfo()); 173 174 Config.getPref().putList("plugins", Arrays.asList("qux_plugin", "baz_plugin")); 174 175 -
trunk/test/unit/org/openstreetmap/josm/spi/lifecycle/LifecycleTest.java
r18893 r19050 19 19 @Projection 20 20 class LifecycleTest { 21 private static class InitStatusListenerStub implements InitStatusListener {21 private static final class InitStatusListenerStub implements InitStatusListener { 22 22 23 23 boolean updated; -
trunk/test/unit/org/openstreetmap/josm/tools/LanguageInfoTest.java
r18870 r19050 46 46 } 47 47 48 private static void testGetWikiLanguagePrefixes(LanguageInfo.LocaleType type, String... expected) {48 private static void testGetWikiLanguagePrefixes(LanguageInfo.LocaleType type, String... expected) { 49 49 final List<String> actual = Stream.of(EN_NZ, DE_DE, PT_BR, CA_ES_VALENCIA, ZN_CN, ZN_TW, AST, EN_GB, RU, NB) 50 50 .map(locale -> LanguageInfo.getWikiLanguagePrefix(locale, type))
Note:
See TracChangeset
for help on using the changeset viewer.