Ticket #8902: fortoforeach.diff
| File fortoforeach.diff, 25.1 KB (added by , 12 years ago) |
|---|
-
src/org/openstreetmap/josm/actions/OpenLocationAction.java
132 132 */ 133 133 public Collection<DownloadTask> findDownloadTasks(final String url) { 134 134 List<DownloadTask> result = new ArrayList<DownloadTask>(); 135 for (int i = 0; i < downloadTasks.size(); i++) { 136 Class<? extends DownloadTask> taskClass = downloadTasks.get(i); 135 for (Class<? extends DownloadTask> taskClass : downloadTasks) { 137 136 if (taskClass != null) { 138 137 try { 139 138 DownloadTask task = taskClass.getConstructor().newInstance(); -
src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
1669 1669 1670 1670 private double getNearestAngle(double angle) { 1671 1671 double delta,minDelta=1e5, bestAngle=0.0; 1672 for ( int i=0; i < snapAngles.length; i++) {1673 delta = getAngleDelta(angle, snapAngles[i]);1672 for (double snapAngle : snapAngles) { 1673 delta = getAngleDelta(angle, snapAngle); 1674 1674 if (delta < minDelta) { 1675 minDelta =delta;1676 bestAngle =snapAngles[i];1675 minDelta = delta; 1676 bestAngle = snapAngle; 1677 1677 } 1678 1678 } 1679 1679 if (Math.abs(bestAngle-360) < 1e-3) { -
src/org/openstreetmap/josm/data/AutosaveTask.java
113 113 114 114 private String getFileName(String layerName, int index) { 115 115 String result = layerName; 116 for ( int i=0; i<ILLEGAL_CHARACTERS.length; i++) {117 result = result.replaceAll(Pattern.quote(String.valueOf( ILLEGAL_CHARACTERS[i])),118 '&' + String.valueOf((int) ILLEGAL_CHARACTERS[i]) + ';');116 for (char illegalCharacter : ILLEGAL_CHARACTERS) { 117 result = result.replaceAll(Pattern.quote(String.valueOf(illegalCharacter)), 118 '&' + String.valueOf((int) illegalCharacter) + ';'); 119 119 } 120 120 if (index != 0) { 121 121 result = result + '_' + index; -
src/org/openstreetmap/josm/data/osm/Way.java
150 150 if (node == null) return false; 151 151 152 152 Node[] nodes = this.nodes; 153 for ( int i=0; i<nodes.length; i++) {154 if (n odes[i].equals(node))153 for (Node n : nodes) { 154 if (n.equals(node)) 155 155 return true; 156 156 } 157 157 return false; -
src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
297 297 nodes.addAll(w.getNodes()); 298 298 } else { 299 299 List<Way> waysToJoin = new ArrayList<Way>(); 300 for ( Iterator<Long> it = wayIds.iterator(); it.hasNext();) {301 Way w = (Way) ds.getPrimitiveById( it.next(), OsmPrimitiveType.WAY);300 for (Long wayId : wayIds) { 301 Way w = (Way) ds.getPrimitiveById(wayId, OsmPrimitiveType.WAY); 302 302 if (w != null && w.getNodesCount() > 0) { // fix #7173 (empty ways on purge) 303 303 waysToJoin.add(w); 304 304 } -
src/org/openstreetmap/josm/data/projection/CustomProjection.java
159 159 if (pref.trim().isEmpty()) { 160 160 parts = new String[0]; 161 161 } 162 for (int i = 0; i < parts.length; i++) { 163 String part = parts[i]; 162 for (String part : parts) { 164 163 if (part.isEmpty() || part.charAt(0) != '+') 165 164 throw new ProjectionConfigurationException(tr("Parameter must begin with a ''+'' character (found ''{0}'')", part)); 166 165 Matcher m = Pattern.compile("\\+([a-zA-Z0-9_]+)(=(.*))?").matcher(part); … … 287 286 if (numStr.length != 3 && numStr.length != 7) 288 287 throw new ProjectionConfigurationException(tr("Unexpected number of arguments for parameter ''towgs84'' (must be 3 or 7)")); 289 288 List<Double> towgs84Param = new ArrayList<Double>(); 290 for ( int i = 0; i < numStr.length; i++) {289 for (String str : numStr) { 291 290 try { 292 towgs84Param.add(Double.parseDouble( numStr[i]));291 towgs84Param.add(Double.parseDouble(str)); 293 292 } catch (NumberFormatException e) { 294 throw new ProjectionConfigurationException(tr("Unable to parse value of parameter ''towgs84'' (''{0}'')", numStr[i]));293 throw new ProjectionConfigurationException(tr("Unable to parse value of parameter ''towgs84'' (''{0}'')", str)); 295 294 } 296 295 } 297 296 boolean isCentric = true; 298 for ( int i = 0; i<towgs84Param.size(); i++) {299 if ( towgs84Param.get(i)!= 0.0) {297 for (Double param : towgs84Param) { 298 if (param != 0.0) { 300 299 isCentric = false; 301 300 break; 302 301 } -
src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java
162 162 if (subGrid == null) 163 163 return this; 164 164 else { 165 for ( int i = 0; i < subGrid.length; i++) {166 if ( subGrid[i].isCoordWithin(lon, lat))167 return subGrid[i].getSubGridForCoord(lon, lat);165 for (NTV2SubGrid aSubGrid : subGrid) { 166 if (aSubGrid.isCoordWithin(lon, lat)) 167 return aSubGrid.getSubGridForCoord(lon, lat); 168 168 } 169 169 return this; 170 170 } -
src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java
84 84 tags = r.getKeys(); 85 85 List<Node> wNodes = r.getNodes(); 86 86 coor = new ArrayList<LatLon>(wNodes.size()); 87 for ( int i = 0; i < wNodes.size(); i++) {88 coor.add(wNode s.get(i).getCoor());87 for (Node wNode : wNodes) { 88 coor.add(wNode.getCoor()); 89 89 } 90 90 } 91 91 if (src.isRelation()) { … … 109 109 */ 110 110 public RelationMembers(List<RelationMember> members) { 111 111 this.members = new ArrayList<RelMember>(members.size()); 112 for ( int i = 0; i < members.size(); i++) {113 this.members.add(new RelMember(member s.get(i)));112 for (RelationMember member : members) { 113 this.members.add(new RelMember(member)); 114 114 } 115 115 } 116 116 -
src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
192 192 } 193 193 // Build the list of lat/lon 194 194 List<LatLon> wLat = new ArrayList<LatLon>(wNodesToUse.size()); 195 for ( int i=0; i<wNodesToUse.size(); i++) {196 wLat.add( wNodesToUse.get(i).getCoor());195 for (Node node : wNodesToUse) { 196 wLat.add(node.getCoor()); 197 197 } 198 198 // If this way has not direction-dependant keys, make sure the list is ordered the same for all ways (fix #8015) 199 199 if (!w.hasDirectionKeys()) { -
src/org/openstreetmap/josm/data/validation/util/Entities.java
387 387 if(mapNameToValue == null) 388 388 { 389 389 mapNameToValue = new HashMap<String, String>(); 390 for ( int in = 0; in < ARRAY.length; ++in)391 mapNameToValue.put( ARRAY[in][0], ARRAY[in][1]);390 for (String[] pair : ARRAY) 391 mapNameToValue.put(pair[0], pair[1]); 392 392 } 393 393 String value = mapNameToValue.get(entityContent); 394 394 entityValue = (value == null ? -1 : Integer.parseInt(value)); -
src/org/openstreetmap/josm/gui/FileDrop.java
2 2 (public domain) with only very small additions */ 3 3 package org.openstreetmap.josm.gui; 4 4 5 import java.awt.*; 5 6 import java.awt.datatransfer.DataFlavor; 7 import java.awt.dnd.DnDConstants; 6 8 import java.io.BufferedReader; 7 9 import java.io.File; 8 10 import java.io.IOException; … … 342 344 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 343 345 DataFlavor[] flavors = tr.getTransferDataFlavors(); 344 346 boolean handled = false; 345 for ( int zz = 0; zz < flavors.length; zz++) {346 if (flavor s[zz].isRepresentationClassReader()) {347 for (DataFlavor flavor : flavors) { 348 if (flavor.isRepresentationClassReader()) { 347 349 // Say we'll take it. 348 350 //evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 349 evt.acceptDrop( java.awt.dnd.DnDConstants.ACTION_COPY);351 evt.acceptDrop(DnDConstants.ACTION_COPY); 350 352 log(out, "FileDrop: reader accepted."); 351 353 352 Reader reader = flavor s[zz].getReaderForText(tr);354 Reader reader = flavor.getReaderForText(tr); 353 355 354 356 BufferedReader br = new BufferedReader(reader); 355 357 356 if (listener != null) {358 if (listener != null) { 357 359 listener.filesDropped(createFileArray(br, out)); 358 360 } 359 361 … … 513 515 java.awt.Component[] comps = cont.getComponents(); 514 516 515 517 // Set it's components as listeners also 516 for ( int i = 0; i < comps.length; i++) {517 makeDropTarget( out, comps[i], recursive);518 for (Component comp : comps) { 519 makeDropTarget(out, comp, recursive); 518 520 } 519 521 } // end if: recursively set components as listener 520 522 } // end dropListener … … 593 595 c.setDropTarget( null ); 594 596 if( recursive && ( c instanceof java.awt.Container ) ) 595 597 { java.awt.Component[] comps = ((java.awt.Container)c).getComponents(); 596 for( int i = 0; i < comps.length; i++) {597 remove( out, comps[i], recursive);598 }598 for (Component comp : comps) { 599 remove(out, comp, recursive); 600 } 599 601 return true; 600 602 } // end if: recursive 601 603 else return false; -
src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
390 390 */ 391 391 protected void setContentVisible(boolean visible) { 392 392 Component[] comps = getComponents(); 393 for (int i=0; i<comps.length; i++) {394 if (comp s[i] != titleBar && (!visible || comps[i]!= buttonsPanel || buttonHiding != ButtonHiddingType.ALWAYS_HIDDEN)) {395 comp s[i].setVisible(visible);393 for (Component comp : comps) { 394 if (comp != titleBar && (!visible || comp != buttonsPanel || buttonHiding != ButtonHiddingType.ALWAYS_HIDDEN)) { 395 comp.setVisible(visible); 396 396 } 397 397 } 398 398 } -
src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
48 48 49 49 protected void registerBoundingBoxBuilder() { 50 50 BoundingBoxBuilder bboxbuilder = new BoundingBoxBuilder(); 51 for ( int i = 0;i < latlon.length; i++) {52 l atlon[i].addFocusListener(bboxbuilder);53 l atlon[i].addActionListener(bboxbuilder);51 for (JosmTextField ll : latlon) { 52 ll.addFocusListener(bboxbuilder); 53 ll.addActionListener(bboxbuilder); 54 54 } 55 55 } 56 56 -
src/org/openstreetmap/josm/gui/io/ActionFlagsTableCell.java
54 54 setLayout(new GridBagLayout()); 55 55 56 56 ActionMap am = getActionMap(); 57 for(int i=0; i<checkBoxes.length; i++) { 58 final JCheckBox b = checkBoxes[i]; 57 for (final JCheckBox b : checkBoxes) { 59 58 add(b, GBC.eol().fill(GBC.HORIZONTAL)); 60 59 b.setPreferredSize(new Dimension(b.getPreferredSize().width, 19)); 61 60 b.addActionListener(al); -
src/org/openstreetmap/josm/gui/layer/WMSLayer.java
273 273 GeorefImage[][] old = images; 274 274 images = new GeorefImage[dax][day]; 275 275 if (old != null) { 276 for (int i=0; i<old.length; i++) { 277 for (int k=0; k<old[i].length; k++) { 278 GeorefImage o = old[i][k]; 279 images[modulo(o.getXIndex(),dax)][modulo(o.getYIndex(),day)] = old[i][k]; 276 for (GeorefImage[] row : old) { 277 for (GeorefImage image : row) { 278 images[modulo(image.getXIndex(), dax)][modulo(image.getYIndex(), day)] = image; 280 279 } 281 280 } 282 281 } -
src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
90 90 }); 91 91 } 92 92 String names = null; 93 for ( int i = 0; i < sel.length; i++) {93 for (File file : sel) { 94 94 if (names == null) { 95 95 names = " ("; 96 96 } else { 97 97 names += ", "; 98 98 } 99 names += sel[i].getName();99 names += file.getName(); 100 100 } 101 101 if (names != null) { 102 102 names += ")"; … … 106 106 MarkerLayer ml = new MarkerLayer(new GpxData(), tr("Audio markers from {0}", layer.getName()) + names, layer.getAssociatedFile(), layer); 107 107 double firstStartTime = sel[0].lastModified() / 1000.0 - AudioUtil.getCalibratedDuration(sel[0]); 108 108 Markers m = new Markers(); 109 for ( int i = 0; i < sel.length; i++) {110 importAudio( sel[i], ml, firstStartTime, m);109 for (File file : sel) { 110 importAudio(file, ml, firstStartTime, m); 111 111 } 112 112 Main.main.addLayer(ml); 113 113 Main.map.repaint(); -
src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
134 134 virtualNode.put(tag.getKey(), tag.getValue()); 135 135 StyleList styleList = getStyles().generateStyles(virtualNode, 0.5, null, false).a; 136 136 if (styleList != null) { 137 for (Iterator<ElemStyle> it = styleList.iterator(); it.hasNext(); ) { 138 ElemStyle style = it.next(); 137 for (ElemStyle style : styleList) { 139 138 if (style instanceof NodeElemStyle) { 140 139 MapImage mapImage = ((NodeElemStyle) style).mapImage; 141 140 if (mapImage != null) { -
src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
513 513 514 514 Set<String> acceptedEulas = new HashSet<String>(); 515 515 516 outer: for (int i = 0; i < lines.length; i++) { 517 ImageryInfo info = defaultModel.getRow(lines[i]); 516 outer: 517 for (int line : lines) { 518 ImageryInfo info = defaultModel.getRow(line); 518 519 519 520 // Check if an entry with exactly the same values already 520 521 // exists -
src/org/openstreetmap/josm/io/OsmServerChangesetReader.java
131 131 monitor.setTicksCount(ids.size()); 132 132 List<Changeset> ret = new ArrayList<Changeset>(); 133 133 int i=0; 134 for (Iterator<Integer> it = ids.iterator(); it.hasNext(); ) { 135 int id = it.next(); 134 for (int id : ids) { 136 135 if (id <= 0) { 137 136 continue; 138 137 } … … 142 141 InputStream in = getInputStream(sb.toString(), monitor.createSubTaskMonitor(1, true)); 143 142 if (in == null) 144 143 return null; 145 monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {2} ...", i, ids.size(), id));144 monitor.indeterminateSubTask(tr("({0}/{1}) Downloading changeset {2} ...", i, ids.size(), id)); 146 145 List<Changeset> changesets = OsmChangesetParser.parse(in, monitor.createSubTaskMonitor(1, true)); 147 146 if (changesets == null || changesets.isEmpty()) { 148 147 continue; -
src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
337 337 if (trustedSenders.contains(sender)) { 338 338 if (Main.main.getCurrentDataSet() != null) { 339 339 Collection<OsmPrimitive> s = Main.main.getCurrentDataSet().getSelected(); 340 for ( int j = 0; j < keyValue.length; j++) {341 Main.main.undoRedo.add(new ChangePropertyCommand(s, keyValue[j][0], keyValue[j][1]));340 for (String[] row : keyValue) { 341 Main.main.undoRedo.add(new ChangePropertyCommand(s, row[0], row[1])); 342 342 } 343 343 } 344 344 } else { -
src/org/openstreetmap/josm/tools/FallbackDateParser.java
42 42 public FallbackDateParser() { 43 43 // Build a list of candidate date parsers. 44 44 dateParsers = new ArrayList<DateFormat>(formats.length); 45 for ( int i = 0; i < formats.length; i++) {46 dateParsers.add(new SimpleDateFormat(format s[i]));45 for (String format : formats) { 46 dateParsers.add(new SimpleDateFormat(format)); 47 47 } 48 48 49 49 // We haven't selected a date parser yet. -
src/org/openstreetmap/josm/tools/Utils.java
280 280 public static boolean deleteDirectory(File path) { 281 281 if( path.exists() ) { 282 282 File[] files = path.listFiles(); 283 for(int i=0; i<files.length; i++) { 284 if(files[i].isDirectory()) { 285 deleteDirectory(files[i]); 283 for (File file : files) { 284 if (file.isDirectory()) { 285 deleteDirectory(file); 286 } else { 287 file.delete(); 286 288 } 287 else {288 files[i].delete();289 }290 289 } 291 290 } 292 291 return( path.delete() ); -
src/org/openstreetmap/josm/tools/WindowGeometry.java
295 295 GraphicsEnvironment ge = GraphicsEnvironment 296 296 .getLocalGraphicsEnvironment(); 297 297 GraphicsDevice[] gs = ge.getScreenDevices(); 298 for (int j = 0; j < gs.length; j++) { 299 GraphicsDevice gd = gs[j]; 298 for (GraphicsDevice gd : gs) { 300 299 if (gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) { 301 300 virtualBounds = virtualBounds.union(gd.getDefaultConfiguration().getBounds()); 302 301 } … … 345 344 GraphicsDevice[] gs = ge.getScreenDevices(); 346 345 int intersect = 0; 347 346 Rectangle bounds = null; 348 for (int j = 0; j < gs.length; j++) { 349 GraphicsDevice gd = gs[j]; 347 for (GraphicsDevice gd : gs) { 350 348 if (gd.getType() == GraphicsDevice.TYPE_RASTER_SCREEN) { 351 349 Rectangle b = gd.getDefaultConfiguration().getBounds(); 352 if (b.height > 0 && b.width/b.height >= 3) /* multiscreen with wrong definition */ 353 { 350 if (b.height > 0 && b.width / b.height >= 3) /* multiscreen with wrong definition */ { 354 351 b.width /= 2; 355 352 Rectangle is = b.intersection(g); 356 int s = is.width *is.height;357 if (bounds == null || intersect < s) {353 int s = is.width * is.height; 354 if (bounds == null || intersect < s) { 358 355 intersect = s; 359 356 bounds = b; 360 357 } 361 358 b = new Rectangle(b); 362 359 b.x += b.width; 363 360 is = b.intersection(g); 364 s = is.width *is.height;365 if (bounds == null || intersect < s) {361 s = is.width * is.height; 362 if (bounds == null || intersect < s) { 366 363 intersect = s; 367 364 bounds = b; 368 365 } 369 } 370 else 371 { 366 } else { 372 367 Rectangle is = b.intersection(g); 373 int s = is.width *is.height;374 if (bounds == null || intersect < s) {368 int s = is.width * is.height; 369 if (bounds == null || intersect < s) { 375 370 intersect = s; 376 371 bounds = b; 377 372 }
