Changeset 6104 in josm
- Timestamp:
- 2013-08-03T00:12:29+02:00 (11 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/FollowLineAction.java
r6093 r6104 7 7 import java.awt.event.KeyEvent; 8 8 import java.util.Collection; 9 import java.util.Iterator;10 9 import java.util.List; 11 10 import java.util.Set; … … 85 84 86 85 Node newPoint = null; 87 Iterator<OsmPrimitive> i = referrers.iterator(); 88 while (i.hasNext()) { 89 OsmPrimitive referrer = i.next(); 86 for (OsmPrimitive referrer : referrers) { 90 87 if (!referrer.getType().equals(OsmPrimitiveType.WAY)) { // Can't follow points or relations 91 88 continue; -
trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java
r6084 r6104 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 { -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r6093 r6104 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 } -
trunk/src/org/openstreetmap/josm/command/DeleteCommand.java
r5612 r6104 395 395 // remove the objects from their parent relations 396 396 // 397 Iterator<Relation> iterator = OsmPrimitive.getFilteredSet(OsmPrimitive.getReferrer(primitivesToDelete), Relation.class).iterator(); 398 while (iterator.hasNext()) { 399 Relation cur = iterator.next(); 397 for (Relation cur : OsmPrimitive.getFilteredSet(OsmPrimitive.getReferrer(primitivesToDelete), Relation.class)) { 400 398 Relation rel = new Relation(cur); 401 399 rel.removeMembersFor(primitivesToDelete); -
trunk/src/org/openstreetmap/josm/data/AutosaveTask.java
r6084 r6104 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) { -
trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java
r6084 r6104 59 59 60 60 protected void fireConflictRemoved() { 61 Iterator<IConflictListener> it = listeners.iterator(); 62 while(it.hasNext()) { 63 it.next().onConflictsRemoved(this); 61 for (IConflictListener listener : listeners) { 62 listener.onConflictsRemoved(this); 64 63 } 65 64 } -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r6069 r6104 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 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/relations/Multipolygon.java
r6069 r6104 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); -
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r5889 r6104 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)); … … 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; -
trunk/src/org/openstreetmap/josm/data/projection/datum/NTV2SubGrid.java
r5909 r6104 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; -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateRelation.java
r5783 r6104 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 } … … 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 } -
trunk/src/org/openstreetmap/josm/data/validation/tests/DuplicateWay.java
r6069 r6104 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) -
trunk/src/org/openstreetmap/josm/data/validation/util/Entities.java
r3669 r6104 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); -
trunk/src/org/openstreetmap/josm/gui/FileDrop.java
r6084 r6104 3 3 package org.openstreetmap.josm.gui; 4 4 5 import java.awt.Color; 6 import java.awt.Component; 7 import java.awt.Container; 5 8 import java.awt.datatransfer.DataFlavor; 9 import java.awt.datatransfer.Transferable; 10 import java.awt.datatransfer.UnsupportedFlavorException; 11 import java.awt.dnd.DnDConstants; 12 import java.awt.dnd.DropTarget; 13 import java.awt.dnd.DropTargetDragEvent; 14 import java.awt.dnd.DropTargetDropEvent; 15 import java.awt.dnd.DropTargetEvent; 16 import java.awt.dnd.DropTargetListener; 17 import java.awt.event.HierarchyEvent; 18 import java.awt.event.HierarchyListener; 6 19 import java.io.BufferedReader; 7 20 import java.io.File; 8 21 import java.io.IOException; 9 import java.io.PrintStream;10 22 import java.io.Reader; 23 import java.net.URI; 24 import java.util.ArrayList; 11 25 import java.util.Arrays; 26 import java.util.EventObject; 12 27 import java.util.List; 28 import java.util.TooManyListenersException; 13 29 14 30 import javax.swing.BorderFactory; 31 import javax.swing.JComponent; 32 import javax.swing.border.Border; 15 33 16 34 import org.openstreetmap.josm.Main; … … 55 73 * @author rharder@users.sf.net 56 74 * @version 1.0.1 75 * @since 1231 57 76 */ 58 77 public class FileDrop 59 78 { 60 private transient javax.swing.border.Border normalBorder;61 private transient java.awt.dnd.DropTargetListener dropListener;79 private transient Border normalBorder; 80 private transient DropTargetListener dropListener; 62 81 63 82 /** Discover if the running JVM is modern enough to have drag and drop. */ … … 65 84 66 85 // Default border color 67 private static java.awt.Color defaultBorderColor = new java.awt.Color( 0f, 0f, 1f, 0.25f ); 68 69 /* Constructor for JOSM file drop */ 70 public FileDrop(final java.awt.Component c){ 86 private static Color defaultBorderColor = new Color( 0f, 0f, 1f, 0.25f ); 87 88 /** 89 * Constructor for JOSM file drop 90 * @param c The drop target 91 */ 92 public FileDrop(final Component c){ 71 93 this( 72 null, // Logging stream73 94 c, // Drop target 74 95 BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ), // Drag border … … 76 97 new FileDrop.Listener(){ 77 98 @Override 78 public void filesDropped( java.io.File[] files ){99 public void filesDropped( File[] files ){ 79 100 // start asynchronous loading of files 80 101 OpenFileAction.OpenFileTask task = new OpenFileAction.OpenFileTask(Arrays.asList(files), null); … … 87 108 88 109 /** 89 * Constructs a {@link FileDrop} with a default light-blue border90 * and, if <var>c</var> is a {@link java.awt.Container}, recursively91 * sets all elements contained within as drop targets, though only92 * the top level container will change borders.93 *94 * @param c Component on which files will be dropped.95 * @param listener Listens for <tt>filesDropped</tt>.96 * @since 1.097 */98 public FileDrop(99 final java.awt.Component c,100 final Listener listener )101 { this( null, // Logging stream102 c, // Drop target103 javax.swing.BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ), // Drag border104 true, // Recursive105 listener );106 } // end constructor107 108 /**109 * Constructor with a default border and the option to recursively set drop targets.110 * If your component is a <tt>java.awt.Container</tt>, then each of its children111 * components will also listen for drops, though only the parent will change borders.112 *113 * @param c Component on which files will be dropped.114 * @param recursive Recursively set children as drop targets.115 * @param listener Listens for <tt>filesDropped</tt>.116 * @since 1.0117 */118 public FileDrop(119 final java.awt.Component c,120 final boolean recursive,121 final Listener listener )122 { this( null, // Logging stream123 c, // Drop target124 javax.swing.BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ), // Drag border125 recursive, // Recursive126 listener );127 } // end constructor128 129 /**130 * Constructor with a default border and debugging optionally turned on.131 * With Debugging turned on, more status messages will be displayed to132 * <tt>out</tt>. A common way to use this constructor is with133 * <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for134 * the parameter <tt>out</tt> will result in no debugging output.135 *136 * @param out PrintStream to record debugging info or null for no debugging.137 * @param c Component on which files will be dropped.138 * @param listener Listens for <tt>filesDropped</tt>.139 * @since 1.0140 */141 public FileDrop(142 final java.io.PrintStream out,143 final java.awt.Component c,144 final Listener listener )145 { this( out, // Logging stream146 c, // Drop target147 javax.swing.BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ),148 false, // Recursive149 listener );150 } // end constructor151 152 /**153 * Constructor with a default border, debugging optionally turned on154 * and the option to recursively set drop targets.155 * If your component is a <tt>java.awt.Container</tt>, then each of its children156 * components will also listen for drops, though only the parent will change borders.157 * With Debugging turned on, more status messages will be displayed to158 * <tt>out</tt>. A common way to use this constructor is with159 * <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for160 * the parameter <tt>out</tt> will result in no debugging output.161 *162 * @param out PrintStream to record debugging info or null for no debugging.163 * @param c Component on which files will be dropped.164 * @param recursive Recursively set children as drop targets.165 * @param listener Listens for <tt>filesDropped</tt>.166 * @since 1.0167 */168 public FileDrop(169 final java.io.PrintStream out,170 final java.awt.Component c,171 final boolean recursive,172 final Listener listener)173 { this( out, // Logging stream174 c, // Drop target175 javax.swing.BorderFactory.createMatteBorder( 2, 2, 2, 2, defaultBorderColor ), // Drag border176 recursive, // Recursive177 listener );178 } // end constructor179 180 /**181 * Constructor with a specified border182 *183 * @param c Component on which files will be dropped.184 * @param dragBorder Border to use on <tt>JComponent</tt> when dragging occurs.185 * @param listener Listens for <tt>filesDropped</tt>.186 * @since 1.0187 */188 public FileDrop(189 final java.awt.Component c,190 final javax.swing.border.Border dragBorder,191 final Listener listener)192 { this(193 null, // Logging stream194 c, // Drop target195 dragBorder, // Drag border196 false, // Recursive197 listener );198 } // end constructor199 200 /**201 * Constructor with a specified border and the option to recursively set drop targets.202 * If your component is a <tt>java.awt.Container</tt>, then each of its children203 * components will also listen for drops, though only the parent will change borders.204 *205 * @param c Component on which files will be dropped.206 * @param dragBorder Border to use on <tt>JComponent</tt> when dragging occurs.207 * @param recursive Recursively set children as drop targets.208 * @param listener Listens for <tt>filesDropped</tt>.209 * @since 1.0210 */211 public FileDrop(212 final java.awt.Component c,213 final javax.swing.border.Border dragBorder,214 final boolean recursive,215 final Listener listener)216 { this(217 null,218 c,219 dragBorder,220 recursive,221 listener );222 } // end constructor223 224 /**225 * Constructor with a specified border and debugging optionally turned on.226 * With Debugging turned on, more status messages will be displayed to227 * <tt>out</tt>. A common way to use this constructor is with228 * <tt>System.out</tt> or <tt>System.err</tt>. A <tt>null</tt> value for229 * the parameter <tt>out</tt> will result in no debugging output.230 *231 * @param out PrintStream to record debugging info or null for no debugging.232 * @param c Component on which files will be dropped.233 * @param dragBorder Border to use on <tt>JComponent</tt> when dragging occurs.234 * @param listener Listens for <tt>filesDropped</tt>.235 * @since 1.0236 */237 public FileDrop(238 final java.io.PrintStream out,239 final java.awt.Component c,240 final javax.swing.border.Border dragBorder,241 final Listener listener)242 { this(243 out, // Logging stream244 c, // Drop target245 dragBorder, // Drag border246 false, // Recursive247 listener );248 } // end constructor249 250 /**251 110 * Full constructor with a specified border and debugging optionally turned on. 252 111 * With Debugging turned on, more status messages will be displayed to … … 255 114 * the parameter <tt>out</tt> will result in no debugging output. 256 115 * 257 * @param out PrintStream to record debugging info or null for no debugging.258 116 * @param c Component on which files will be dropped. 259 117 * @param dragBorder Border to use on <tt>JComponent</tt> when dragging occurs. 260 118 * @param recursive Recursively set children as drop targets. 261 119 * @param listener Listens for <tt>filesDropped</tt>. 262 * @since 1.0263 120 */ 264 121 public FileDrop( 265 final java.io.PrintStream out, 266 final java.awt.Component c, 267 final javax.swing.border.Border dragBorder, 122 final Component c, 123 final Border dragBorder, 268 124 final boolean recursive, 269 125 final Listener listener) … … 272 128 if( supportsDnD() ) 273 129 { // Make a drop listener 274 dropListener = new java.awt.dnd.DropTargetListener()130 dropListener = new DropTargetListener() 275 131 { @Override 276 public void dragEnter( java.awt.dnd.DropTargetDragEvent evt )277 { log( out,"FileDrop: dragEnter event." );132 public void dragEnter( DropTargetDragEvent evt ) 133 { Main.debug("FileDrop: dragEnter event." ); 278 134 279 135 // Is this an acceptable drag event? 280 if( isDragOk( out,evt ) )136 if( isDragOk( evt ) ) 281 137 { 282 138 // If it's a Swing component, set its border 283 if( c instanceof javax.swing.JComponent )284 { javax.swing.JComponent jc = (javax.swing.JComponent) c;139 if( c instanceof JComponent ) 140 { JComponent jc = (JComponent) c; 285 141 normalBorder = jc.getBorder(); 286 log( out,"FileDrop: normal border saved." );142 Main.debug("FileDrop: normal border saved." ); 287 143 jc.setBorder( dragBorder ); 288 log( out,"FileDrop: drag border set." );144 Main.debug("FileDrop: drag border set." ); 289 145 } // end if: JComponent 290 146 291 147 // Acknowledge that it's okay to enter 292 //evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 293 evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY ); 294 log( out, "FileDrop: event accepted." ); 148 evt.acceptDrag( DnDConstants.ACTION_COPY ); 149 Main.debug("FileDrop: event accepted." ); 295 150 } // end if: drag ok 296 151 else 297 152 { // Reject the drag event 298 153 evt.rejectDrag(); 299 log( out,"FileDrop: event rejected." );154 Main.debug("FileDrop: event rejected." ); 300 155 } // end else: drag not ok 301 156 } // end dragEnter 302 157 303 158 @Override 304 public void dragOver( java.awt.dnd.DropTargetDragEvent evt )159 public void dragOver( DropTargetDragEvent evt ) 305 160 { // This is called continually as long as the mouse is 306 161 // over the drag target. … … 308 163 309 164 @Override 310 public void drop( java.awt.dnd.DropTargetDropEvent evt )311 { log( out,"FileDrop: drop event." );165 public void drop( DropTargetDropEvent evt ) 166 { Main.debug("FileDrop: drop event." ); 312 167 try 313 168 { // Get whatever was dropped 314 java.awt.datatransfer.Transferable tr = evt.getTransferable();169 Transferable tr = evt.getTransferable(); 315 170 316 171 // Is it a file list? 317 if (tr.isDataFlavorSupported ( java.awt.datatransfer.DataFlavor.javaFileListFlavor))172 if (tr.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) 318 173 { 319 174 // Say we'll take it. 320 //evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 321 evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY ); 322 log( out, "FileDrop: file list accepted." ); 175 evt.acceptDrop ( DnDConstants.ACTION_COPY ); 176 Main.debug("FileDrop: file list accepted." ); 323 177 324 178 // Get a useful list 325 List<?> fileList = (List<?>)tr.getTransferData( java.awt.datatransfer.DataFlavor.javaFileListFlavor);179 List<?> fileList = (List<?>)tr.getTransferData(DataFlavor.javaFileListFlavor); 326 180 327 181 // Convert list to array … … 335 189 // Mark that drop is completed. 336 190 evt.getDropTargetContext().dropComplete(true); 337 log( out,"FileDrop: drop complete." );191 Main.debug("FileDrop: drop complete." ); 338 192 } // end if: file list 339 193 else // this section will check for a reader flavor. … … 343 197 DataFlavor[] flavors = tr.getTransferDataFlavors(); 344 198 boolean handled = false; 345 for ( int zz = 0; zz < flavors.length; zz++) {346 if (flavor s[zz].isRepresentationClassReader()) {199 for (DataFlavor flavor : flavors) { 200 if (flavor.isRepresentationClassReader()) { 347 201 // Say we'll take it. 348 //evt.acceptDrop ( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE ); 349 evt.acceptDrop(java.awt.dnd.DnDConstants.ACTION_COPY); 350 log(out, "FileDrop: reader accepted."); 351 352 Reader reader = flavors[zz].getReaderForText(tr); 202 evt.acceptDrop(DnDConstants.ACTION_COPY); 203 Main.debug("FileDrop: reader accepted."); 204 205 Reader reader = flavor.getReaderForText(tr); 353 206 354 207 BufferedReader br = new BufferedReader(reader); 355 208 356 if (listener != null) {357 listener.filesDropped(createFileArray(br , out));209 if (listener != null) { 210 listener.filesDropped(createFileArray(br)); 358 211 } 359 212 360 213 // Mark that drop is completed. 361 214 evt.getDropTargetContext().dropComplete(true); 362 log(out,"FileDrop: drop complete.");215 Main.debug("FileDrop: drop complete."); 363 216 handled = true; 364 217 break; … … 366 219 } 367 220 if(!handled){ 368 log( out,"FileDrop: not a file list or reader - abort." );221 Main.debug("FileDrop: not a file list or reader - abort." ); 369 222 evt.rejectDrop(); 370 223 } … … 372 225 } // end else: not a file list 373 226 } // end try 374 catch ( java.io.IOException io)375 { log( out,"FileDrop: IOException - abort:" );376 io.printStackTrace( out);227 catch ( IOException io) 228 { Main.warn("FileDrop: IOException - abort:" ); 229 io.printStackTrace(); 377 230 evt.rejectDrop(); 378 231 } // end catch IOException 379 catch ( java.awt.datatransfer.UnsupportedFlavorException ufe)380 { log( out,"FileDrop: UnsupportedFlavorException - abort:" );381 ufe.printStackTrace( out);232 catch (UnsupportedFlavorException ufe) 233 { Main.warn("FileDrop: UnsupportedFlavorException - abort:" ); 234 ufe.printStackTrace(); 382 235 evt.rejectDrop(); 383 236 } // end catch: UnsupportedFlavorException … … 385 238 { 386 239 // If it's a Swing component, reset its border 387 if( c instanceof javax.swing.JComponent )388 { javax.swing.JComponent jc = (javax.swing.JComponent) c;240 if( c instanceof JComponent ) 241 { JComponent jc = (JComponent) c; 389 242 jc.setBorder( normalBorder ); 390 log( out,"FileDrop: normal border restored." );243 Main.debug("FileDrop: normal border restored." ); 391 244 } // end if: JComponent 392 245 } // end finally … … 394 247 395 248 @Override 396 public void dragExit( java.awt.dnd.DropTargetEvent evt )397 { log( out,"FileDrop: dragExit event." );249 public void dragExit( DropTargetEvent evt ) 250 { Main.debug("FileDrop: dragExit event." ); 398 251 // If it's a Swing component, reset its border 399 if( c instanceof javax.swing.JComponent )400 { javax.swing.JComponent jc = (javax.swing.JComponent) c;252 if( c instanceof JComponent ) 253 { JComponent jc = (JComponent) c; 401 254 jc.setBorder( normalBorder ); 402 log( out,"FileDrop: normal border restored." );255 Main.debug("FileDrop: normal border restored." ); 403 256 } // end if: JComponent 404 257 } // end dragExit 405 258 406 259 @Override 407 public void dropActionChanged( java.awt.dnd.DropTargetDragEvent evt )408 { log( out,"FileDrop: dropActionChanged event." );260 public void dropActionChanged( DropTargetDragEvent evt ) 261 { Main.debug("FileDrop: dropActionChanged event." ); 409 262 // Is this an acceptable drag event? 410 if( isDragOk( out,evt ) )411 { //evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY_OR_MOVE );412 evt.acceptDrag( java.awt.dnd.DnDConstants.ACTION_COPY );413 log( out,"FileDrop: event accepted." );263 if( isDragOk( evt ) ) 264 { 265 evt.acceptDrag( DnDConstants.ACTION_COPY ); 266 Main.debug("FileDrop: event accepted." ); 414 267 } // end if: drag ok 415 268 else 416 269 { evt.rejectDrag(); 417 log( out,"FileDrop: event rejected." );270 Main.debug("FileDrop: event rejected." ); 418 271 } // end else: drag not ok 419 272 } // end dropActionChanged … … 421 274 422 275 // Make the component (and possibly children) drop targets 423 makeDropTarget( out,c, recursive );276 makeDropTarget( c, recursive ); 424 277 } // end if: supports dnd 425 278 else 426 { log( out,"FileDrop: Drag and drop is not supported with this JVM" );279 { Main.info("FileDrop: Drag and drop is not supported with this JVM" ); 427 280 } // end else: does not support DnD 428 281 } // end constructor … … 446 299 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 447 300 private static String ZERO_CHAR_STRING = "" + (char)0; 448 private static File[] createFileArray(BufferedReader bReader , PrintStream out)301 private static File[] createFileArray(BufferedReader bReader) 449 302 { 450 303 try { 451 java.util.List<File> list = new java.util.ArrayList<File>();452 java.lang.String line = null;304 List<File> list = new ArrayList<File>(); 305 String line = null; 453 306 while ((line = bReader.readLine()) != null) { 454 307 try { 455 308 // kde seems to append a 0 char to the end of the reader 456 if (ZERO_CHAR_STRING.equals(line)) {309 if (ZERO_CHAR_STRING.equals(line)) { 457 310 continue; 458 311 } 459 312 460 java.io.File file = new java.io.File(new java.net.URI(line));313 File file = new File(new URI(line)); 461 314 list.add(file); 462 315 } catch (Exception ex) { 463 log(out,"Error with " + line + ": " + ex.getMessage());316 Main.warn("Error with " + line + ": " + ex.getMessage()); 464 317 } 465 318 } … … 467 320 return list.toArray(new File[list.size()]); 468 321 } catch (IOException ex) { 469 log(out,"FileDrop: IOException");322 Main.warn("FileDrop: IOException"); 470 323 } 471 324 return new File[0]; … … 473 326 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 474 327 475 private void makeDropTarget( final java.io.PrintStream out, final java.awt.Component c, boolean recursive )328 private void makeDropTarget( final Component c, boolean recursive ) 476 329 { 477 330 // Make drop target 478 final java.awt.dnd.DropTarget dt = new java.awt.dnd.DropTarget();331 final DropTarget dt = new DropTarget(); 479 332 try 480 333 { dt.addDropTargetListener( dropListener ); 481 334 } // end try 482 catch( java.util.TooManyListenersException e )335 catch( TooManyListenersException e ) 483 336 { e.printStackTrace(); 484 log(out,"FileDrop: Drop will not work due to previous error. Do you have another listener attached?" );337 Main.warn("FileDrop: Drop will not work due to previous error. Do you have another listener attached?" ); 485 338 } // end catch 486 339 487 340 // Listen for hierarchy changes and remove the drop target when the parent gets cleared out. 488 c.addHierarchyListener( new java.awt.event.HierarchyListener()341 c.addHierarchyListener( new HierarchyListener() 489 342 { @Override 490 public void hierarchyChanged( java.awt.event.HierarchyEvent evt )491 { log( out,"FileDrop: Hierarchy changed." );492 java.awt.Component parent = c.getParent();343 public void hierarchyChanged( HierarchyEvent evt ) 344 { Main.debug("FileDrop: Hierarchy changed." ); 345 Component parent = c.getParent(); 493 346 if( parent == null ) 494 347 { c.setDropTarget( null ); 495 log( out,"FileDrop: Drop target cleared from component." );348 Main.debug("FileDrop: Drop target cleared from component." ); 496 349 } // end if: null parent 497 350 else 498 { new java.awt.dnd.DropTarget(c, dropListener);499 log( out,"FileDrop: Drop target added to component." );351 { new DropTarget(c, dropListener); 352 Main.debug("FileDrop: Drop target added to component." ); 500 353 } // end else: parent not null 501 354 } // end hierarchyChanged 502 355 }); // end hierarchy listener 503 356 if( c.getParent() != null ) { 504 new java.awt.dnd.DropTarget(c, dropListener);357 new DropTarget(c, dropListener); 505 358 } 506 359 507 if( recursive && (c instanceof java.awt.Container ) )360 if( recursive && (c instanceof Container ) ) 508 361 { 509 362 // Get the container 510 java.awt.Container cont = (java.awt.Container) c;363 Container cont = (Container) c; 511 364 512 365 // Get it's components 513 java.awt.Component[] comps = cont.getComponents();366 Component[] comps = cont.getComponents(); 514 367 515 368 // Set it's components as listeners also 516 for ( int i = 0; i < comps.length; i++) {517 makeDropTarget( out, comps[i], recursive);369 for (Component comp : comps) { 370 makeDropTarget( comp, recursive); 518 371 } 519 372 } // end if: recursively set components as listener … … 521 374 522 375 /** Determine if the dragged data is a file list. */ 523 private boolean isDragOk( final java.io.PrintStream out, final java.awt.dnd.DropTargetDragEvent evt )376 private boolean isDragOk( final DropTargetDragEvent evt ) 524 377 { boolean ok = false; 525 378 526 379 // Get data flavors being dragged 527 java.awt.datatransfer.DataFlavor[] flavors = evt.getCurrentDataFlavors();380 DataFlavor[] flavors = evt.getCurrentDataFlavors(); 528 381 529 382 // See if any of the flavors are a file list … … 534 387 // Is the flavor a file list? 535 388 final DataFlavor curFlavor = flavors[i]; 536 if( curFlavor.equals( java.awt.datatransfer.DataFlavor.javaFileListFlavor ) ||389 if( curFlavor.equals( DataFlavor.javaFileListFlavor ) || 537 390 curFlavor.isRepresentationClassReader()){ 538 391 ok = true; … … 542 395 } // end while: through flavors 543 396 544 // If logging is enabled, show data flavors 545 if( out != null ) 546 { if( flavors.length == 0 ) { 547 log( out, "FileDrop: no data flavors." ); 397 // show data flavors 398 if( flavors.length == 0 ) { 399 Main.debug("FileDrop: no data flavors." ); 548 400 } 549 401 for( i = 0; i < flavors.length; i++ ) { 550 log( out,flavors[i].toString() );402 Main.debug(flavors[i].toString() ); 551 403 } 552 } // end if: logging enabled553 404 554 405 return ok; 555 406 } // end isDragOk 556 557 /** Outputs <tt>message</tt> to <tt>out</tt> if it's not null. */558 private static void log( java.io.PrintStream out, String message )559 { // Log message if requested560 if( out != null ) {561 out.println( message );562 }563 } // end log564 407 565 408 /** … … 571 414 * 572 415 * @param c The component to unregister as a drop target 573 * @ since 1.0416 * @return {@code true} if at least one item has been removed, {@code false} otherwise 574 417 */ 575 public static boolean remove( java.awt.Component c)576 { return remove( null,c, true );418 public static boolean remove( Component c) 419 { return remove( c, true ); 577 420 } // end remove 578 421 … … 582 425 * components after you've set up the drag-and-drop. 583 426 * 584 * @param out Optional {@link java.io.PrintStream} for logging drag and drop messages585 427 * @param c The component to unregister 586 428 * @param recursive Recursively unregister components within a container 587 * @ since 1.0429 * @return {@code true} if at least one item has been removed, {@code false} otherwise 588 430 */ 589 public static boolean remove( java.io.PrintStream out, java.awt.Component c, boolean recursive )431 public static boolean remove( Component c, boolean recursive ) 590 432 { // Make sure we support dnd. 591 if( supportsDnD() ) 592 { log( out, "FileDrop: Removing drag-and-drop hooks." ); 593 c.setDropTarget( null ); 594 if( recursive && ( c instanceof java.awt.Container ) ) 595 { 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 } 599 return true; 600 } // end if: recursive 601 else return false; 433 if (supportsDnD()) { 434 Main.debug("FileDrop: Removing drag-and-drop hooks."); 435 c.setDropTarget(null); 436 if (recursive && (c instanceof Container)) { 437 for (Component comp : ((Container) c).getComponents()) { 438 remove(comp, recursive); 439 } 440 return true; 441 } // end if: recursive 442 else return false; 602 443 } // end if: supports DnD 603 444 else return false; … … 618 459 * ... 619 460 * </pre></code> 620 *621 * @since 1.1622 461 */ 623 462 public static interface Listener { … … 627 466 * 628 467 * @param files An array of <tt>File</tt>s that were dropped. 629 * @since 1.0 630 */ 631 public abstract void filesDropped( java.io.File[] files ); 468 */ 469 public abstract void filesDropped( File[] files ); 632 470 633 471 } // end inner-interface Listener … … 647 485 * @version 1.2 648 486 */ 649 public static class Event extends java.util.EventObject {650 651 private java.io.File[] files;487 public static class Event extends EventObject { 488 489 private File[] files; 652 490 653 491 /** … … 658 496 * @param files The array of files that were dropped 659 497 * @param source The event source 660 * @since 1.1 661 */ 662 public Event( java.io.File[] files, Object source ) { 498 */ 499 public Event( File[] files, Object source ) { 663 500 super( source ); 664 501 this.files = files; … … 670 507 * 671 508 * @return array of files that were dropped 672 * @since 1.1 673 */ 674 public java.io.File[] getFiles() { 509 */ 510 public File[] getFiles() { 675 511 return files; 676 512 } // end getFiles … … 722 558 * @version 1.2 723 559 */ 724 public static class TransferableObject implements java.awt.datatransfer.Transferable560 public static class TransferableObject implements Transferable 725 561 { 726 562 /** 727 563 * The MIME type for {@link #DATA_FLAVOR} is 728 564 * <tt>application/x-net.iharder.dnd.TransferableObject</tt>. 729 *730 * @since 1.1731 565 */ 732 566 public final static String MIME_TYPE = "application/x-net.iharder.dnd.TransferableObject"; … … 738 572 * and the MIME type 739 573 * <tt>application/x-net.iharder.dnd.TransferableObject</tt>. 740 * 741 * @since 1.1 742 */ 743 public final static java.awt.datatransfer.DataFlavor DATA_FLAVOR = 744 new java.awt.datatransfer.DataFlavor( FileDrop.TransferableObject.class, MIME_TYPE ); 574 */ 575 public final static DataFlavor DATA_FLAVOR = 576 new DataFlavor( FileDrop.TransferableObject.class, MIME_TYPE ); 745 577 746 578 private Fetcher fetcher; 747 579 private Object data; 748 580 749 private java.awt.datatransfer.DataFlavor customFlavor;581 private DataFlavor customFlavor; 750 582 751 583 /** … … 757 589 * 758 590 * @param data The data to transfer 759 * @since 1.1760 591 */ 761 592 public TransferableObject( Object data ) 762 593 { this.data = data; 763 this.customFlavor = new java.awt.datatransfer.DataFlavor( data.getClass(), MIME_TYPE );594 this.customFlavor = new DataFlavor( data.getClass(), MIME_TYPE ); 764 595 } // end constructor 765 596 … … 772 603 * @see Fetcher 773 604 * @param fetcher The {@link Fetcher} that will return the data object 774 * @since 1.1775 605 */ 776 606 public TransferableObject( Fetcher fetcher ) … … 789 619 * @param dataClass The {@link java.lang.Class} to use in the custom data flavor 790 620 * @param fetcher The {@link Fetcher} that will return the data object 791 * @since 1.1792 621 */ 793 622 public TransferableObject(Class<?> dataClass, Fetcher fetcher ) 794 623 { this.fetcher = fetcher; 795 this.customFlavor = new java.awt.datatransfer.DataFlavor( dataClass, MIME_TYPE );624 this.customFlavor = new DataFlavor( dataClass, MIME_TYPE ); 796 625 } // end constructor 797 626 … … 802 631 * 803 632 * @return The custom data flavor for the encapsulated object 804 * @since 1.1 805 */ 806 public java.awt.datatransfer.DataFlavor getCustomDataFlavor() 633 */ 634 public DataFlavor getCustomDataFlavor() 807 635 { return customFlavor; 808 636 } // end getCustomDataFlavor … … 815 643 * second the default {@link #DATA_FLAVOR} associated with 816 644 * {@link TransferableObject}, and third the 817 * {@link java.awt.datatransfer.DataFlavor .stringFlavor}.645 * {@link java.awt.datatransfer.DataFlavor#stringFlavor}. 818 646 * 819 647 * @return An array of supported data flavors 820 * @since 1.1821 648 */ 822 649 @Override 823 public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()650 public DataFlavor[] getTransferDataFlavors() 824 651 { 825 652 if( customFlavor != null ) 826 return new java.awt.datatransfer.DataFlavor[]653 return new DataFlavor[] 827 654 { customFlavor, 828 655 DATA_FLAVOR, 829 java.awt.datatransfer.DataFlavor.stringFlavor656 DataFlavor.stringFlavor 830 657 }; // end flavors array 831 658 else 832 return new java.awt.datatransfer.DataFlavor[]659 return new DataFlavor[] 833 660 { DATA_FLAVOR, 834 java.awt.datatransfer.DataFlavor.stringFlavor661 DataFlavor.stringFlavor 835 662 }; // end flavors array 836 663 } // end getTransferDataFlavors … … 845 672 * @param flavor The data flavor for the data to return 846 673 * @return The dropped data 847 * @since 1.1848 674 */ 849 675 @Override 850 public Object getTransferData( java.awt.datatransfer.DataFlavor flavor )851 throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException676 public Object getTransferData( DataFlavor flavor ) 677 throws UnsupportedFlavorException, IOException 852 678 { 853 679 // Native object … … 856 682 857 683 // String 858 if( flavor.equals( java.awt.datatransfer.DataFlavor.stringFlavor ) )684 if( flavor.equals( DataFlavor.stringFlavor ) ) 859 685 return fetcher == null ? data.toString() : fetcher.getObject().toString(); 860 686 861 687 // We can't do anything else 862 throw new java.awt.datatransfer.UnsupportedFlavorException(flavor);688 throw new UnsupportedFlavorException(flavor); 863 689 } // end getTransferData 864 690 … … 869 695 * @param flavor The data flavor to check 870 696 * @return Whether or not the flavor is supported 871 * @since 1.1872 697 */ 873 698 @Override 874 public boolean isDataFlavorSupported( java.awt.datatransfer.DataFlavor flavor )699 public boolean isDataFlavorSupported( DataFlavor flavor ) 875 700 { 876 701 // Native object … … 879 704 880 705 // String 881 if( flavor.equals( java.awt.datatransfer.DataFlavor.stringFlavor ) )706 if( flavor.equals( DataFlavor.stringFlavor ) ) 882 707 return true; 883 708 … … 897 722 * 898 723 * @author Robert Harder 899 * @since 1.1900 724 */ 901 725 public static interface Fetcher … … 906 730 * 907 731 * @return The dropped object 908 * @since 1.1909 732 */ 910 733 public abstract Object getObject(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictDialog.java
r6084 r6104 16 16 import java.util.Collection; 17 17 import java.util.HashSet; 18 import java.util.Iterator;19 18 import java.util.LinkedList; 20 19 import java.util.Set; … … 382 381 getSize() 383 382 ); 384 Iterator<ListDataListener> it = listeners.iterator(); 385 while(it.hasNext()) { 386 it.next().contentsChanged(evt); 383 for (ListDataListener listener : listeners) { 384 listener.contentsChanged(evt); 387 385 } 388 386 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r6093 r6104 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 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r6092 r6104 26 26 import java.util.Collections; 27 27 import java.util.EnumSet; 28 import java.util.HashMap;29 28 import java.util.HashSet; 30 import java.util.Iterator;31 29 import java.util.List; 32 import java.util.Map;33 30 import java.util.Set; 34 31 … … 773 770 return primitives; 774 771 ArrayList<OsmPrimitive> ret = new ArrayList<OsmPrimitive>(); 775 Iterator<OsmPrimitive> it = primitives.iterator(); 776 while(it.hasNext()) { 777 OsmPrimitive primitive = it.next(); 772 for (OsmPrimitive primitive : primitives) { 778 773 if (primitive instanceof Relation && getRelation() != null && getRelation().equals(primitive)) { 779 774 warnOfCircularReferences(primitive); 780 775 continue; 781 776 } 782 if (isPotentialDuplicate(primitive)) 777 if (isPotentialDuplicate(primitive)) { 783 778 if (confirmAddingPrimitive(primitive)) { 784 779 ret.add(primitive); -
trunk/src/org/openstreetmap/josm/gui/download/BoundingBoxSelection.java
r6101 r6104 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 } -
trunk/src/org/openstreetmap/josm/gui/io/ActionFlagsTableCell.java
r6084 r6104 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)); -
trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java
r5969 r6104 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 } -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/CorrelateGpxWithImages.java
r6093 r6104 34 34 import java.util.Date; 35 35 import java.util.Hashtable; 36 import java.util.Iterator;37 36 import java.util.List; 38 37 import java.util.TimeZone; … … 452 451 Collection<Layer> layerLst = Main.map.mapView.getAllLayers(); 453 452 GpxDataWrapper defaultItem = null; 454 Iterator<Layer> iterLayer = layerLst.iterator(); 455 while (iterLayer.hasNext()) { 456 Layer cur = iterLayer.next(); 453 for (Layer cur : layerLst) { 457 454 if (cur instanceof GpxLayer) { 458 455 GpxLayer curGpx = (GpxLayer) cur; -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ImportAudioAction.java
r6083 r6104 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 = " ("; … … 97 97 names += ", "; 98 98 } 99 names += sel[i].getName();99 names += file.getName(); 100 100 } 101 101 if (names != null) { … … 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); -
trunk/src/org/openstreetmap/josm/gui/mappaint/MapPaintStyles.java
r6083 r6104 11 11 import java.util.Arrays; 12 12 import java.util.Collection; 13 import java.util.Iterator;14 13 import java.util.LinkedList; 15 14 import java.util.List; … … 135 134 StyleList styleList = getStyles().generateStyles(virtualNode, 0.5, null, false).a; 136 135 if (styleList != null) { 137 for (Iterator<ElemStyle> it = styleList.iterator(); it.hasNext(); ) { 138 ElemStyle style = it.next(); 136 for (ElemStyle style : styleList) { 139 137 if (style instanceof NodeElemStyle) { 140 138 MapImage mapImage = ((NodeElemStyle) style).mapImage; -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreference.java
r6084 r6104 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 -
trunk/src/org/openstreetmap/josm/io/OsmServerChangesetReader.java
r5832 r6104 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; … … 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()) { -
trunk/src/org/openstreetmap/josm/io/remotecontrol/AddTagsDialog.java
r6085 r6104 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 } -
trunk/src/org/openstreetmap/josm/tools/FallbackDateParser.java
r3719 r6104 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 -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r6103 r6104 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]); 286 } 287 else { 288 files[i].delete(); 283 for (File file : files) { 284 if (file.isDirectory()) { 285 deleteDirectory(file); 286 } else { 287 file.delete(); 289 288 } 290 289 } -
trunk/src/org/openstreetmap/josm/tools/WindowGeometry.java
r6087 r6104 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()); … … 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; … … 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;
Note:
See TracChangeset
for help on using the changeset viewer.