Changeset 19048 in josm for trunk/src/org/openstreetmap/josm/actions
- Timestamp:
- 2024-04-19T16:21:11+02:00 (2 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/actions
- Files:
-
- 6 edited
-
AddImageryLayerAction.java (modified) (13 diffs)
-
AutoScaleAction.java (modified) (10 diffs)
-
ChangesetManagerToggleAction.java (modified) (1 diff)
-
DownloadOsmInViewAction.java (modified) (1 diff)
-
JoinAreasAction.java (modified) (42 diffs)
-
SplitWayAction.java (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r18628 r19048 7 7 import java.awt.Dimension; 8 8 import java.awt.GraphicsEnvironment; 9 import java.awt.GridBagConstraints; 9 10 import java.awt.GridBagLayout; 10 11 import java.awt.event.ActionEvent; … … 14 15 import java.time.Year; 15 16 import java.time.ZoneOffset; 16 import java.util.Collection;17 17 import java.util.Collections; 18 18 import java.util.List; … … 26 26 import javax.swing.JScrollPane; 27 27 28 import org.openstreetmap.josm.data.coor.LatLon;29 import org.openstreetmap.josm.data.imagery.DefaultLayer;30 28 import org.openstreetmap.josm.data.imagery.ImageryInfo; 31 29 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; … … 62 60 SelectWmsLayersDialog(WMSLayerTree tree, JComboBox<String> formats) { 63 61 super(MainApplication.getMainFrame(), tr("Select WMS layers"), tr("Add layers"), tr("Cancel")); 64 final JScrollPanescrollPane = new JScrollPane(tree.getLayerTree());62 final var scrollPane = new JScrollPane(tree.getLayerTree()); 65 63 scrollPane.setPreferredSize(new Dimension(400, 400)); 66 final JPanelpanel = new JPanel(new GridBagLayout());64 final var panel = new JPanel(new GridBagLayout()); 67 65 panel.add(scrollPane, GBC.eol().fill()); 68 panel.add(formats, GBC.eol().fill(G BC.HORIZONTAL));66 panel.add(formats, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 69 67 setContent(panel); 70 68 } … … 84 82 85 83 // change toolbar icon from if specified 86 Stringicon = info.getIcon();84 var icon = info.getIcon(); 87 85 if (icon != null) { 88 86 new ImageProvider(icon).setOptional(true).getResourceAsync(result -> { … … 103 101 try { 104 102 if (info.getUrl() != null && info.getUrl().contains("{time}")) { 105 final Stringinstant = Year.now(ZoneOffset.UTC).atDay(1).atStartOfDay(ZoneOffset.UTC).toInstant().toString();106 final Stringexample = String.join("/", instant, instant);107 final StringinitialSelectionValue = info.getDate() != null ? info.getDate() : example;108 final StringuserDate = JOptionPane.showInputDialog(MainApplication.getMainFrame(),103 final var instant = Year.now(ZoneOffset.UTC).atDay(1).atStartOfDay(ZoneOffset.UTC).toInstant().toString(); 104 final var example = String.join("/", instant, instant); 105 final var initialSelectionValue = info.getDate() != null ? info.getDate() : example; 106 final var userDate = JOptionPane.showInputDialog(MainApplication.getMainFrame(), 109 107 tr("Time filter for \"{0}\" such as \"{1}\"", info.getName(), example), 110 108 initialSelectionValue); … … 115 113 // TODO persist new {time} value (via ImageryLayerInfo.save?) 116 114 } 117 switch(info.getImageryType()) { 115 switch (info.getImageryType()) { 118 116 case WMS_ENDPOINT: 119 117 // convert to WMS type … … 126 124 // specify which layer to use 127 125 if (Utils.isEmpty(info.getDefaultLayers())) { 128 WMTSTileSourcetileSource = new WMTSTileSource(info);129 DefaultLayer layerId = tileSource.userSelectLayer();126 var tileSource = new WMTSTileSource(info); 127 var layerId = tileSource.userSelectLayer(); 130 128 if (layerId != null) { 131 ImageryInfocopy = new ImageryInfo(info);129 var copy = new ImageryInfo(info); 132 130 copy.setDefaultLayers(Collections.singletonList(layerId)); 133 StringlayerName = tileSource.getLayers().stream()131 var layerName = tileSource.getLayers().stream() 134 132 .filter(x -> x.getIdentifier().equals(layerId.getLayerName())) 135 133 .map(Layer::getUserTitle) … … 165 163 ImageryLayer layer = null; 166 164 try { 167 final ImageryInfoinfoToAdd = convertImagery(info);165 final var infoToAdd = convertImagery(info); 168 166 if (infoToAdd != null) { 169 167 layer = ImageryLayer.create(infoToAdd); … … 207 205 208 206 private static LayerSelection askToSelectLayers(WMSImagery wms) { 209 final WMSLayerTreetree = new WMSLayerTree();210 211 Collection<String>wmsFormats = wms.getFormats();212 final JComboBox<String>formats = new JComboBox<>(wmsFormats.toArray(new String[0]));207 final var tree = new WMSLayerTree(); 208 209 var wmsFormats = wms.getFormats(); 210 final var formats = new JComboBox<String>(wmsFormats.toArray(new String[0])); 213 211 formats.setSelectedItem(wms.getPreferredFormat()); 214 212 formats.setToolTipText(tr("Select image format for WMS layer")); 215 213 216 JCheckBoxcheckBounds = new JCheckBox(tr("Show only layers for current view"), true);214 var checkBounds = new JCheckBox(tr("Show only layers for current view"), true); 217 215 Runnable updateTree = () -> { 218 LatLonlatLon = checkBounds.isSelected() && MainApplication.isDisplayingMapView()216 var latLon = checkBounds.isSelected() && MainApplication.isDisplayingMapView() 219 217 ? MainApplication.getMap().mapView.getProjection().eastNorth2latlon(MainApplication.getMap().mapView.getCenter()) 220 218 : null; … … 227 225 228 226 if (!GraphicsEnvironment.isHeadless()) { 229 ExtendedDialogdialog = new ExtendedDialog(MainApplication.getMainFrame(),227 var dialog = new ExtendedDialog(MainApplication.getMainFrame(), 230 228 tr("Select WMS layers"), tr("Add layers"), tr("Cancel")); 231 final JScrollPanescrollPane = new JScrollPane(tree.getLayerTree());229 final var scrollPane = new JScrollPane(tree.getLayerTree()); 232 230 scrollPane.setPreferredSize(new Dimension(400, 400)); 233 final JPanelpanel = new JPanel(new GridBagLayout());231 final var panel = new JPanel(new GridBagLayout()); 234 232 panel.add(scrollPane, GBC.eol().fill()); 235 panel.add(checkBounds, GBC.eol().fill(G BC.HORIZONTAL));236 panel.add(formats, GBC.eol().fill(G BC.HORIZONTAL));233 panel.add(checkBounds, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 234 panel.add(formats, GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 237 235 dialog.setContent(panel); 238 236 … … 283 281 CheckParameterUtil.ensureThat(ImageryType.WMS_ENDPOINT == info.getImageryType(), "wms_endpoint imagery type expected"); 284 282 // We need to get the URL with {apikey} replaced. See #22642. 285 final TemplatedWMSTileSourcetileSource = new TemplatedWMSTileSource(info, ProjectionRegistry.getProjection());286 final WMSImagerywms = new WMSImagery(tileSource.getBaseUrl(), info.getCustomHttpHeaders());287 LayerSelectionselection = choice.apply(wms);283 final var tileSource = new TemplatedWMSTileSource(info, ProjectionRegistry.getProjection()); 284 final var wms = new WMSImagery(tileSource.getBaseUrl(), info.getCustomHttpHeaders()); 285 var selection = choice.apply(wms); 288 286 if (selection == null) { 289 287 return null; 290 288 } 291 289 292 final Stringurl = wms.buildGetMapUrl(290 final var url = wms.buildGetMapUrl( 293 291 selection.layers.stream().map(LayerDetails::getName).collect(Collectors.toList()), 294 292 (List<String>) null, … … 297 295 ); 298 296 299 StringselectedLayers = selection.layers.stream()297 var selectedLayers = selection.layers.stream() 300 298 .map(LayerDetails::getName) 301 299 .collect(Collectors.joining(", ")); 302 300 // Use full copy of original Imagery info to copy all attributes. Only overwrite what's different 303 ImageryInforet = new ImageryInfo(info);301 var ret = new ImageryInfo(info); 304 302 ret.setUrl(url); 305 303 ret.setImageryType(ImageryType.WMS); -
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r18211 r19048 8 8 import java.awt.event.ActionEvent; 9 9 import java.awt.event.KeyEvent; 10 import java.awt.geom.Area;11 10 import java.util.ArrayList; 12 11 import java.util.Collection; … … 23 22 import org.openstreetmap.josm.data.DataSource; 24 23 import org.openstreetmap.josm.data.conflict.Conflict; 25 import org.openstreetmap.josm.data.osm.DataSet;26 24 import org.openstreetmap.josm.data.osm.IPrimitive; 27 25 import org.openstreetmap.josm.data.osm.OsmData; … … 34 32 import org.openstreetmap.josm.gui.MapView; 35 33 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener; 36 import org.openstreetmap.josm.gui.dialogs.ConflictDialog;37 34 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 38 35 import org.openstreetmap.josm.gui.dialogs.ValidatorDialog.ValidatorBoundingXYVisitor; … … 146 143 */ 147 144 public static void zoomTo(Collection<? extends IPrimitive> sel) { 148 BoundingXYVisitor bboxCalculator = new BoundingXYVisitor();145 final var bboxCalculator = new BoundingXYVisitor(); 149 146 bboxCalculator.computeBoundingBox(sel); 150 147 if (bboxCalculator.getBounds() != null) { … … 244 241 public void autoScale() { 245 242 if (MainApplication.isDisplayingMapView()) { 246 MapViewmapView = MainApplication.getMap().mapView;243 final var mapView = MainApplication.getMap().mapView; 247 244 switch (mode) { 248 245 case PREVIOUS: … … 312 309 private void modeLayer(BoundingXYVisitor v) { 313 310 // try to zoom to the first selected layer 314 Layer l = getFirstSelectedLayer();311 final var l = getFirstSelectedLayer(); 315 312 if (l == null) 316 313 return; … … 327 324 } 328 325 } else { 329 ConflictDialogconflictDialog = MainApplication.getMap().conflictDialog;326 final var conflictDialog = MainApplication.getMap().conflictDialog; 330 327 Conflict<? extends IPrimitive> c = conflictDialog.getSelectedConflict(); 331 328 if (c != null) { … … 359 356 } 360 357 Bounds bbox = null; 361 final DataSetdataset = getLayerManager().getActiveDataSet();358 final var dataset = getLayerManager().getActiveDataSet(); 362 359 if (dataset != null) { 363 360 List<DataSource> dataSources = new ArrayList<>(dataset.getDataSources()); … … 372 369 } else { 373 370 lastZoomArea = -1; 374 AreasourceArea = getLayerManager().getActiveDataSet().getDataSourceArea();371 final var sourceArea = getLayerManager().getActiveDataSet().getDataSourceArea(); 375 372 if (sourceArea != null) { 376 373 bbox = new Bounds(sourceArea.getBounds2D()); … … 439 436 * Adapter for zoom change events 440 437 */ 441 private class ZoomChangeAdapter implements ZoomChangeListener { 438 private final class ZoomChangeAdapter implements ZoomChangeListener { 442 439 @Override 443 440 public void zoomChanged() { -
trunk/src/org/openstreetmap/josm/actions/ChangesetManagerToggleAction.java
r17188 r19048 49 49 } 50 50 51 private class ChangesetCacheManagerClosedHandler extends WindowAdapter { 51 private final class ChangesetCacheManagerClosedHandler extends WindowAdapter { 52 52 @Override 53 53 public void windowClosed(WindowEvent e) { -
trunk/src/org/openstreetmap/josm/actions/DownloadOsmInViewAction.java
r17052 r19048 37 37 @Override 38 38 public void actionPerformed(ActionEvent e) { 39 final Boundsbounds = MainApplication.getMap().mapView.getRealBounds();40 DownloadOsmInViewTasktask = new DownloadOsmInViewTask();39 final var bounds = MainApplication.getMap().mapView.getRealBounds(); 40 final var task = new DownloadOsmInViewTask(); 41 41 task.setZoomAfterDownload(false); 42 42 Future<?> future = task.download(bounds); -
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r18972 r19048 210 210 211 211 public List<Node> getNodes() { 212 List<Node>nodes = new ArrayList<>();212 final var nodes = new ArrayList<Node>(); 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 ( intpos = 0; pos < way.way.getNodesCount() - 1; pos++) {216 for (var 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 EastNorthen1 = n1.getEastNorth();346 EastNorthen2 = n2.getEastNorth();347 EastNorthen3 = n3.getEastNorth();345 final var en1 = n1.getEastNorth(); 346 final var en2 = n2.getEastNorth(); 347 final var 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 NodeheadNode = getHeadNode();365 NodeprevNode = getPrevNode();364 final var headNode = getHeadNode(); 365 final var 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 booleanbestWayReverse = false;373 var bestWayReverse = false; 374 374 375 375 for (WayInPolygon way : availableWays) { … … 418 418 */ 419 419 public WayInPolygon leftComingWay() { 420 NodeheadNode = getHeadNode();421 NodeprevNode = getPrevNode();420 final var headNode = getHeadNode(); 421 final var prevNode = getPrevNode(); 422 422 423 423 WayInPolygon mostLeft = null; // most left way connected to head node 424 booleancomingToHead = false; // true if candidate come to head node424 var comingToHead = false; // true if candidate come to head node 425 425 double angle = 2*Math.PI; 426 426 … … 649 649 } 650 650 651 booleanhasChanges = false;652 653 List<Way>allStartingWays = new ArrayList<>();654 List<Way>innerStartingWays = new ArrayList<>();655 List<Way>outerStartingWays = new ArrayList<>();651 var hasChanges = false; 652 653 final var allStartingWays = new ArrayList<Way>(); 654 final var innerStartingWays = new ArrayList<Way>(); 655 final var outerStartingWays = new ArrayList<Way>(); 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 ( intk = 0; k < ring.ways.size(); k++) {723 for (var 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 WayInPolygonrepl = new WayInPolygon(older, ringWay.insideToTheRight);728 final var 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 CommanddeleteCmd = DeleteCommand.delete(discardedWays, true);771 final var 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 ( Noden : way.getNodes()) {799 Wayorig = oldestWayMap .get(n);798 for (var n : way.getNodes()) { 799 final var 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 TagCollectionwayTags = TagCollection.unionOfAllPrimitives(ways);832 final var 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 Map<Node, Node>nodeMap = new TreeMap<>(new NodePositionComparator());850 inttotalWaysModified = 0;849 final var nodeMap = new TreeMap<Node, Node>(new NodePositionComparator()); 850 var totalWaysModified = 0; 851 851 852 852 for (Way way : ways) { … … 855 855 } 856 856 857 List<Node>newNodes = new ArrayList<>();857 final var newNodes = new ArrayList<Node>(); 858 858 Node prevNode = null; 859 booleanmodifyWay = false;859 var modifyWay = false; 860 860 861 861 for (Node node : way.getNodes()) { 862 Noderepresentator = nodeMap.get(node);862 var representator = nodeMap.get(node); 863 863 if (representator == null) { 864 864 //new node … … 898 898 */ 899 899 private void commitCommands(String description) { 900 switch(cmds.size()) { 900 switch (cmds.size()) { 901 901 case 0: 902 902 return; … … 923 923 cmds.clear(); 924 924 if (addUndoRedo && !executedCmds.isEmpty()) { 925 UndoRedoHandler ur = UndoRedoHandler.getInstance();925 final var 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 ( intpos = 0; pos < parts.size(); pos++) {947 for (var 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 inttopIndex = 0;958 var topIndex = 0; 959 959 double minY = Double.POSITIVE_INFINITY; 960 960 961 961 for (Way way : parts) { 962 for ( intpos = 0; pos < way.getNodesCount(); pos++) {963 Nodenode = way.getNode(pos);962 for (var pos = 0; pos < way.getNodesCount(); pos++) { 963 final var 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 NodenextNode = way.getNode(1);998 final var 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 NodenextNode = way.getNode(way.getNodesCount() - 2);1010 final var 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 Nodeprev = topWay.getNode(topIndex - 1);1023 Nodenext = topWay.getNode(topIndex + 1);1022 final var prev = topWay.getNode(topIndex - 1); 1023 final var 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 WaycurWay = topWay;1029 var curWay = topWay; 1030 1030 boolean curWayInsideToTheRight = wayClockwise ^ isInner; 1031 1031 List<WayInPolygon> result = new ArrayList<>(); … … 1035 1035 1036 1036 //add cur way 1037 WayInPolygonresultWay = new WayInPolygon(curWay, curWayInsideToTheRight);1037 final var resultWay = new WayInPolygon(curWay, curWayInsideToTheRight); 1038 1038 result.add(resultWay); 1039 1039 1040 1040 //process next way 1041 WaynextWay = nextWayMap.get(curWay);1042 NodeprevNode = curWay.getNode(curWay.getNodesCount() - 2);1043 NodeheadNode = curWay.lastNode();1044 NodenextNode = nextWay.getNode(1);1041 final var nextWay = nextWayMap.get(curWay); 1042 final var prevNode = curWay.getNode(curWay.getNodesCount() - 2); 1043 final var headNode = curWay.lastNode(); 1044 final var nextNode = nextWay.getNode(1); 1045 1045 1046 1046 if (nextWay == topWay) { … … 1068 1068 // | 1069 1069 1070 intintersectionCount = 0;1070 var intersectionCount = 0; 1071 1071 1072 1072 for (Way wayA : parts) { … … 1078 1078 if (wayA.lastNode().equals(headNode)) { 1079 1079 1080 WaywayB = nextWayMap.get(wayA);1080 final var wayB = nextWayMap.get(wayA); 1081 1081 1082 1082 //test if wayA is opposite wayB relative to curWay and nextWay 1083 1083 1084 NodewayANode = wayA.getNode(wayA.getNodesCount() - 2);1085 NodewayBNode = wayB.getNode(1);1084 final var wayANode = wayA.getNode(wayA.getNodesCount() - 2); 1085 final var 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 ( inti = 0; i < parts.size(); i++) {1119 for (var 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 List<Way>result = new ArrayList<>();1143 final var result = new ArrayList<Way>(); 1144 1144 List<List<Node>> chunks = buildNodeChunks(way, nodes); 1145 1145 1146 1146 if (chunks.size() > 1) { 1147 SplitWayCommandsplit = SplitWayCommand.splitWay(way, chunks,1147 final var 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 Noden = part.firstNode();1162 Wayold = oldestWayMap.get(n);1161 final var n = part.firstNode(); 1162 final var 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 List<PolygonLevel>result = new ArrayList<>();1233 final var result = new ArrayList<PolygonLevel>(); 1234 1234 1235 1235 for (AssembledPolygon outerWay : boundaryWays) { 1236 1236 1237 booleanouterGood = true;1238 List<AssembledPolygon>innerCandidates = new ArrayList<>();1237 var outerGood = true; 1238 final var innerCandidates = new ArrayList<AssembledPolygon>(); 1239 1239 1240 1240 for (AssembledPolygon innerWay : boundaryWays) { … … 1256 1256 1257 1257 //add new outer polygon 1258 AssembledMultipolygonpol = new AssembledMultipolygon(outerWay);1259 PolygonLevelpolLev = new PolygonLevel(pol, level);1258 final var pol = new AssembledMultipolygon(outerWay); 1259 final var 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 List<WayInPolygon>cleanMultigonWays = new ArrayList<>();1290 final var cleanMultigonWays = new ArrayList<WayInPolygon>(); 1291 1291 for (WayInPolygon way: multigonWays) { 1292 1292 if (way.way.getNodesCount() != 2 || !way.way.isClosed()) 1293 1293 cleanMultigonWays.add(way); 1294 1294 } 1295 WayTraverser traverser = new WayTraverser(cleanMultigonWays);1296 List<AssembledPolygon>result = new ArrayList<>();1295 final var traverser = new WayTraverser(cleanMultigonWays); 1296 final var result = new ArrayList<AssembledPolygon>(); 1297 1297 1298 1298 WayInPolygon startWay; 1299 1299 while ((startWay = traverser.startNewWay()) != null) { 1300 List<WayInPolygon>path = new ArrayList<>();1301 List<WayInPolygon>startWays = new ArrayList<>();1300 final var path = new ArrayList<WayInPolygon>(); 1301 final var startWays = new ArrayList<WayInPolygon>(); 1302 1302 path.add(startWay); 1303 1303 while (true) { … … 1318 1318 if (path.get(0) == nextWay) { 1319 1319 // path is closed -> stop here 1320 AssembledPolygonring = new AssembledPolygon(path);1320 final var 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 List<AssembledPolygon>newPolygons = new ArrayList<>();1359 final var newPolygons = new ArrayList<AssembledPolygon>(); 1360 1360 1361 1361 for (AssembledPolygon ring : polygons) { 1362 1362 ring.reverse(); 1363 WayTraverser traverser = new WayTraverser(ring.ways);1363 final var traverser = new WayTraverser(ring.ways); 1364 1364 WayInPolygon startWay; 1365 1365 1366 1366 while ((startWay = traverser.startNewWay()) != null) { 1367 List<WayInPolygon>simpleRingWays = new ArrayList<>();1367 final var simpleRingWays = new ArrayList<WayInPolygon>(); 1368 1368 simpleRingWays.add(startWay); 1369 1369 WayInPolygon nextWay; … … 1374 1374 } 1375 1375 traverser.removeWays(simpleRingWays); 1376 AssembledPolygonsimpleRing = new AssembledPolygon(simpleRingWays);1376 final var 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 Multipolygonresult = new Multipolygon(joinWays(polygon.outerWay.ways));1413 final var 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 booleanallReverse = true;1431 var allReverse = true; 1432 1432 for (WayInPolygon way : ways) { 1433 1433 allReverse &= !way.insideToTheRight; … … 1440 1440 } 1441 1441 1442 WayjoinedWay = joinOrientedWays(ways);1442 final var joinedWay = joinOrientedWays(ways); 1443 1443 1444 1444 //should not happen … … 1462 1462 // the user about this. 1463 1463 1464 List<Way>actionWays = new ArrayList<>(ways.size());1465 intoldestPos = 0;1464 final var actionWays = new ArrayList<Way>(ways.size()); 1465 var oldestPos = 0; 1466 1466 Way oldest = ways.get(0).way; 1467 1467 for (WayInPolygon way : ways) { … … 1511 1511 } 1512 1512 1513 booleanhasKnownOuter = false;1513 var hasKnownOuter = false; 1514 1514 outerWays.clear(); 1515 1515 innerWays.clear(); … … 1538 1538 } 1539 1539 1540 WayouterWay = outerWays.get(0);1540 final var outerWay = outerWays.get(0); 1541 1541 1542 1542 //retain only selected inner ways … … 1588 1588 processedInnerWays.addAll(innerWays); 1589 1589 1590 Multipolygonpol = new Multipolygon(outerWay);1590 final var 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 RelationnewRel = new Relation();1617 final var 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 RelationRolesaverel = new RelationRole(r, rm.getRole());1652 final var 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 RelationnewRel = new Relation();1703 final var newRel = new Relation(); 1704 1704 for (RelationRole r : multiouters) { 1705 1705 // Add members -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r18759 r19048 7 7 8 8 import java.awt.Component; 9 import java.awt.GridBagConstraints; 9 10 import java.awt.GridBagLayout; 10 11 import java.awt.event.ActionEvent; … … 146 147 147 148 // Finally, applicableWays contains only one perfect way 148 final WayselectedWay = applicableWays.get(0);149 final List<OsmPrimitive>sel = new ArrayList<>(ds.getSelectedRelations());149 final var selectedWay = applicableWays.get(0); 150 final var sel = new ArrayList<OsmPrimitive>(ds.getSelectedRelations()); 150 151 sel.addAll(selectedWays); 151 152 doSplitWayShowSegmentSelection(selectedWay, selectedNodes, sel); … … 164 165 if (wayChunks != null) { 165 166 final List<Way> newWays = SplitWayCommand.createNewWaysFromChunks(splitWay, wayChunks); 166 final WaywayToKeep = SplitWayCommand.Strategy.keepLongestChunk().determineWayToKeep(newWays);167 final var wayToKeep = SplitWayCommand.Strategy.keepLongestChunk().determineWayToKeep(newWays); 167 168 168 169 if (ExpertToggleAction.isExpert() && !splitWay.isNew()) { … … 210 211 211 212 setButtonIcons("ok", "cancel"); 212 final JPanelpane = new JPanel(new GridBagLayout());213 pane.add(new JLabel(getTitle()), GBC.eol().fill(G BC.HORIZONTAL));214 pane.add(list, GBC.eop().fill(G BC.HORIZONTAL));213 final var pane = new JPanel(new GridBagLayout()); 214 pane.add(new JLabel(getTitle()), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 215 pane.add(list, GBC.eop().fill(GridBagConstraints.HORIZONTAL)); 215 216 setContent(pane); 216 217 setDefaultCloseOperation(HIDE_ON_CLOSE); … … 224 225 final Collection<WaySegment> segments = new ArrayList<>(selected.getNodesCount() - 1); 225 226 final Iterator<Node> it = selected.getNodes().iterator(); 226 NodepreviousNode = it.next();227 var previousNode = it.next(); 227 228 while (it.hasNext()) { 228 final Nodenode = it.next();229 final var node = it.next(); 229 230 segments.add(WaySegment.forNodePair(selectedWay, previousNode, node)); 230 231 previousNode = node; … … 237 238 238 239 protected void setHighlightedWaySegments(Collection<WaySegment> segments) { 239 DataSetds = selectedWay.getDataSet();240 final var ds = selectedWay.getDataSet(); 240 241 if (ds != null) { 241 242 ds.setHighlightedWaySegments(segments); … … 247 248 public void setVisible(boolean visible) { 248 249 super.setVisible(visible); 249 DataSetds = selectedWay.getDataSet();250 final var ds = selectedWay.getDataSet(); 250 251 if (visible) { 251 252 DISPLAY_COUNT.incrementAndGet(); … … 276 277 } 277 278 278 private class SplitWayDataSetListener implements DataSetListener { 279 private final class SplitWayDataSetListener implements DataSetListener { 279 280 280 281 @Override … … 336 337 @Override 337 338 public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { 338 final Componentc = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);339 final var c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); 339 340 final String name = DefaultNameFormatter.getInstance().format((Way) value); 340 341 // get rid of id from DefaultNameFormatter.decorateNameWithId() … … 359 360 // Special case - one of the selected ways touches (not cross) way that we want to split 360 361 if (selectedNodes.size() == 1) { 361 Noden = selectedNodes.get(0);362 final var n = selectedNodes.get(0); 362 363 List<Way> referredWays = n.getParentWays(); 363 364 Way inTheMiddle = null;
Note:
See TracChangeset
for help on using the changeset viewer.
