Changeset 8342 in josm
- Timestamp:
- 2015-05-09T12:49:35+02:00 (10 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 47 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/Main.java
r8291 r8342 916 916 try { 917 917 UIManager.setLookAndFeel(laf); 918 } 919 catch (final NoClassDefFoundError | ClassNotFoundException e) { 918 } catch (final NoClassDefFoundError | ClassNotFoundException e) { 920 919 // Try to find look and feel in plugin classloaders 921 920 Class<?> klass = null; … … 938 937 Main.pref.put("laf", defaultlaf); 939 938 } 940 } 941 catch (final UnsupportedLookAndFeelException e) { 939 } catch (final UnsupportedLookAndFeelException e) { 942 940 info("Look and Feel not supported: " + laf); 943 941 Main.pref.put("laf", defaultlaf); -
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r8308 r8342 119 119 tree.getSelectedLayers(), (String) formats.getSelectedItem()); 120 120 return new ImageryInfo(info.getName(), url, "wms", info.getEulaAcceptanceRequired(), info.getCookies()); 121 } // exception handling from AddWMSLayerPanel.java 122 catch (MalformedURLException ex) { 121 } catch (MalformedURLException ex) { 123 122 JOptionPane.showMessageDialog(Main.parent, tr("Invalid service URL."), 124 123 tr("WMS Error"), JOptionPane.ERROR_MESSAGE); -
trunk/src/org/openstreetmap/josm/actions/AlignInLineAction.java
r8318 r8342 171 171 try { 172 172 Command cmd = null; 173 //// Decide what to align based on selection: 174 175 /// Only ways selected -> For each way align their nodes taking care of intersection 173 // Decide what to align based on selection: 174 176 175 if(selectedNodes.isEmpty() && !selectedWays.isEmpty()) { 176 // Only ways selected -> For each way align their nodes taking care of intersection 177 177 cmd = alignMultiWay(selectedWays); 178 } 179 /// Only 1 node selected -> align this node relative to referers way 180 else if(selectedNodes.size() == 1) { 178 } else if(selectedNodes.size() == 1) { 179 // Only 1 node selected -> align this node relative to referers way 181 180 Node selectedNode = selectedNodes.get(0); 182 181 List<Way> involvedWays = null; 183 182 if(selectedWays.isEmpty()) 184 // /No selected way, all way containing this node are used183 // No selected way, all way containing this node are used 185 184 involvedWays = OsmPrimitive.getFilteredList(selectedNode.getReferrers(), Way.class); 186 185 else 187 // /Selected way, use only these ways186 // Selected way, use only these ways 188 187 involvedWays = selectedWays; 189 188 List<Line> lines = getInvolvedLines(selectedNode, involvedWays); … … 191 190 throw new InvalidSelection(); 192 191 cmd = alignSingleNode(selectedNodes.get(0), lines); 193 } 194 // More than 3 nodes and way(s) selected -> align selected nodes. Don't care of way(s). 195 else if(selectedNodes.size() >= 3) { 192 } else if(selectedNodes.size() >= 3) { 193 // More than 3 nodes and way(s) selected -> align selected nodes. Don't care of way(s). 196 194 cmd = alignOnlyNodes(selectedNodes); 197 } 198 /// All others cases are invalid 199 else { 195 } else { 196 // All others cases are invalid 200 197 throw new InvalidSelection(); 201 198 } … … 257 254 if(n == way.firstNode() || n == way.lastNode()) continue; 258 255 cmds.add(lines.get(way).projectionCommand(n)); 259 } 260 else if(referers.size() == 2) { 256 } else if(referers.size() == 2) { 261 257 Command cmd = lines.get(referers.get(0)).intersectionCommand(n, lines.get(referers.get(1))); 262 258 cmds.add(cmd); 263 } 264 else 259 } else 265 260 throw new InvalidSelection(tr("Intersection of three or more ways can not be solved. Abort.")); 266 261 } -
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r8338 r8342 150 150 nodes.add(way.way.getNode(pos)); 151 151 } 152 } 153 else { 152 } else { 154 153 for (int pos = way.way.getNodesCount() - 1; pos > 0; pos--) { 155 154 nodes.add(way.way.getNode(pos)); … … 1292 1291 outerWays.add(rm.getWay()); 1293 1292 hasKnownOuter |= selectedWays.contains(rm.getWay()); 1294 } 1295 else if ("inner".equalsIgnoreCase(rm.getRole())) { 1293 } else if ("inner".equalsIgnoreCase(rm.getRole())) { 1296 1294 innerWays.add(rm.getWay()); 1297 1295 } -
trunk/src/org/openstreetmap/josm/actions/OrthogonalizeAction.java
r8338 r8342 114 114 Main.map.repaint(); 115 115 } else throw new InvalidUserInputException(); 116 } 117 catch (InvalidUserInputException ex) { 116 } catch (InvalidUserInputException ex) { 118 117 new Notification( 119 118 tr("Orthogonalize Shape / Undo<br>"+ … … 154 153 if (p instanceof Node) { 155 154 nodeList.add((Node) p); 156 } 157 else if (p instanceof Way) { 155 } else if (p instanceof Way) { 158 156 wayDataList.add(new WayData((Way) p)); 159 157 } else … … 169 167 if (nodeList.size() == 2) { // fixed direction 170 168 commands.addAll(orthogonalize(wayDataList, nodeList)); 171 } 172 else if (nodeList.isEmpty()) { 169 } else if (nodeList.isEmpty()) { 173 170 List<List<WayData>> groups = buildGroups(wayDataList); 174 171 for (List<WayData> g: groups) { … … 267 264 } 268 265 headingAll = EN.polar(new EastNorth(0., 0.), totSum); 269 } 270 else { 266 } else { 271 267 headingAll = EN.polar(headingNodes.get(0).getEastNorth(), headingNodes.get(1).getEastNorth()); 272 268 for (WayData w : wayDataList) { … … 392 388 Math.abs(dy) > Math.abs(EPSILON * tmp.east())) 393 389 throw new AssertionError(); 394 } 395 else { 390 } else { 396 391 OrthogonalizeAction.rememberMovements.put(n, new EastNorth(dx, dy)); 397 392 commands.add(new MoveCommand(n, dx, dy)); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r8338 r8342 529 529 // double click adds a new node 530 530 addNewNode(e); 531 } 532 else if (e.getPoint().distance(initialMousePos) > initialMoveThreshold && newN1en != null && selectedSegment != null) { 531 } else if (e.getPoint().distance(initialMousePos) > initialMoveThreshold && newN1en != null && selectedSegment != null) { 533 532 // main extrusion commands 534 533 performExtrusion(); … … 1177 1176 1178 1177 return new Line2D.Double(start, new Point2D.Double(start.getX() + (unitvector.getX() * linelength) , start.getY() + (unitvector.getY() * linelength))); 1179 } 1180 catch (NoninvertibleTransformException e) { 1178 } catch (NoninvertibleTransformException e) { 1181 1179 return new Line2D.Double(start, new Point2D.Double(start.getX() + (unitvector.getX() * 10) , start.getY() + (unitvector.getY() * 10))); 1182 1180 } -
trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java
r8338 r8342 97 97 // new value is null and tag exists (will delete tag) 98 98 modified = true; 99 } 100 else if (oldVal == null || !newVal.equals(oldVal)) 99 } else if (oldVal == null || !newVal.equals(oldVal)) 101 100 // new value is not null and is different from current value 102 101 modified = true; … … 121 120 if (oldVal != null) 122 121 osm.remove(tag.getKey()); 123 } 124 else if (oldVal == null || !newVal.equals(oldVal)) 122 } else if (oldVal == null || !newVal.equals(oldVal)) 125 123 osm.put(tag.getKey(), newVal); 126 124 } … … 130 128 } 131 129 return true; 132 } 133 finally { 130 } finally { 134 131 Main.main.getCurrentDataSet().endUpdate(); 135 132 } … … 171 168 text = trn("Set {0}={1} for {2} object", "Set {0}={1} for {2} objects", objects.size(), entry.getKey(), entry.getValue(), objects.size()); 172 169 } 173 } 174 else { 170 } else { 175 171 boolean allnull = true; 176 172 for (Map.Entry<String, String> tag : this.tags.entrySet()) { -
trunk/src/org/openstreetmap/josm/data/UndoRedoHandler.java
r7005 r8342 96 96 } 97 97 } 98 } 99 finally { 98 } finally { 100 99 Main.main.getCurrentDataSet().endUpdate(); 101 100 } -
trunk/src/org/openstreetmap/josm/data/osm/User.java
r8155 r8342 228 228 if (names.size() == 1) { 229 229 s.append(" name:").append(getName()); 230 } 231 else if (names.size() > 1) { 230 } else if (names.size() > 1) { 232 231 s.append(String.format(" %d names:%s", names.size(), getName())); 233 232 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/LineClip.java
r7040 r8342 72 72 accept = true; 73 73 done = true; 74 } 75 else if ( (outcode0 & outcode1) > 0 ) { 74 } else if ( (outcode0 & outcode1) > 0 ) { 76 75 done = true; 77 } 78 else { 76 } else { 79 77 long x = 0, y = 0; 80 78 outcodeOut = outcode0 != 0 ? outcode0: outcode1; … … 82 80 x = x1 + (x2 - x1) * (ymax - y1)/(y2 - y1); 83 81 y = ymax; 84 } 85 else if ((outcodeOut & OUT_BOTTOM) > 0 ) { 82 } else if ((outcodeOut & OUT_BOTTOM) > 0 ) { 86 83 x = x1 + (x2 - x1) * (ymin - y1)/(y2 - y1); 87 84 y = ymin; 88 } 89 else if ((outcodeOut & OUT_RIGHT)> 0) { 85 } else if ((outcodeOut & OUT_RIGHT)> 0) { 90 86 y = y1 + (y2 - y1) * (xmax - x1)/(x2 - x1); 91 87 x = xmax; 92 } 93 else if ((outcodeOut & OUT_LEFT) > 0) { 88 } else if ((outcodeOut & OUT_LEFT) > 0) { 94 89 y = y1 + (y2 - y1) * (xmin - x1)/(x2 - x1); 95 90 x = xmin; … … 124 119 if (y > ymax) { 125 120 code |= OUT_TOP; 126 } 127 else if (y < ymin) { 121 } else if (y < ymin) { 128 122 code |= OUT_BOTTOM; 129 123 } 130 124 if (x > xmax) { 131 125 code |= OUT_RIGHT; 132 } 133 else if (x < xmin) { 126 } else if (x < xmin) { 134 127 code |= OUT_LEFT; 135 128 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRenderer.java
r8318 r8342 946 946 947 947 Node viaNode; 948 if(via instanceof Node) 949 { 948 if(via instanceof Node) { 950 949 viaNode = (Node) via; 951 950 if(!fromWay.isFirstLastNode(viaNode)) 952 951 return; 953 } 954 else 955 { 952 } else { 956 953 Way viaWay = (Way) via; 957 954 Node firstNode = viaWay.firstNode(); … … 960 957 961 958 String onewayviastr = viaWay.get("oneway"); 962 if(onewayviastr != null) 963 { 959 if(onewayviastr != null) { 964 960 if("-1".equals(onewayviastr)) { 965 961 onewayvia = true; -
trunk/src/org/openstreetmap/josm/data/validation/tests/Coastlines.java
r7005 r8342 189 189 errors.add(new TestError(this, Severity.ERROR, tr("Unordered coastline"), 190 190 UNORDERED_COASTLINE, primitives, highlight)); 191 } 192 else if (reversed) { 191 } else if (reversed) { 193 192 errors.add(new TestError(this, Severity.ERROR, tr("Reversed coastline"), 194 193 REVERSED_COASTLINE, primitives)); -
trunk/src/org/openstreetmap/josm/data/validation/tests/OverlappingWays.java
r7005 r8342 132 132 type = OVERLAPPING_WAY_AREA; 133 133 } 134 } 135 else if (highway == ways) { 134 } else if (highway == ways) { 136 135 errortype = tr("Overlapping highways"); 137 136 type = OVERLAPPING_HIGHWAY; -
trunk/src/org/openstreetmap/josm/data/validation/tests/RelationChecker.java
r8338 r8342 323 323 errors.add(new TestError(this, Severity.WARNING, ROLE_VERIF_PROBLEM_MSG, 324 324 tr(s, keyname), MessageFormat.format(s, keyname), ROLE_MISSING, n)); 325 } 326 else if (vc > count) { 325 } else if (vc > count) { 327 326 String s = marktr("Number of {0} roles too low ({1})"); 328 327 errors.add(new TestError(this, Severity.WARNING, ROLE_VERIF_PROBLEM_MSG, -
trunk/src/org/openstreetmap/josm/gui/DefaultNameFormatter.java
r8126 r8342 168 168 before street for better visibility */ 169 169 n = tr("House number {0} at {1}", s, t); 170 } 171 else { 170 } else { 172 171 /* I18n: house number as parameter */ 173 172 n = tr("House number {0}", s); … … 267 266 before street for better visibility */ 268 267 n = tr("House number {0} at {1}", s, t); 269 } 270 else { 268 } else { 271 269 /* I18n: house number as parameter */ 272 270 n = tr("House number {0}", s); -
trunk/src/org/openstreetmap/josm/gui/FileDrop.java
r8290 r8342 34 34 import org.openstreetmap.josm.Main; 35 35 import org.openstreetmap.josm.actions.OpenFileAction; 36 import org.openstreetmap.josm.gui.FileDrop.TransferableObject; 36 37 37 38 /** … … 75 76 * @since 1231 76 77 */ 77 public class FileDrop 78 { 78 public class FileDrop { 79 79 80 private Border normalBorder; 80 81 private DropTargetListener dropListener; … … 123 124 final Border dragBorder, 124 125 final boolean recursive, 125 final Listener listener) 126 { 127 128 if( supportsDnD() ) 129 { // Make a drop listener 130 dropListener = new DropTargetListener() 131 { @Override 132 public void dragEnter( DropTargetDragEvent evt ) 133 { Main.trace("FileDrop: dragEnter event." ); 134 135 // Is this an acceptable drag event? 136 if( isDragOk( evt ) ) 137 { 138 // If it's a Swing component, set its border 139 if( c instanceof JComponent ) 140 { JComponent jc = (JComponent) c; 141 normalBorder = jc.getBorder(); 142 Main.trace("FileDrop: normal border saved." ); 143 jc.setBorder( dragBorder ); 144 Main.trace("FileDrop: drag border set." ); 145 } // end if: JComponent 146 147 // Acknowledge that it's okay to enter 148 evt.acceptDrag( DnDConstants.ACTION_COPY ); 149 Main.trace("FileDrop: event accepted." ); 150 } // end if: drag ok 151 else 152 { // Reject the drag event 153 evt.rejectDrag(); 154 Main.trace("FileDrop: event rejected." ); 155 } // end else: drag not ok 156 } // end dragEnter 157 158 @Override 159 public void dragOver( DropTargetDragEvent evt ) 160 { // This is called continually as long as the mouse is 161 // over the drag target. 162 } // end dragOver 163 164 @Override 165 public void drop( DropTargetDropEvent evt ) 166 { Main.trace("FileDrop: drop event." ); 167 try 168 { // Get whatever was dropped 169 Transferable tr = evt.getTransferable(); 170 171 // Is it a file list? 172 if (tr.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) 173 { 174 // Say we'll take it. 175 evt.acceptDrop ( DnDConstants.ACTION_COPY ); 176 Main.trace("FileDrop: file list accepted." ); 177 178 // Get a useful list 179 List<?> fileList = (List<?>)tr.getTransferData(DataFlavor.javaFileListFlavor); 180 181 // Convert list to array 182 final File[] files = fileList.toArray(new File[fileList.size()]); 183 184 // Alert listener to drop. 185 if( listener != null ) { 186 listener.filesDropped( files ); 126 final Listener listener) { 127 128 if( supportsDnD() ) { 129 // Make a drop listener 130 dropListener = new DropTargetListener() { 131 @Override 132 public void dragEnter( DropTargetDragEvent evt ) { 133 Main.trace("FileDrop: dragEnter event." ); 134 135 // Is this an acceptable drag event? 136 if( isDragOk( evt ) ) { 137 // If it's a Swing component, set its border 138 if( c instanceof JComponent ) { 139 JComponent jc = (JComponent) c; 140 normalBorder = jc.getBorder(); 141 Main.trace("FileDrop: normal border saved." ); 142 jc.setBorder( dragBorder ); 143 Main.trace("FileDrop: drag border set." ); 144 } 145 146 // Acknowledge that it's okay to enter 147 evt.acceptDrag( DnDConstants.ACTION_COPY ); 148 Main.trace("FileDrop: event accepted." ); 149 } else { 150 // Reject the drag event 151 evt.rejectDrag(); 152 Main.trace("FileDrop: event rejected." ); 187 153 } 188 189 // Mark that drop is completed. 190 evt.getDropTargetContext().dropComplete(true); 191 Main.trace("FileDrop: drop complete." ); 192 } // end if: file list 193 else // this section will check for a reader flavor. 194 { 195 // Thanks, Nathan! 196 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 197 DataFlavor[] flavors = tr.getTransferDataFlavors(); 198 boolean handled = false; 199 for (DataFlavor flavor : flavors) { 200 if (flavor.isRepresentationClassReader()) { 154 } 155 156 @Override 157 public void dragOver( DropTargetDragEvent evt ) { 158 // This is called continually as long as the mouse is over the drag target. 159 } 160 161 @Override 162 public void drop( DropTargetDropEvent evt ) { 163 Main.trace("FileDrop: drop event." ); 164 try { 165 // Get whatever was dropped 166 Transferable tr = evt.getTransferable(); 167 168 // Is it a file list? 169 if (tr.isDataFlavorSupported (DataFlavor.javaFileListFlavor)) { 170 201 171 // Say we'll take it. 202 evt.acceptDrop(DnDConstants.ACTION_COPY); 203 Main.trace("FileDrop: reader accepted."); 204 205 Reader reader = flavor.getReaderForText(tr); 206 207 BufferedReader br = new BufferedReader(reader); 208 209 if (listener != null) { 210 listener.filesDropped(createFileArray(br)); 172 evt.acceptDrop ( DnDConstants.ACTION_COPY ); 173 Main.trace("FileDrop: file list accepted." ); 174 175 // Get a useful list 176 List<?> fileList = (List<?>)tr.getTransferData(DataFlavor.javaFileListFlavor); 177 178 // Convert list to array 179 final File[] files = fileList.toArray(new File[fileList.size()]); 180 181 // Alert listener to drop. 182 if( listener != null ) { 183 listener.filesDropped( files ); 211 184 } 212 185 213 186 // Mark that drop is completed. 214 187 evt.getDropTargetContext().dropComplete(true); 215 Main.trace("FileDrop: drop complete."); 216 handled = true; 217 break; 188 Main.trace("FileDrop: drop complete." ); 189 } else { 190 // this section will check for a reader flavor. 191 // Thanks, Nathan! 192 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 193 DataFlavor[] flavors = tr.getTransferDataFlavors(); 194 boolean handled = false; 195 for (DataFlavor flavor : flavors) { 196 if (flavor.isRepresentationClassReader()) { 197 // Say we'll take it. 198 evt.acceptDrop(DnDConstants.ACTION_COPY); 199 Main.trace("FileDrop: reader accepted."); 200 201 Reader reader = flavor.getReaderForText(tr); 202 203 BufferedReader br = new BufferedReader(reader); 204 205 if (listener != null) { 206 listener.filesDropped(createFileArray(br)); 207 } 208 209 // Mark that drop is completed. 210 evt.getDropTargetContext().dropComplete(true); 211 Main.trace("FileDrop: drop complete."); 212 handled = true; 213 break; 214 } 215 } 216 if(!handled){ 217 Main.trace("FileDrop: not a file list or reader - abort." ); 218 evt.rejectDrop(); 219 } 220 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 221 } 222 } catch (IOException | UnsupportedFlavorException e) { 223 Main.warn("FileDrop: "+e.getClass().getSimpleName()+" - abort:" ); 224 Main.error(e); 225 try { 226 evt.rejectDrop(); 227 } catch (InvalidDnDOperationException ex) { 228 // Catch InvalidDnDOperationException to fix #11259 229 Main.error(ex); 230 } 231 } finally { 232 // If it's a Swing component, reset its border 233 if( c instanceof JComponent ) { 234 JComponent jc = (JComponent) c; 235 jc.setBorder( normalBorder ); 236 Main.debug("FileDrop: normal border restored." ); 218 237 } 219 238 } 220 if(!handled){ 221 Main.trace("FileDrop: not a file list or reader - abort." ); 222 evt.rejectDrop(); 239 } 240 241 @Override 242 public void dragExit( DropTargetEvent evt ) { 243 Main.debug("FileDrop: dragExit event." ); 244 // If it's a Swing component, reset its border 245 if( c instanceof JComponent ) { 246 JComponent jc = (JComponent) c; 247 jc.setBorder( normalBorder ); 248 Main.debug("FileDrop: normal border restored." ); 223 249 } 224 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 225 } // end else: not a file list 226 } // end try 227 catch (IOException | UnsupportedFlavorException e) { 228 Main.warn("FileDrop: "+e.getClass().getSimpleName()+" - abort:" ); 229 Main.error(e); 230 try { 231 evt.rejectDrop(); 232 } catch (InvalidDnDOperationException ex) { 233 // Catch InvalidDnDOperationException to fix #11259 234 Main.error(ex); 235 } 236 } finally { 237 // If it's a Swing component, reset its border 238 if( c instanceof JComponent ) 239 { JComponent jc = (JComponent) c; 240 jc.setBorder( normalBorder ); 241 Main.debug("FileDrop: normal border restored." ); 242 } // end if: JComponent 243 } // end finally 244 } // end drop 245 246 @Override 247 public void dragExit( DropTargetEvent evt ) 248 { Main.debug("FileDrop: dragExit event." ); 249 // If it's a Swing component, reset its border 250 if( c instanceof JComponent ) 251 { JComponent jc = (JComponent) c; 252 jc.setBorder( normalBorder ); 253 Main.debug("FileDrop: normal border restored." ); 254 } // end if: JComponent 255 } // end dragExit 256 257 @Override 258 public void dropActionChanged( DropTargetDragEvent evt ) 259 { Main.debug("FileDrop: dropActionChanged event." ); 260 // Is this an acceptable drag event? 261 if( isDragOk( evt ) ) 262 { 263 evt.acceptDrag( DnDConstants.ACTION_COPY ); 264 Main.debug("FileDrop: event accepted." ); 265 } // end if: drag ok 266 else 267 { evt.rejectDrag(); 268 Main.debug("FileDrop: event rejected." ); 269 } // end else: drag not ok 270 } // end dropActionChanged 271 }; // end DropTargetListener 250 } 251 252 @Override 253 public void dropActionChanged( DropTargetDragEvent evt ) { 254 Main.debug("FileDrop: dropActionChanged event." ); 255 // Is this an acceptable drag event? 256 if( isDragOk( evt ) ) { 257 evt.acceptDrag( DnDConstants.ACTION_COPY ); 258 Main.debug("FileDrop: event accepted." ); 259 } else { 260 evt.rejectDrag(); 261 Main.debug("FileDrop: event rejected." ); 262 } 263 } 264 }; 272 265 273 266 // Make the component (and possibly children) drop targets 274 267 makeDropTarget( c, recursive ); 275 } // end if: supports dnd 276 else 277 { Main.info("FileDrop: Drag and drop is not supported with this JVM" ); 278 } // end else: does not support DnD 279 } // end constructor 280 281 private static synchronized boolean supportsDnD() 282 { // Static Boolean 283 if( supportsDnD == null ) 284 { 268 } else { 269 Main.info("FileDrop: Drag and drop is not supported with this JVM" ); 270 } 271 } 272 273 private static synchronized boolean supportsDnD() { 274 if( supportsDnD == null ) { 285 275 boolean support = false; 286 276 try { … … 291 281 } 292 282 supportsDnD = support; 293 } // end if: first time through283 } 294 284 return supportsDnD.booleanValue(); 295 } // end supportsDnD285 } 296 286 297 287 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 298 288 private static final String ZERO_CHAR_STRING = "" + (char)0; 299 private static File[] createFileArray(BufferedReader bReader) 300 { 289 private static File[] createFileArray(BufferedReader bReader) { 301 290 try { 302 291 List<File> list = new ArrayList<>(); … … 324 313 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 325 314 326 private void makeDropTarget( final Component c, boolean recursive ) 327 { 315 private void makeDropTarget( final Component c, boolean recursive ) { 328 316 // Make drop target 329 317 final DropTarget dt = new DropTarget(); 330 try 331 { dt.addDropTargetListener( dropListener ); 332 } // end try 333 catch( TooManyListenersException e ) 334 { Main.error(e); 335 Main.warn("FileDrop: Drop will not work due to previous error. Do you have another listener attached?" ); 336 } // end catch 318 try { 319 dt.addDropTargetListener( dropListener ); 320 } catch( TooManyListenersException e ) { 321 Main.error(e); 322 Main.warn("FileDrop: Drop will not work due to previous error. Do you have another listener attached?" ); 323 } 337 324 338 325 // Listen for hierarchy changes and remove the drop target when the parent gets cleared out. 339 c.addHierarchyListener( new HierarchyListener() 340 { @Override 341 public void hierarchyChanged( HierarchyEvent evt ) 342 { Main.trace("FileDrop: Hierarchy changed." ); 343 Component parent = c.getParent(); 344 if( parent == null ) 345 { c.setDropTarget( null ); 346 Main.trace("FileDrop: Drop target cleared from component." ); 347 } // end if: null parent 348 else 349 { new DropTarget(c, dropListener); 350 Main.trace("FileDrop: Drop target added to component." ); 351 } // end else: parent not null 352 } // end hierarchyChanged 353 }); // end hierarchy listener 326 c.addHierarchyListener( new HierarchyListener() { 327 @Override 328 public void hierarchyChanged( HierarchyEvent evt ) { 329 Main.trace("FileDrop: Hierarchy changed." ); 330 Component parent = c.getParent(); 331 if( parent == null ) { 332 c.setDropTarget( null ); 333 Main.trace("FileDrop: Drop target cleared from component." ); 334 } else { 335 new DropTarget(c, dropListener); 336 Main.trace("FileDrop: Drop target added to component." ); 337 } 338 } 339 }); 354 340 if( c.getParent() != null ) { 355 341 new DropTarget(c, dropListener); 356 342 } 357 343 358 if( recursive && (c instanceof Container ) ) 359 { 344 if( recursive && (c instanceof Container ) ) { 360 345 // Get the container 361 346 Container cont = (Container) c; … … 368 353 makeDropTarget( comp, recursive); 369 354 } 370 } // end if: recursively set components as listener371 } // end dropListener355 } 356 } 372 357 373 358 /** Determine if the dragged data is a file list. */ 374 private boolean isDragOk( final DropTargetDragEvent evt ) 375 { boolean ok = false; 376 377 // Get data flavors being dragged 378 DataFlavor[] flavors = evt.getCurrentDataFlavors(); 379 380 // See if any of the flavors are a file list 381 int i = 0; 382 while( !ok && i < flavors.length ) 383 { 384 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 385 // Is the flavor a file list? 386 final DataFlavor curFlavor = flavors[i]; 387 if( curFlavor.equals( DataFlavor.javaFileListFlavor ) || 388 curFlavor.isRepresentationClassReader()){ 389 ok = true; 390 } 391 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 392 i++; 393 } // end while: through flavors 394 395 // show data flavors 396 if( flavors.length == 0 ) { 397 Main.trace("FileDrop: no data flavors." ); 398 } 399 for( i = 0; i < flavors.length; i++ ) { 400 Main.trace(flavors[i].toString() ); 401 } 402 403 return ok; 404 } // end isDragOk 359 private boolean isDragOk( final DropTargetDragEvent evt ) { 360 boolean ok = false; 361 362 // Get data flavors being dragged 363 DataFlavor[] flavors = evt.getCurrentDataFlavors(); 364 365 // See if any of the flavors are a file list 366 int i = 0; 367 while( !ok && i < flavors.length ) { 368 // BEGIN 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 369 // Is the flavor a file list? 370 final DataFlavor curFlavor = flavors[i]; 371 if( curFlavor.equals( DataFlavor.javaFileListFlavor ) || 372 curFlavor.isRepresentationClassReader()){ 373 ok = true; 374 } 375 // END 2007-09-12 Nathan Blomquist -- Linux (KDE/Gnome) support added. 376 i++; 377 } 378 379 // show data flavors 380 if( flavors.length == 0 ) { 381 Main.trace("FileDrop: no data flavors." ); 382 } 383 for( i = 0; i < flavors.length; i++ ) { 384 Main.trace(flavors[i].toString() ); 385 } 386 387 return ok; 388 } 405 389 406 390 /** … … 414 398 * @return {@code true} if at least one item has been removed, {@code false} otherwise 415 399 */ 416 public static boolean remove( Component c) 417 {return remove( c, true );418 } // end remove400 public static boolean remove( Component c) { 401 return remove( c, true ); 402 } 419 403 420 404 /** … … 427 411 * @return {@code true} if at least one item has been removed, {@code false} otherwise 428 412 */ 429 public static boolean remove( Component c, boolean recursive ) 430 {// Make sure we support dnd.413 public static boolean remove( Component c, boolean recursive ) { 414 // Make sure we support dnd. 431 415 if (supportsDnD()) { 432 416 Main.trace("FileDrop: Removing drag-and-drop hooks."); … … 437 421 } 438 422 return true; 439 } // end if: recursive440 elsereturn false;441 } // end if: supports DnD442 elsereturn false;443 } // end remove423 } else 424 return false; 425 } else 426 return false; 427 } 444 428 445 429 /* ******** I N N E R I N T E R F A C E L I S T E N E R ******** */ … … 466 450 */ 467 451 public abstract void filesDropped( File[] files ); 468 469 } // end inner-interface Listener 452 } 470 453 471 454 /* ******** I N N E R C L A S S ******** */ … … 545 528 * @param data The data to transfer 546 529 */ 547 public TransferableObject( Object data ) 548 {this.data = data;530 public TransferableObject( Object data ) { 531 this.data = data; 549 532 this.customFlavor = new DataFlavor( data.getClass(), MIME_TYPE ); 550 } // end constructor533 } 551 534 552 535 /** … … 559 542 * @param fetcher The {@link Fetcher} that will return the data object 560 543 */ 561 public TransferableObject( Fetcher fetcher ) 562 {this.fetcher = fetcher;563 } // end constructor544 public TransferableObject( Fetcher fetcher ) { 545 this.fetcher = fetcher; 546 } 564 547 565 548 /** … … 575 558 * @param fetcher The {@link Fetcher} that will return the data object 576 559 */ 577 public TransferableObject(Class<?> dataClass, Fetcher fetcher ) 578 {this.fetcher = fetcher;579 this.customFlavor = new DataFlavor( dataClass, MIME_TYPE ); 580 } // end constructor560 public TransferableObject(Class<?> dataClass, Fetcher fetcher ) { 561 this.fetcher = fetcher; 562 this.customFlavor = new DataFlavor( dataClass, MIME_TYPE ); 563 } 581 564 582 565 /** … … 587 570 * @return The custom data flavor for the encapsulated object 588 571 */ 589 public DataFlavor getCustomDataFlavor() 590 {return customFlavor;591 } // end getCustomDataFlavor572 public DataFlavor getCustomDataFlavor() { 573 return customFlavor; 574 } 592 575 593 576 /* ******** T R A N S F E R A B L E M E T H O D S ******** */ … … 603 586 */ 604 587 @Override 605 public DataFlavor[] getTransferDataFlavors() 606 { 588 public DataFlavor[] getTransferDataFlavors() { 607 589 if( customFlavor != null ) 608 return new DataFlavor[] 609 {customFlavor,590 return new DataFlavor[] { 591 customFlavor, 610 592 DATA_FLAVOR, 611 DataFlavor.stringFlavor 612 }; // end flavors array 593 DataFlavor.stringFlavor}; 613 594 else 614 return new DataFlavor[] 615 { DATA_FLAVOR, 616 DataFlavor.stringFlavor 617 }; // end flavors array 618 } // end getTransferDataFlavors 595 return new DataFlavor[] { 596 DATA_FLAVOR, 597 DataFlavor.stringFlavor}; 598 } 619 599 620 600 /** … … 630 610 @Override 631 611 public Object getTransferData( DataFlavor flavor ) 632 throws UnsupportedFlavorException, IOException 633 { 612 throws UnsupportedFlavorException, IOException { 634 613 // Native object 635 614 if( flavor.equals( DATA_FLAVOR ) ) … … 640 619 return fetcher == null ? data.toString() : fetcher.getObject().toString(); 641 620 642 643 644 } // end getTransferData621 // We can't do anything else 622 throw new UnsupportedFlavorException(flavor); 623 } 645 624 646 625 /** … … 652 631 */ 653 632 @Override 654 public boolean isDataFlavorSupported( DataFlavor flavor ) 655 { 633 public boolean isDataFlavorSupported( DataFlavor flavor ) { 656 634 // Native object 657 635 if( flavor.equals( DATA_FLAVOR ) ) … … 664 642 // We can't do anything else 665 643 return false; 666 } // end isDataFlavorSupported644 } 667 645 668 646 /* ******** I N N E R I N T E R F A C E F E T C H E R ******** */ … … 678 656 * @author Robert Harder 679 657 */ 680 public static interface Fetcher 681 { 658 public static interface Fetcher { 682 659 /** 683 660 * Return the object being encapsulated in the … … 687 664 */ 688 665 public abstract Object getObject(); 689 } // end inner interface Fetcher 690 691 } // end class TransferableObject 692 693 } // end class FileDrop 666 } 667 } 668 } -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r8338 r8342 432 432 double lat = cl.lat(); 433 433 double lon = cl.lon(); 434 if(lat < b.getMinLat()) {changed = true; lat = b.getMinLat(); }435 else if(lat > b.getMaxLat()) {changed = true; lat = b.getMaxLat(); } 436 if(lon < b.getMinLon()) {changed = true; lon = b.getMinLon(); }437 else if(lon > b.getMaxLon()) {changed = true; lon = b.getMaxLon(); } 434 if(lat < b.getMinLat()) {changed = true; lat = b.getMinLat(); 435 } else if(lat > b.getMaxLat()) {changed = true; lat = b.getMaxLat(); } 436 if(lon < b.getMinLon()) {changed = true; lon = b.getMinLon(); 437 } else if(lon > b.getMaxLon()) {changed = true; lon = b.getMaxLon(); } 438 438 if(changed) { 439 439 newCenter = Projections.project(new LatLon(lat,lon)); -
trunk/src/org/openstreetmap/josm/gui/dialogs/DialogsPanel.java
r8308 r8342 137 137 p.add(dlg, 0); 138 138 p.setVisible(true); 139 } 140 else if (dlg.isDialogInCollapsedView()) { 139 } else if (dlg.isDialogInCollapsedView()) { 141 140 p.add(dlg, 0); 142 141 p.setVisible(true); -
trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java
r8308 r8342 399 399 setMinimumSize(new Dimension(Integer.MAX_VALUE,20)); 400 400 titleBar.lblMinimized.setIcon(ImageProvider.get("misc", "minimized")); 401 } 402 elsethrow new IllegalStateException();401 } else 402 throw new IllegalStateException(); 403 403 } 404 404 … … 413 413 setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); 414 414 titleBar.lblMinimized.setIcon(ImageProvider.get("misc", "normal")); 415 } 416 elsethrow new IllegalStateException();415 } else 416 throw new IllegalStateException(); 417 417 } 418 418 -
trunk/src/org/openstreetmap/josm/gui/dialogs/properties/PropertiesDialog.java
r8338 r8342 791 791 tagTable.clearSelection(); 792 792 } 793 } 794 // double click, edit or add tag 795 else if (e.getSource() == tagTable) { 793 } else if (e.getSource() == tagTable) { 794 // double click, edit or add tag 796 795 int row = tagTable.rowAtPoint(e.getPoint()); 797 796 if (row > -1) { … … 807 806 editMembership(row); 808 807 } 809 } 810 else { 808 } else { 811 809 editHelper.addTag(); 812 810 btnAdd.requestFocusInWindow(); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableLinkedCellRenderer.java
r8308 r8342 79 79 g.drawImage(corners,xoff+xloop-2,y1-3,xoff+xloop+1,y1, 2,0,5,3, new Color(0,0,0,0), null); 80 80 g.drawLine(xoff+3,y1-3,xoff+xloop-3,y1-3); 81 } 82 else { 81 } else { 83 82 g.setColor(Color.red); 84 83 if(value.isOnewayHead) { … … 107 106 g.drawImage(corners,xoff+xloop-2,y2+1,xoff+xloop+1,y2+4, 2,2,5,5, new Color(0,0,0,0), null); 108 107 g.drawLine(xoff+3-1,y2+3,xoff+xloop-3,y2+3); 109 } 110 else { 108 } else { 111 109 g.setColor(Color.red); 112 110 if(value.isOnewayTail) { -
trunk/src/org/openstreetmap/josm/gui/download/BookmarkList.java
r8338 r8342 162 162 try { 163 163 bookmarks.add(new Bookmark(entry)); 164 } 165 catch (Exception e) { 164 } catch (Exception e) { 166 165 Main.error(tr("Error reading bookmark entry: %s", e.getMessage())); 167 166 } -
trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java
r8308 r8342 381 381 ); 382 382 boundingBoxChanged(currentBounds,null); 383 } 384 else { 383 } else { 385 384 Bounds bounds = getSavedDownloadBounds(); 386 385 if (bounds != null) { -
trunk/src/org/openstreetmap/josm/gui/download/SlippyMapChooser.java
r7509 r8342 60 60 Dimension iScreenSize = Toolkit.getDefaultToolkit().getScreenSize(); 61 61 62 // enlarge 63 if(iDownloadDialogDimension == null) { 64 // make the each dimension 90% of the absolute display size 62 if (iDownloadDialogDimension == null) { 63 // enlarge: make the each dimension 90% of the absolute display size 65 64 w = iScreenSize.width * 90 / 100; 66 65 h = iScreenSize.height * 90 / 100; 67 66 iDownloadDialogDimension = iGui.getSize(); 68 } 69 // shrink 70 else { 71 // set the size back to the initial dimensions 67 } else { 68 // shrink: set the size back to the initial dimensions 72 69 w = iDownloadDialogDimension.width; 73 70 h = iDownloadDialogDimension.height; -
trunk/src/org/openstreetmap/josm/gui/io/AbstractUploadTask.java
r7299 r8342 320 320 if (e instanceof OsmApiException) { 321 321 OsmApiException ex = (OsmApiException)e; 322 // There was an upload conflict. Let the user decide whether323 // and how to resolve it324 //325 322 if(ex.getResponseCode() == HttpURLConnection.HTTP_CONFLICT) { 323 // There was an upload conflict. Let the user decide whether and how to resolve it 326 324 handleUploadConflict(ex); 327 325 return; 326 } else if (ex.getResponseCode() == HttpURLConnection.HTTP_PRECON_FAILED) { 327 // There was a precondition failed. Notify the user. 328 handlePreconditionFailed(ex); 329 return; 330 } else if (ex.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) { 331 // Tried to update or delete a primitive which never existed on the server? 332 ExceptionDialogUtil.explainNotFound(ex); 333 return; 328 334 } 329 // There was a precondition failed. Notify the user.330 //331 else if (ex.getResponseCode() == HttpURLConnection.HTTP_PRECON_FAILED) {332 handlePreconditionFailed(ex);333 return;334 }335 // Tried to update or delete a primitive which never existed on336 // the server?337 //338 else if (ex.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND) {339 ExceptionDialogUtil.explainNotFound(ex);340 return;341 }342 335 } 343 336 -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r8318 r8342 499 499 tempG.drawImage(e.thumbnail, target.x, target.y, target.width, target.height, null); 500 500 } 501 } 502 else { // thumbnail not loaded yet 501 } else { // thumbnail not loaded yet 503 502 icon.paintIcon(mv, tempG, 504 503 p.x - icon.getIconWidth() / 2, … … 509 508 } 510 509 g.drawImage(offscreenBuffer, 0, 0, null); 511 } 512 else { 510 } else { 513 511 for (ImageEntry e : data) { 514 512 if (e.getPos() == null) { … … 534 532 imgWidth = d.width; 535 533 imgHeight = d.height; 536 } 537 else { 534 } else { 538 535 imgWidth = selectedIcon.getIconWidth(); 539 536 imgHeight = selectedIcon.getIconHeight(); … … 694 691 cal.set(Calendar.MONTH, Integer.parseInt(dateStampComps[1]) - 1); 695 692 cal.set(Calendar.DAY_OF_MONTH, Integer.parseInt(dateStampComps[2])); 696 } 697 else { 693 } else { 698 694 // No GPS date stamp in EXIF data. Copy it from EXIF time. 699 695 // Date is not set if EXIF time is not available. -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/Marker.java
r7673 r8342 212 212 } 213 213 return new Marker(wpt.getCoor(), wpt, symbolName, parentLayer, time, offset); 214 } 215 else if (url.toString().endsWith(".wav")) { 214 } else if (url.toString().endsWith(".wav")) { 216 215 AudioMarker audioMarker = new AudioMarker(wpt.getCoor(), wpt, url, parentLayer, time, offset); 217 216 Extensions exts = (Extensions) wpt.get(GpxConstants.META_EXTENSIONS); -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayer.java
r8308 r8342 421 421 return previousMarker; 422 422 } 423 } 424 else if (marker.getClass() == AudioMarker.class) 425 { 423 } else if (marker.getClass() == AudioMarker.class) { 426 424 if(nextTime || startMarker == null) 427 425 return marker; -
trunk/src/org/openstreetmap/josm/gui/layer/markerlayer/PlayHeadMarker.java
r8126 r8342 103 103 wasPlaying = AudioPlayer.playing(); 104 104 if (wasPlaying) { 105 try { AudioPlayer.pause(); }106 catch (Exception ex) { AudioPlayer.audioMalfunction(ex);} 105 try { AudioPlayer.pause(); 106 } catch (Exception ex) { AudioPlayer.audioMalfunction(ex);} 107 107 } 108 108 } … … 113 113 private void endDrag(boolean reset) { 114 114 if (! wasPlaying || reset) { 115 try { AudioPlayer.pause(); }116 catch (Exception ex) { AudioPlayer.audioMalfunction(ex);} 115 try { AudioPlayer.pause(); 116 } catch (Exception ex) { AudioPlayer.audioMalfunction(ex);} 117 117 } 118 118 if (reset) { … … 243 243 ); 244 244 endDrag(true); 245 } 246 else if (recent.parentLayer.synchronizeAudioMarkers(ca)) { 245 } else if (recent.parentLayer.synchronizeAudioMarkers(ca)) { 247 246 JOptionPane.showMessageDialog( 248 247 Main.parent, -
trunk/src/org/openstreetmap/josm/gui/mappaint/ElemStyles.java
r8133 r8342 274 274 } 275 275 return p; 276 } 277 else if (osm instanceof Relation) 278 { 276 } else if (osm instanceof Relation) { 279 277 Pair<StyleList, Range> p = generateStyles(osm, scale, true); 280 278 if (drawMultipolygon && ((Relation)osm).isMultipolygon()) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleCache.java
r8318 r8342 170 170 throw new AssertionError("the new range must be within a subrange that has no data"); 171 171 172 // --|-------|--------|--173 // i-1 i i+1174 // (--------]175 172 if (bd.get(i+1) == upper) { 173 // --|-------|--------|-- 174 // i-1 i i+1 175 // (--------] 176 176 data.set(i, sl); 177 } 178 // --|-------|--------|-- 179 // i-1 i i+1 180 // (-----] 181 else { 177 } else { 178 // --|-------|--------|-- 179 // i-1 i i+1 180 // (-----] 182 181 bd.add(i+1, upper); 183 182 data.add(i, sl); -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Selector.java
r8285 r8342 394 394 } 395 395 } 396 } 397 else if (e.osm instanceof Relation) { 396 } else if (e.osm instanceof Relation) { 398 397 List<RelationMember> members = ((Relation) e.osm).getMembers(); 399 398 for (int i=0; i<members.size(); i++) { -
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSource.java
r8338 r8342 269 269 270 270 public void add(XmlCondition c, Collection<XmlCondition> conditions, Prototype prot) { 271 if(conditions != null) 272 { 271 if(conditions != null) { 273 272 prot.conditions = conditions; 274 273 if (prot instanceof IconPrototype) { … … 282 281 } else 283 282 throw new RuntimeException(); 284 } 285 else { 283 } else { 286 284 String key = c.getKey(); 287 285 prot.code = key; -
trunk/src/org/openstreetmap/josm/gui/preferences/ToolbarPreferences.java
r8338 r8342 614 614 comp.setText(tr("Separator")); 615 615 comp.setIcon(ImageProvider.get("preferences/separator")); 616 } 617 else if (node.getUserObject() instanceof Action) { 616 } else if (node.getUserObject() instanceof Action) { 618 617 Action action = (Action) node.getUserObject(); 619 618 comp.setText((String) action.getValue(Action.NAME)); … … 783 782 if (obj == null) { 784 783 dragActions.add(ActionDefinition.getSeparator()); 785 } 786 else if (obj instanceof Action) { 784 } else if (obj instanceof Action) { 787 785 dragActions.add(new ActionDefinition((Action) obj)); 788 786 } -
trunk/src/org/openstreetmap/josm/gui/preferences/display/DrawingPreference.java
r6764 r8342 190 190 vn = 8; 191 191 } 192 } 193 else { 192 } else { 194 193 vn = 0; 195 194 } -
trunk/src/org/openstreetmap/josm/gui/preferences/plugin/PluginListPanel.java
r8308 r8342 148 148 // Alert user if plugin requirements are not met 149 149 PluginHandler.checkRequiredPluginsPreconditions(PluginListPanel.this, model.getAvailablePlugins(), cb.pi, false); 150 } 151 // If the plugin has been unselected, was it required by other plugins still selected ? 152 else if (!cb.isSelected()) { 150 } else if (!cb.isSelected()) { 151 // If the plugin has been unselected, was it required by other plugins still selected ? 153 152 Set<String> otherPlugins = new HashSet<>(); 154 153 for (PluginInformation pi : model.getAvailablePlugins()) { -
trunk/src/org/openstreetmap/josm/gui/tagging/TaggingPresetItems.java
r8338 r8342 648 648 // Ignore - cannot auto-increment if last was non-numeric 649 649 } 650 } 651 else if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) { 650 } else if (!usage.hadKeys() || PROP_FILL_DEFAULT.get() || "force".equals(use_last_as_default)) { 652 651 // selected osm primitives are untagged or filling default values feature is enabled 653 652 if (!"false".equals(use_last_as_default) && LAST_VALUES.containsKey(key) && !presetInitiallyMatches) { -
trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitLayout.java
r8308 r8342 252 252 int dividerSize = getDividerSize(); 253 253 return new Dimension(dividerSize, dividerSize); 254 } 255 else { 254 } else { 256 255 Split split = (Split)root; 257 256 List<Node> splitChildren = split.getChildren(); … … 264 263 height = Math.max(height, size.height); 265 264 } 266 } 267 else { 265 } else { 268 266 for(Node splitChild : splitChildren) { 269 267 Dimension size = preferredNodeSize(splitChild); … … 280 278 Component child = childForNode(root); 281 279 return (child != null) ? child.getMinimumSize() : new Dimension(0, 0); 282 } 283 else if (root instanceof Divider) { 280 } else if (root instanceof Divider) { 284 281 int dividerSize = getDividerSize(); 285 282 return new Dimension(dividerSize, dividerSize); 286 } 287 else { 283 } else { 288 284 Split split = (Split)root; 289 285 List<Node> splitChildren = split.getChildren(); … … 296 292 height = Math.max(height, size.height); 297 293 } 298 } 299 else { 294 } else { 300 295 for(Node splitChild : splitChildren) { 301 296 Dimension size = minimumNodeSize(splitChild); … … 347 342 int lastChildMaxX = lastChildBounds.x + lastChildBounds.width; 348 343 splitBounds.add(lastChildMaxX, bounds.y + bounds.height); 349 } 350 else { 344 } else { 351 345 int lastChildMaxY = lastChildBounds.y + lastChildBounds.height; 352 346 splitBounds.add(bounds.x + bounds.width, lastChildMaxY); … … 379 373 (totalWeightedWidth - minWeightedWidth) > extraWidth; 380 374 381 while(splitChildren.hasNext()) { 382 Node splitChild = splitChildren.next(); 383 Rectangle splitChildBounds = splitChild.getBounds(); 384 double minSplitChildWidth = minimumNodeSize(splitChild).getWidth(); 385 double splitChildWeight = (onlyShrinkWeightedComponents) 386 ? splitChild.getWeight() 387 : (splitChildBounds.getWidth() / totalWidth); 388 389 if (!splitChildren.hasNext()) { 390 double newWidth = Math.max(minSplitChildWidth, bounds.getMaxX() - x); 391 Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth); 392 layout2(splitChild, newSplitChildBounds); 393 } 394 else if ((availableWidth > 0.0) && (splitChildWeight > 0.0)) { 395 double allocatedWidth = Math.rint(splitChildWeight * extraWidth); 396 double oldWidth = splitChildBounds.getWidth(); 397 double newWidth = Math.max(minSplitChildWidth, oldWidth - allocatedWidth); 398 Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth); 399 layout2(splitChild, newSplitChildBounds); 400 availableWidth -= (oldWidth - splitChild.getBounds().getWidth()); 401 } 402 else { 403 double existingWidth = splitChildBounds.getWidth(); 404 Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, existingWidth); 405 layout2(splitChild, newSplitChildBounds); 406 } 407 x = splitChild.getBounds().getMaxX(); 408 } 409 } 410 411 else { 375 while(splitChildren.hasNext()) { 376 Node splitChild = splitChildren.next(); 377 Rectangle splitChildBounds = splitChild.getBounds(); 378 double minSplitChildWidth = minimumNodeSize(splitChild).getWidth(); 379 double splitChildWeight = (onlyShrinkWeightedComponents) 380 ? splitChild.getWeight() 381 : (splitChildBounds.getWidth() / totalWidth); 382 383 if (!splitChildren.hasNext()) { 384 double newWidth = Math.max(minSplitChildWidth, bounds.getMaxX() - x); 385 Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth); 386 layout2(splitChild, newSplitChildBounds); 387 } else if ((availableWidth > 0.0) && (splitChildWeight > 0.0)) { 388 double allocatedWidth = Math.rint(splitChildWeight * extraWidth); 389 double oldWidth = splitChildBounds.getWidth(); 390 double newWidth = Math.max(minSplitChildWidth, oldWidth - allocatedWidth); 391 Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth); 392 layout2(splitChild, newSplitChildBounds); 393 availableWidth -= (oldWidth - splitChild.getBounds().getWidth()); 394 } else { 395 double existingWidth = splitChildBounds.getWidth(); 396 Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, existingWidth); 397 layout2(splitChild, newSplitChildBounds); 398 } 399 x = splitChild.getBounds().getMaxX(); 400 } 401 } else { 412 402 int totalHeight = 0; // sum of the children's heights 413 403 int minWeightedHeight = 0; // sum of the weighted childrens' min heights … … 429 419 (totalWeightedHeight - minWeightedHeight) > extraHeight; 430 420 431 while(splitChildren.hasNext()) { 432 Node splitChild = splitChildren.next(); 433 Rectangle splitChildBounds = splitChild.getBounds(); 434 double minSplitChildHeight = minimumNodeSize(splitChild).getHeight(); 435 double splitChildWeight = (onlyShrinkWeightedComponents) 436 ? splitChild.getWeight() 437 : (splitChildBounds.getHeight() / totalHeight); 438 439 if (!splitChildren.hasNext()) { 440 double oldHeight = splitChildBounds.getHeight(); 441 double newHeight = Math.max(minSplitChildHeight, bounds.getMaxY() - y); 442 Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight); 443 layout2(splitChild, newSplitChildBounds); 444 availableHeight -= (oldHeight - splitChild.getBounds().getHeight()); 445 } 446 else if ((availableHeight > 0.0) && (splitChildWeight > 0.0)) { 447 double allocatedHeight = Math.rint(splitChildWeight * extraHeight); 448 double oldHeight = splitChildBounds.getHeight(); 449 double newHeight = Math.max(minSplitChildHeight, oldHeight - allocatedHeight); 450 Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight); 451 layout2(splitChild, newSplitChildBounds); 452 availableHeight -= (oldHeight - splitChild.getBounds().getHeight()); 453 } 454 else { 455 double existingHeight = splitChildBounds.getHeight(); 456 Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, existingHeight); 457 layout2(splitChild, newSplitChildBounds); 458 } 459 y = splitChild.getBounds().getMaxY(); 460 } 421 while(splitChildren.hasNext()) { 422 Node splitChild = splitChildren.next(); 423 Rectangle splitChildBounds = splitChild.getBounds(); 424 double minSplitChildHeight = minimumNodeSize(splitChild).getHeight(); 425 double splitChildWeight = (onlyShrinkWeightedComponents) 426 ? splitChild.getWeight() 427 : (splitChildBounds.getHeight() / totalHeight); 428 429 if (!splitChildren.hasNext()) { 430 double oldHeight = splitChildBounds.getHeight(); 431 double newHeight = Math.max(minSplitChildHeight, bounds.getMaxY() - y); 432 Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight); 433 layout2(splitChild, newSplitChildBounds); 434 availableHeight -= (oldHeight - splitChild.getBounds().getHeight()); 435 } else if ((availableHeight > 0.0) && (splitChildWeight > 0.0)) { 436 double allocatedHeight = Math.rint(splitChildWeight * extraHeight); 437 double oldHeight = splitChildBounds.getHeight(); 438 double newHeight = Math.max(minSplitChildHeight, oldHeight - allocatedHeight); 439 Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, newHeight); 440 layout2(splitChild, newSplitChildBounds); 441 availableHeight -= (oldHeight - splitChild.getBounds().getHeight()); 442 } else { 443 double existingHeight = splitChildBounds.getHeight(); 444 Rectangle newSplitChildBounds = boundsWithYandHeight(bounds, y, existingHeight); 445 layout2(splitChild, newSplitChildBounds); 446 } 447 y = splitChild.getBounds().getMaxY(); 448 } 461 449 } 462 450 … … 476 464 Node lastWeightedChild = split.lastWeightedChild(); 477 465 478 /* Layout the Split's child Nodes' along the X axis. The bounds479 * of each child will have the same y coordinate and height as the480 * layoutGrow() bounds argument. Extra width is allocated to the481 * to each child with a non-zero weight:482 * newWidth = currentWidth + (extraWidth * splitChild.getWeight())483 * Any extraWidth "left over" (that's availableWidth in the loop484 * below) is given to the last child. Note that Dividers always485 * have a weight of zero, and they're never the last child.486 */487 466 if (split.isRowLayout()) { 467 /* Layout the Split's child Nodes' along the X axis. The bounds 468 * of each child will have the same y coordinate and height as the 469 * layoutGrow() bounds argument. Extra width is allocated to the 470 * to each child with a non-zero weight: 471 * newWidth = currentWidth + (extraWidth * splitChild.getWeight()) 472 * Any extraWidth "left over" (that's availableWidth in the loop 473 * below) is given to the last child. Note that Dividers always 474 * have a weight of zero, and they're never the last child. 475 */ 488 476 double x = bounds.getX(); 489 477 double extraWidth = bounds.getWidth() - splitBounds.getWidth(); … … 499 487 Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, newWidth); 500 488 layout2(splitChild, newSplitChildBounds); 501 } 502 else if ((availableWidth > 0.0) && (splitChildWeight > 0.0)) { 489 } else if ((availableWidth > 0.0) && (splitChildWeight > 0.0)) { 503 490 double allocatedWidth = (splitChild.equals(lastWeightedChild)) 504 491 ? availableWidth … … 508 495 layout2(splitChild, newSplitChildBounds); 509 496 availableWidth -= allocatedWidth; 510 } 511 else { 497 } else { 512 498 double existingWidth = splitChildBounds.getWidth(); 513 499 Rectangle newSplitChildBounds = boundsWithXandWidth(bounds, x, existingWidth); … … 516 502 x = splitChild.getBounds().getMaxX(); 517 503 } 518 } 519 520 /* Layout the Split's child Nodes' along the Y axis. The bounds 521 * of each child will have the same x coordinate and width as the 522 * layoutGrow() bounds argument. Extra height is allocated to the 523 * to each child with a non-zero weight: 524 * newHeight = currentHeight + (extraHeight * splitChild.getWeight()) 525 * Any extraHeight "left over" (that's availableHeight in the loop 526 * below) is given to the last child. Note that Dividers always 527 * have a weight of zero, and they're never the last child. 528 */ 529 else { 504 } else { 505 /* Layout the Split's child Nodes' along the Y axis. The bounds 506 * of each child will have the same x coordinate and width as the 507 * layoutGrow() bounds argument. Extra height is allocated to the 508 * to each child with a non-zero weight: 509 * newHeight = currentHeight + (extraHeight * splitChild.getWeight()) 510 * Any extraHeight "left over" (that's availableHeight in the loop 511 * below) is given to the last child. Note that Dividers always 512 * have a weight of zero, and they're never the last child. 513 */ 530 514 double y = bounds.getY(); 531 515 double extraHeight = bounds.getMaxY() - splitBounds.getHeight(); … … 571 555 } 572 556 root.setBounds(bounds); 573 } 574 else if (root instanceof Divider) { 557 } else if (root instanceof Divider) { 575 558 root.setBounds(bounds); 576 } 577 else if (root instanceof Split) { 559 } else if (root instanceof Split) { 578 560 Split split = (Split)root; 579 561 boolean grow = split.isRowLayout() … … 583 565 layoutGrow(split, bounds); 584 566 root.setBounds(bounds); 585 } 586 else { 567 } else { 587 568 layoutShrink(split, bounds); 588 569 // split.setBounds() called in layoutShrink() … … 608 589 if (root instanceof Leaf) { 609 590 root.setBounds(bounds); 610 } 611 else if (root instanceof Split) { 591 } else if (root instanceof Split) { 612 592 Split split = (Split)root; 613 593 Iterator<Node> splitChildren = split.getChildren().iterator(); … … 629 609 (splitChildren.hasNext()) ? (Divider)(splitChildren.next()) : null; 630 610 631 double childWidth = 0.0; 632 if (getFloatingDividers()) { 633 childWidth = preferredNodeSize(splitChild).getWidth(); 611 double childWidth = 0.0; 612 if (getFloatingDividers()) { 613 childWidth = preferredNodeSize(splitChild).getWidth(); 614 } 615 else { 616 if (dividerChild != null) { 617 childWidth = dividerChild.getBounds().getX() - x; 634 618 } 635 619 else { 636 if (dividerChild != null) { 637 childWidth = dividerChild.getBounds().getX() - x; 638 } 639 else { 640 childWidth = split.getBounds().getMaxX() - x; 641 } 620 childWidth = split.getBounds().getMaxX() - x; 642 621 } 643 childBounds = boundsWithXandWidth(bounds, x, childWidth); 644 layout1(splitChild, childBounds); 645 646 if (getFloatingDividers() && (dividerChild != null)) { 647 double dividerX = childBounds.getMaxX(); 648 Rectangle dividerBounds = boundsWithXandWidth(bounds, dividerX, dividerSize); 649 dividerChild.setBounds(dividerBounds); 650 } 651 if (dividerChild != null) { 652 x = dividerChild.getBounds().getMaxX(); 653 } 654 } 655 } 656 657 /* Layout the Split's child Nodes' along the Y axis. The bounds 658 * of each child will have the same x coordinate and width as the 659 * layout1() bounds argument. The algorithm is identical to what's 660 * explained above, for the X axis case. 661 */ 662 else { 622 } 623 childBounds = boundsWithXandWidth(bounds, x, childWidth); 624 layout1(splitChild, childBounds); 625 626 if (getFloatingDividers() && (dividerChild != null)) { 627 double dividerX = childBounds.getMaxX(); 628 Rectangle dividerBounds = boundsWithXandWidth(bounds, dividerX, dividerSize); 629 dividerChild.setBounds(dividerBounds); 630 } 631 if (dividerChild != null) { 632 x = dividerChild.getBounds().getMaxX(); 633 } 634 } 635 } else { 636 /* Layout the Split's child Nodes' along the Y axis. The bounds 637 * of each child will have the same x coordinate and width as the 638 * layout1() bounds argument. The algorithm is identical to what's 639 * explained above, for the X axis case. 640 */ 663 641 double y = bounds.getY(); 664 642 while(splitChildren.hasNext()) { … … 670 648 if (getFloatingDividers()) { 671 649 childHeight = preferredNodeSize(splitChild).getHeight(); 672 } 673 else { 650 } else { 674 651 if (dividerChild != null) { 675 652 childHeight = dividerChild.getBounds().getY() - y; 676 } 677 else { 653 } else { 678 654 childHeight = split.getBounds().getMaxY() - y; 679 655 } … … 772 748 Divider divider = (Divider)root; 773 749 return (divider.getBounds().contains(x, y)) ? divider : null; 774 } 775 else if (root instanceof Split) { 750 } else if (root instanceof Split) { 776 751 Split split = (Split)root; 777 752 for(Node child : split.getChildren()) { … … 810 785 dividers.add((Divider)child); 811 786 } 812 } 813 else if (child instanceof Split) { 787 } else if (child instanceof Split) { 814 788 dividers.addAll(dividersThatOverlap(child, r)); 815 789 } … … 982 956 * children are to be laid out in a row: all the same height, 983 957 * each node's left edge equal to the previous Node's right 984 * edge. If false, children are laid on in a column. Default 985 * value is true. 958 * edge. If false, children are laid on in a column. Default value is true. 986 959 * 987 960 * @param rowLayout true for horizontal row layout, false for column … … 1007 980 * of each new child is set to this Split node, and the parent 1008 981 * of each old child (if any) is set to null. This method 1009 * defensively copies the incoming List. Default value is 1010 * an empty List. 982 * defensively copies the incoming List. Default value is an empty List. 1011 983 * 1012 984 * @param children List of children … … 1156 1128 if (st.nextToken() == StreamTokenizer.TT_NUMBER) { 1157 1129 node.setWeight(st.nval); 1158 } 1159 else { 1130 } else { 1160 1131 throwParseException(st, "invalid weight"); 1161 1132 } 1162 } 1163 else if ("NAME".equalsIgnoreCase(name)) { 1133 } else if ("NAME".equalsIgnoreCase(name)) { 1164 1134 if (st.nextToken() == StreamTokenizer.TT_WORD) { 1165 1135 if (node instanceof Leaf) { 1166 1136 ((Leaf)node).setName(st.sval); 1167 } 1168 else { 1137 } else { 1169 1138 throwParseException(st, "can't specify name for " + node); 1170 1139 } 1171 } 1172 else { 1140 } else { 1173 1141 throwParseException(st, "invalid name"); 1174 1142 } 1175 } 1176 else { 1143 } else { 1177 1144 throwParseException(st, "unrecognized attribute \"" + name + "\""); 1178 1145 } … … 1183 1150 if (children.isEmpty()) { 1184 1151 children.add(child); 1185 } 1186 else { 1152 } else { 1187 1153 children.add(new Divider()); 1188 1154 children.add(child); … … 1200 1166 if (token == StreamTokenizer.TT_WORD) { 1201 1167 parseAttribute(st.sval, st, leaf); 1202 } 1203 else { 1168 } else { 1204 1169 throwParseException(st, "Bad Leaf: " + leaf); 1205 1170 } … … 1213 1178 if (token == ')') { 1214 1179 break; 1215 } 1216 else if (token == StreamTokenizer.TT_WORD) { 1180 } else if (token == StreamTokenizer.TT_WORD) { 1217 1181 if ("WEIGHT".equalsIgnoreCase(st.sval)) { 1218 1182 parseAttribute(st.sval, st, parent); 1219 } 1220 else { 1183 } else { 1221 1184 addSplitChild(parent, new Leaf(st.sval)); 1222 1185 } 1223 } 1224 else if (token == '(') { 1186 } else if (token == '(') { 1225 1187 if ((token = st.nextToken()) != StreamTokenizer.TT_WORD) { 1226 1188 throwParseException(st, "invalid node type"); … … 1229 1191 if ("LEAF".equals(nodeType)) { 1230 1192 parseLeaf(st, parent); 1231 } 1232 else if ("ROW".equals(nodeType) || "COLUMN".equals(nodeType)) { 1193 } else if ("ROW".equals(nodeType) || "COLUMN".equals(nodeType)) { 1233 1194 Split split = new Split(); 1234 1195 split.setRowLayout("ROW".equals(nodeType)); 1235 1196 addSplitChild(parent, split); 1236 1197 parseSplit(st, split); 1237 } 1238 else { 1198 } else { 1239 1199 throwParseException(st, "unrecognized node type '" + nodeType + "'"); 1240 1200 } … … 1249 1209 parseSplit(st, root); 1250 1210 return root.getChildren().get(0); 1251 } 1252 catch (Exception e) { 1211 } catch (Exception e) { 1253 1212 Main.error(e); 1254 } 1255 finally { 1213 } finally { 1256 1214 Utils.close(r); 1257 1215 } -
trunk/src/org/openstreetmap/josm/gui/widgets/MultiSplitPane.java
r8318 r8342 214 214 dp.paint(dpg, divider); 215 215 } 216 } 217 finally { 216 } finally { 218 217 dpg.dispose(); 219 218 } … … 239 238 if ((prevNode == null) || (nextNode == null)) { 240 239 dragUnderway = false; 241 } 242 else { 240 } else { 243 241 initialDividerBounds = divider.getBounds(); 244 242 dragOffsetX = mx - initialDividerBounds.x; … … 251 249 dragMax = nextNodeBounds.x + nextNodeBounds.width; 252 250 dragMax -= dragDivider.getBounds().width; 253 } 254 else { 251 } else { 255 252 dragMin = prevNodeBounds.y; 256 253 dragMax = nextNodeBounds.y + nextNodeBounds.height; … … 261 258 dragUnderway = true; 262 259 } 263 } 264 else { 260 } else { 265 261 dragUnderway = false; 266 262 } … … 272 268 damageR.x = dragMin; 273 269 damageR.width = dragMax - dragMin; 274 } 275 else { 270 } else { 276 271 damageR.y = dragMin; 277 272 damageR.height = dragMax - dragMin; … … 290 285 bounds.x = Math.max(bounds.x, dragMin); 291 286 bounds.x = Math.min(bounds.x, dragMax); 292 } 293 else { 287 } else { 294 288 bounds.y = my - dragOffsetY; 295 289 bounds.y = Math.max(bounds.y, dragMin); … … 300 294 revalidate(); 301 295 repaintDragLimits(); 302 } 303 else { 296 } else { 304 297 repaint(oldBounds.union(bounds)); 305 298 } -
trunk/src/org/openstreetmap/josm/io/NmeaReader.java
r7596 r8342 376 376 currentwp.put(GpxConstants.PT_PDOP, Float.parseFloat(accu)); 377 377 } 378 } 379 else if("$GPRMC".equals(e[0]) || "$GNRMC".equals(e[0])) { 378 } else if("$GPRMC".equals(e[0]) || "$GNRMC".equals(e[0])) { 380 379 // coordinates 381 380 LatLon latLon = parseLatLon( -
trunk/src/org/openstreetmap/josm/io/OsmApiException.java
r7205 r8342 130 130 .append(responseCode); 131 131 String eh = ""; 132 try 133 { 132 try { 134 133 if(errorHeader != null) 135 134 eh = tr(errorHeader.trim()); … … 139 138 .append(">"); 140 139 } 141 } 142 catch (Exception e) { 140 } catch (Exception e) { 143 141 // Ignored 144 142 } 145 try 146 { 143 try { 147 144 String eb = errorBody != null ? tr(errorBody.trim()) : ""; 148 145 if (!eb.isEmpty() && !eb.equals(eh)) { … … 151 148 .append(">"); 152 149 } 153 } 154 catch (Exception e) { 150 } catch (Exception e) { 155 151 // Ignored 156 152 } -
trunk/src/org/openstreetmap/josm/io/OsmServerReader.java
r8291 r8342 187 187 } 188 188 } 189 } 190 catch(Exception e) { 189 } catch(Exception e) { 191 190 errorBody.append(tr("Reading error text failed.")); 192 191 } -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpServer.java
r8340 r8342 5 5 6 6 import java.io.IOException; 7 import java.net.BindException;8 7 import java.net.ServerSocket; 9 8 import java.net.Socket; -
trunk/src/org/openstreetmap/josm/io/remotecontrol/RemoteControlHttpsServer.java
r8341 r8342 7 7 import java.io.InputStream; 8 8 import java.math.BigInteger; 9 import java.net.BindException;10 9 import java.net.ServerSocket; 11 10 import java.net.Socket; -
trunk/src/org/openstreetmap/josm/plugins/PluginInformation.java
r8291 r8342 273 273 } 274 274 } 275 } 276 catch(Exception e) { 275 } catch(Exception e) { 277 276 Main.error(e); 278 277 } -
trunk/src/org/openstreetmap/josm/tools/Diff.java
r8285 r8342 764 764 or until the first nonprovisional at least 8 lines in. 765 765 Until that point, cancel any provisionals. */ 766 for (j = 0, consec = 0; j < length; j++) 767 { 766 for (j = 0, consec = 0; j < length; j++) { 768 767 if (j >= 8 && discards[i + j] == 1) { 769 768 break; … … 771 770 if (discards[i + j] == 2) { 772 771 consec = 0; discards[i + j] = 0; 773 } 774 else if (discards[i + j] == 0) { 772 } else if (discards[i + j] == 0) { 775 773 consec = 0; 776 774 } else { … … 786 784 787 785 /* Same thing, from end. */ 788 for (j = 0, consec = 0; j < length; j++) 789 { 786 for (j = 0, consec = 0; j < length; j++) { 790 787 if (j >= 8 && discards[i - j] == 1) { 791 788 break; … … 793 790 if (discards[i - j] == 2) { 794 791 consec = 0; discards[i - j] = 0; 795 } 796 else if (discards[i - j] == 0) { 792 } else if (discards[i - j] == 0) { 797 793 consec = 0; 798 794 } else { -
trunk/src/org/openstreetmap/josm/tools/Geometry.java
r8303 r8342 183 183 } 184 184 } 185 } 186 else if (test && !intersectionNodes.isEmpty()) 185 } else if (test && !intersectionNodes.isEmpty()) 187 186 return intersectionNodes; 188 187 }
Note:
See TracChangeset
for help on using the changeset viewer.