- Timestamp:
- 2025-02-03T20:59:54+01:00 (7 days ago)
- Location:
- trunk
- Files:
-
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/TagInfoExtract.java
r19184 r19307 122 122 script.new ExternalPresets().run(); 123 123 break; 124 default:125 throw new IllegalStateException("Invalid type " + script.options.mode);126 124 } 127 125 if (!script.options.noexit) { -
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r19050 r19307 233 233 setHelpId(ht("/Action/ZoomToNext")); 234 234 break; 235 default:236 throw new IllegalArgumentException("Unknown mode: " + mode);237 235 } 238 236 installAdapters(); -
trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java
r19297 r19307 247 247 newCursor = Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR); 248 248 break; 249 default: throw new AssertionError();250 249 } 251 250 if (newCursor != null) { -
trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java
r19050 r19307 69 69 /** 70 70 * Move is an action that can move all kind of OsmPrimitives (except keys for now). 71 * 71 * <p> 72 72 * If an selected object is under the mouse when dragging, move all selected objects. 73 73 * If an unselected object is under the mouse when dragging, it becomes selected 74 74 * and will be moved. 75 75 * If no object is under the mouse, move all selected objects (if any) 76 * 76 * <p> 77 77 * On Mac OS X, Ctrl + mouse button 1 simulates right click (map move), so the 78 78 * feature "selection remove" is disabled on this platform. … … 402 402 * Look, whether any object is selected. If not, select the nearest node. 403 403 * If there are no nodes in the dataset, do nothing. 404 * 404 * <p> 405 405 * If the user did not press the left mouse button, do nothing. 406 * 406 * <p> 407 407 * Also remember the starting position of the movement and change the mouse 408 408 * cursor to movement. … … 465 465 break; 466 466 case SELECT: 467 default:468 467 if (!(ctrl && PlatformManager.isPlatformOsx())) { 469 468 // start working with rectangle or lasso -
trunk/src/org/openstreetmap/josm/command/SplitWayCommand.java
r19199 r19307 367 367 } 368 368 369 MissingMemberStrategy missingMemberStrategy ;369 MissingMemberStrategy missingMemberStrategy = USER_ABORTED; // default case 370 370 if (relationsNeedingMoreMembers.isEmpty()) { 371 371 // The split can be performed without any extra downloads. … … 393 393 break; 394 394 case ABORT: 395 default:396 395 missingMemberStrategy = USER_ABORTED; 397 396 break; … … 419 418 break; 420 419 case USER_ABORTED: 421 default:422 420 return Optional.empty(); 423 421 } -
trunk/src/org/openstreetmap/josm/data/APIDataSet.java
r16913 r19307 26 26 import org.openstreetmap.josm.data.osm.RelationMember; 27 27 import org.openstreetmap.josm.data.osm.Way; 28 import org.openstreetmap.josm.tools.Logging;29 28 import org.openstreetmap.josm.tools.Utils; 30 29 … … 105 104 case UPDATE: toUpdate.add(osm); break; 106 105 case DELETE: toDelete.add(osm); break; 107 default: Logging.trace("Ignored primitive {0} -> {1}", osm, op);106 // Used to have a default case for logging: Logging.trace("Ignored primitive {0} -> {1}", osm, op); 108 107 } 109 108 } … … 228 227 * Adjusts the upload order for new relations. Child relations are uploaded first, 229 228 * parent relations second. 230 * 229 * <p> 231 230 * This method detects cyclic dependencies in new relation. Relations with cyclic 232 231 * dependencies can't be uploaded. -
trunk/src/org/openstreetmap/josm/data/Bounds.java
r18871 r19307 278 278 break; 279 279 case MINLAT_MINLON_MAXLAT_MAXLON: 280 default:281 280 this.minLat = initLat(values[0], roundToOsmPrecision); 282 281 this.minLon = initLon(values[1], roundToOsmPrecision); -
trunk/src/org/openstreetmap/josm/data/imagery/TMSCachedTileLoaderJob.java
r19050 r19307 216 216 case CANCELED: 217 217 tile.loadingCanceled(); 218 break; 219 default: // This should be removed when we move to Java 17+ 218 220 // do nothing 219 221 } -
trunk/src/org/openstreetmap/josm/data/osm/SimplePrimitiveId.java
r18829 r19307 167 167 case RELATION: 168 168 return "r" + primitive.getUniqueId(); 169 default: 170 throw new IllegalArgumentException("Unknown primitive type: " + primitive.getType()); 169 171 } 170 throw new IllegalArgumentException("Unknown primitive type: " + primitive.getType());171 172 } 172 173 } -
trunk/src/org/openstreetmap/josm/data/osm/pbf/Blob.java
r18877 r19307 98 98 case zlib: 99 99 return new InflaterInputStream(bais); 100 default:101 throw new IOException("unknown compression type is not currently supported: " + this.compressionType.name());102 100 } 101 throw new IOException("unknown compression type is not currently supported: " + this.compressionType.name()); 103 102 } 104 103 } -
trunk/src/org/openstreetmap/josm/data/projection/proj/LambertAzimuthalEqualArea.java
r16627 r19307 122 122 ymf = rq / dd; 123 123 break; 124 default:125 throw new AssertionError(mode);126 124 } 127 125 } … … 133 131 final double sinphi = Math.sin(phi); 134 132 double q = qsfn(sinphi); 135 final double sinb, cosb, b, c, x, y; 133 double sinb, cosb, b, c, x, y; 134 // Set c, x, y to 0 until we move to Java 17 where we can use a better switch expression. 135 c = 0; 136 x = 0; 137 y = 0; 136 138 switch (mode) { 137 139 case OBLIQUE: … … 173 175 } 174 176 break; 175 default:176 throw new AssertionError(mode);177 177 } 178 178 if (Math.abs(c) < EPSILON_LATITUDE) { … … 192 192 case SOUTH_POLE: 193 193 return invprojectNS(x, y); 194 default: 195 throw new AssertionError(mode); 196 } 194 } 195 throw new AssertionError(mode); 197 196 } 198 197 -
trunk/src/org/openstreetmap/josm/data/validation/Test.java
r18960 r19307 42 42 * @author frsantos 43 43 */ 44 @SuppressWarnings("PMD.UnitTestShouldUseTestAnnotation") 44 45 public class Test implements OsmPrimitiveVisitor { 45 46 -
trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java
r19229 r19307 1868 1868 case LOCAL_RO: 1869 1869 throw new IllegalArgumentException("Cannot update the table: " + table); 1870 default:1871 throw new IllegalArgumentException("Unexpected enum value: " + table);1872 1870 } 1873 1871 } … … 1881 1879 */ 1882 1880 public static String[] getTLDEntries(ArrayType table) { 1883 finalString[] array;1881 String[] array = null; 1884 1882 switch (table) { 1885 1883 case COUNTRY_CODE_MINUS: … … 1907 1905 array = LOCAL_TLDS; 1908 1906 break; 1909 default: 1907 } 1908 if (array == null) { 1910 1909 throw new IllegalArgumentException("Unexpected enum value: " + table); 1911 1910 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/MultiValueCellRenderer.java
r19050 r19307 132 132 decision.getChosenValue(), decision.getKey()); 133 133 break; 134 default: 135 throw new AssertionError("Unknown decision type in renderToolTipText(): " + decision.getDecisionType()); 134 136 } 135 137 setToolTipText(toolTipText); … … 171 173 renderValue(decision); 172 174 return cbDecisionRenderer; 175 176 default: 177 return this; 173 178 } 174 return this;175 179 } 176 180 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionType.java
r15729 r19307 31 31 return tr("Keep"); 32 32 case UNDECIDED: 33 default:34 33 return tr("Undecided"); 35 34 } 35 return tr("Undecided"); 36 36 } 37 37 … … 43 43 return tr("Keep this relation member for the target object"); 44 44 case UNDECIDED: 45 default:46 45 return tr("Not decided yet"); 47 46 } 47 return tr("Not decided yet"); 48 48 } 49 49 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverColumnModel.java
r15729 r19307 66 66 comp.setBackground(ConflictColors.BGCOLOR_MEMBER_REMOVE.get()); 67 67 break; 68 default: throw new AssertionError("Unknown decision type: " + model.getDecision(row).getDecision()); 68 69 } 69 70 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java
r19050 r19307 31 31 /** 32 32 * This model manages a list of conflicting relation members. 33 * 33 * <p> 34 34 * It can be used as {@link javax.swing.table.TableModel}. 35 35 */ … … 113 113 case 4: /* decision keep */ return RelationMemberConflictDecisionType.KEEP == d.getDecision(); 114 114 case 5: /* decision remove */ return RelationMemberConflictDecisionType.REMOVE == d.getDecision(); 115 }116 return null;115 default: return null; 116 } 117 117 } 118 118 … … 212 212 /** 213 213 * Prepare the default decisions for the current model. 214 * 214 * <p> 215 215 * Keep/delete decisions are made if every member has the same role and the members are in consecutive order within the relation. 216 216 * For multiple occurrences those conditions are tested stepwise for each occurrence. … … 222 222 /** 223 223 * Prepare the default decisions for the current model. 224 * 224 * <p> 225 225 * Keep/delete decisions are made if every member has the same role and the members are in consecutive order within the relation. 226 226 * For multiple occurrences those conditions are tested stepwise for each occurrence. … … 383 383 break; 384 384 case UNDECIDED: 385 default: 385 386 // FIXME: this is an error 386 387 break; … … 419 420 break; 420 421 case UNDECIDED: 422 default: 421 423 // FIXME: handle error 422 424 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java
r19050 r19307 197 197 options[1] 198 198 ); 199 switch (ret) { 200 case JOptionPane.YES_OPTION: 199 if (ret == JOptionPane.YES_OPTION) { 201 200 buttonAction(1, evt); 202 break; 203 default: 201 } else { 204 202 return; 205 203 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableCellRenderer.java
r19050 r19307 26 26 case UPDATED: setText(tr("Updated")); break; 27 27 case DELETED: setText(tr("Deleted")); break; 28 default: throw new IllegalStateException("Unexpected value: " + type); 28 29 } 29 30 setToolTipText(null); -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentTableModel.java
r19050 r19307 114 114 @Override 115 115 public Object getValueAt(int row, int col) { 116 switch (col) { 117 case 0: return data.get(row).getModificationType(); 118 default: return data.get(row).getPrimitive(); 116 if (col == 0) { 117 return data.get(row).getModificationType(); 119 118 } 119 return data.get(row).getPrimitive(); 120 120 } 121 121 -
trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/query/ChangesetQueryDialog.java
r19050 r19307 204 204 return; 205 205 } 206 default: 207 throw new IllegalStateException("Unexpected value: " + tpQueryPanels.getSelectedIndex()); 206 208 } 207 209 setCanceled(false); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r19279 r19307 248 248 case 2: 249 249 return getWayConnection(rowIndex); 250 } 251 // should not happen 252 return null; 250 default: 251 // should not happen 252 return null; 253 } 253 254 } 254 255 -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java
r19050 r19307 135 135 switch (dialog.getUserAction()) { 136 136 case PROCEED: return true; 137 case CANCEL: 138 default: return false; 137 case CANCEL: return false; 139 138 } 140 139 } … … 379 378 public void cancel() { 380 379 switch (model.getMode()) { 381 case EDITING_DATA: cancelWhenInEditingModel(); 380 case EDITING_DATA: 381 cancelWhenInEditingModel(); 382 382 break; 383 case UPLOADING_AND_SAVING: cancelSafeAndUploadTask(); 383 case UPLOADING_AND_SAVING: 384 cancelSafeAndUploadTask(); 384 385 break; 386 default: 387 throw new IllegalStateException("Unexpected value: " + model.getMode()); 385 388 } 386 389 } … … 428 431 Mode mode = (Mode) evt.getNewValue(); 429 432 switch (mode) { 430 case EDITING_DATA: setEnabled(true); 431 break; 432 case UPLOADING_AND_SAVING: setEnabled(false); 433 break; 433 case EDITING_DATA: 434 setEnabled(true); 435 break; 436 case UPLOADING_AND_SAVING: 437 setEnabled(false); 438 break; 439 default: 440 throw new IllegalStateException("Unexpected value: " + mode); 434 441 } 435 442 } … … 525 532 SaveLayersModel.Mode mode = (SaveLayersModel.Mode) evt.getNewValue(); 526 533 switch (mode) { 527 case EDITING_DATA: setEnabled(true); 528 break; 529 case UPLOADING_AND_SAVING: setEnabled(false); 530 break; 534 case EDITING_DATA: 535 setEnabled(true); 536 break; 537 case UPLOADING_AND_SAVING: 538 setEnabled(false); 539 break; 540 default: 541 throw new IllegalStateException("Unexpected value: " + mode); 531 542 } 532 543 } -
trunk/src/org/openstreetmap/josm/gui/io/SaveLayersTable.java
r19050 r19307 27 27 Mode mode = (Mode) evt.getNewValue(); 28 28 switch (mode) { 29 case EDITING_DATA: setEnabled(true); 30 break; 31 case UPLOADING_AND_SAVING: setEnabled(false); 32 break; 29 case EDITING_DATA: 30 setEnabled(true); 31 break; 32 case UPLOADING_AND_SAVING: 33 setEnabled(false); 34 break; 35 default: 36 throw new IllegalStateException("Unexpected value: " + mode); 33 37 } 34 38 } -
trunk/src/org/openstreetmap/josm/gui/io/UploadPrimitivesTask.java
r19136 r19307 401 401 switch (strategy.getPolicy()) { 402 402 case ABORT: 403 break; /* do nothing - we return to map editing */404 403 case AUTOMATICALLY_OPEN_NEW_CHANGESETS: 405 404 break; /* do nothing - we return to map editing */ … … 411 410 UploadDialog.getUploadDialog().setVisible(true); 412 411 break; 412 default: 413 throw new IllegalStateException("Unexpected value: " + strategy.getPolicy()); 413 414 } 414 415 } else { -
trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java
r19050 r19307 39 39 /** 40 40 * UploadStrategySelectionPanel is a panel for selecting an upload strategy. 41 * 41 * <p> 42 42 * Clients can listen for property change events for the property 43 43 * {@link #UPLOAD_STRATEGY_SPECIFICATION_PROP}. … … 394 394 tfChunkSize.requestFocusInWindow(); 395 395 break; 396 case SINGLE_REQUEST_STRATEGY: 397 case INDIVIDUAL_OBJECTS_STRATEGY: 396 398 default: 397 399 tfChunkSize.setEnabled(false); -
trunk/src/org/openstreetmap/josm/gui/layer/CustomizeColor.java
r15735 r19307 27 27 /** 28 28 * Action to show a dialog for picking a color. 29 * 29 * <p> 30 30 * By calling this action, the user can choose a color to customize the painting 31 31 * of a certain {@link GpxLayer} or {@link org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer}. … … 84 84 ); 85 85 switch (answer) { 86 case 0:86 case JOptionPane.OK_OPTION: 87 87 colorLayers.forEach(l -> l.setColor(c.getColor())); 88 88 break; 89 case 1:89 case JOptionPane.NO_OPTION: 90 90 return; 91 case 2:91 case JOptionPane.CANCEL_OPTION: 92 92 colorLayers.forEach(l -> l.setColor(null)); 93 93 break; 94 default: 95 throw new IllegalStateException("Unexpected value: " + answer); 94 96 } 95 97 // TODO: Make the layer dialog listen to property change events so that this is not needed any more. -
trunk/src/org/openstreetmap/josm/gui/layer/gpx/ChooseTrackVisibilityAction.java
r18208 r19307 115 115 ); 116 116 switch (answer) { 117 case 0:117 case JOptionPane.OK_OPTION: 118 118 tracks.forEach(t -> t.setColor(c.getColor())); 119 119 GPXSettingsPanel.putLayerPrefLocal(layer, "colormode", "0"); //set Colormode to none 120 120 break; 121 case 1:121 case JOptionPane.NO_OPTION: 122 122 return; 123 case 2:123 case JOptionPane.CANCEL_OPTION: 124 124 tracks.forEach(t -> t.setColor(null)); 125 125 break; 126 default: 127 throw new InvalidArgumentException("Unknown choice: " + answer); 126 128 } 127 129 table.repaint(); -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/ColorfulFilter.java
r18801 r19307 106 106 alphaOffset, src.getAlphaRaster() != null); 107 107 return dest; 108 }109 108 default: // Fall through 109 } 110 110 return doFilterRGB(src); 111 111 } -
trunk/src/org/openstreetmap/josm/gui/layer/imagery/ReprojectionTile.java
r19075 r19307 138 138 double scaleMapView = MainApplication.getMap().mapView.getScale(); 139 139 ImageWarp.Interpolation interpolation; 140 switch (Config.getPref().get("imagery.warp.pixel-interpolation", "bilinear")) { 141 case "nearest_neighbor": 142 interpolation = ImageWarp.Interpolation.NEAREST_NEIGHBOR; 143 break; 144 default: 145 interpolation = ImageWarp.Interpolation.BILINEAR; 140 if (Config.getPref().get("imagery.warp.pixel-interpolation", "bilinear").equals("nearest_neighbor")) { 141 interpolation = ImageWarp.Interpolation.NEAREST_NEIGHBOR; 142 } else { 143 interpolation = ImageWarp.Interpolation.BILINEAR; 146 144 } 147 145 -
trunk/src/org/openstreetmap/josm/gui/mappaint/styleelement/LineElement.java
r17744 r19307 423 423 424 424 private static Float computeWidth(LineType type, Cascade c, Cascade cDef) { 425 Float width;426 425 switch (type) { 427 426 case NORMAL: 428 width = getWidth(c, WIDTH, getWidth(cDef, WIDTH, null)); 429 break; 427 return getWidth(c, WIDTH, getWidth(cDef, WIDTH, null)); 430 428 case CASING: 431 429 Float casingWidth = c.get(type.prefix + WIDTH, null, Float.class, true); … … 438 436 if (casingWidth == null) 439 437 return null; 440 width = Optional.ofNullable(getWidth(c, WIDTH, getWidth(cDef, WIDTH, null))).orElse(0f) + 2 * casingWidth; 441 break; 438 return Optional.ofNullable(getWidth(c, WIDTH, getWidth(cDef, WIDTH, null))).orElse(0f) + 2 * casingWidth; 442 439 case LEFT_CASING: 443 440 case RIGHT_CASING: 444 width = getWidth(c, type.prefix + WIDTH, null); 445 break; 446 default: 447 throw new AssertionError(); 448 } 449 return width; 441 return getWidth(c, type.prefix + WIDTH, null); 442 } 443 throw new AssertionError(); 450 444 } 451 445 -
trunk/src/org/openstreetmap/josm/gui/tagging/presets/items/KeyedItem.java
r19285 r19307 282 282 case KEY_VALUE_REQUIRED: 283 283 return tags.containsKey(key) && getValues().contains(tags.get(key)); 284 default: 285 throw new IllegalStateException(); 286 } 284 } 285 throw new IllegalStateException(); 287 286 } 288 287 -
trunk/src/org/openstreetmap/josm/io/AbstractReader.java
r19079 r19307 523 523 524 524 protected final void parseVersion(PrimitiveData current, int version) throws IllegalDataException { 525 switch (ds.getVersion()) { 526 case "0.6": 525 if (ds.getVersion().equals("0.6")) { 527 526 if (version <= 0 && !current.isNew()) { 528 527 throw new IllegalDataException( 529 528 tr("Illegal value for attribute ''version'' on OSM primitive with ID {0}. Got {1}.", 530 Long.toString(current.getUniqueId()), version)); 529 Long.toString(current.getUniqueId()), version)); 531 530 } else if (version < 0 && current.isNew()) { 532 531 Logging.warn(tr("Normalizing value of attribute ''version'' of element {0} to {2}, API version is ''{3}''. Got {1}.", … … 534 533 version = 0; 535 534 } 536 break; 537 default: 538 // should not happen. API version has been checked before 535 } else { // should not happen. API version has been checked before 539 536 throw new IllegalDataException(tr("Unknown or unsupported API version. Got {0}.", ds.getVersion())); 540 537 } -
trunk/src/org/openstreetmap/josm/io/Compression.java
r16816 r19307 103 103 return getXZInputStream(in); 104 104 case NONE: 105 default:106 105 return in; 107 106 } 107 return in; 108 108 } 109 109 … … 219 219 return new XZCompressorOutputStream(out); 220 220 case NONE: 221 default:222 221 return out; 223 222 } 223 return out; 224 224 } 225 225 -
trunk/src/org/openstreetmap/josm/io/DefaultProxySelector.java
r19080 r19307 254 254 return NO_PROXY_LIST; 255 255 return Collections.singletonList(new Proxy(Type.SOCKS, socksProxySocketAddress)); 256 }257 256 // should not happen 258 return Collections.emptyList(); 257 default: return Collections.emptyList(); 258 } 259 259 } 260 260 } -
trunk/src/org/openstreetmap/josm/io/OnlineResource.java
r19101 r19307 57 57 case ALL: 58 58 return /* ICON() */ "offline_all"; 59 default:60 return null;61 59 } 60 return null; 62 61 } 63 62 -
trunk/src/org/openstreetmap/josm/io/OsmChangeReader.java
r18211 r19307 111 111 int event = parser.next(); 112 112 if (event == XMLStreamConstants.START_ELEMENT) { 113 switch (parser.getLocalName()) { 114 case "comment": 113 if (parser.getLocalName().equals("comment")) { 115 114 text = parser.getAttributeValue(null, "text"); 116 115 jumpToEnd(); 117 break; 118 default: 116 } else { 119 117 parseUnknown(); 120 118 } -
trunk/src/org/openstreetmap/josm/io/UploadStrategySpecification.java
r19050 r19307 7 7 * An UploadStrategySpecification consists of the parameter describing the strategy 8 8 * for uploading a collection of {@link org.openstreetmap.josm.data.osm.OsmPrimitive}. 9 * 9 * <p> 10 10 * This includes: 11 11 * <ul> … … 145 145 else 146 146 return (int) Math.ceil((double) numObjects / (double) chunkSize); 147 default: // do nothing 147 148 } 148 149 // should not happen -
trunk/src/org/openstreetmap/josm/io/audio/AudioPlayer.java
r17333 r19307 344 344 stateChange = State.PAUSED; 345 345 break; 346 default: // Do nothing347 346 } 348 347 command.ok(stateChange); -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r19109 r19307 85 85 /** 86 86 * Helper class to support the application with images. 87 * 87 * <p> 88 88 * How to use: 89 * 89 * <p> 90 90 * <code>ImageIcon icon = new ImageProvider(name).setMaxSize(ImageSizes.MAP).get();</code> 91 91 * (there are more options, see below) 92 * 92 * <p> 93 93 * short form: 94 94 * <code>ImageIcon icon = ImageProvider.get(name);</code> … … 247 247 } 248 248 249 private enum ImageLocations { 250 LOCAL, 251 ARCHIVE 252 } 253 249 254 /** 250 255 * Property set on {@code BufferedImage} returned by {@link #makeImageTransparent}. … … 372 377 /** 373 378 * Specify a zip file where the image is located. 374 * 379 * <p> 375 380 * (optional) 376 381 * @param archive zip file where the image is located … … 384 389 /** 385 390 * Specify a base path inside the zip file. 386 * 391 * <p> 387 392 * The subdir and name will be relative to this path. 388 * 393 * <p> 389 394 * (optional) 390 395 * @param inArchiveDir path inside the archive … … 413 418 /** 414 419 * Set the dimensions of the image. 415 * 420 * <p> 416 421 * If not specified, the original size of the image is used. 417 422 * The width part of the dimension can be -1. Then it will only set the height but … … 428 433 /** 429 434 * Set the dimensions of the image. 430 * 435 * <p> 431 436 * If not specified, the original size of the image is used. 432 437 * @param size final dimensions of the image … … 476 481 /** 477 482 * Limit the maximum size of the image. 478 * 483 * <p> 479 484 * It will shrink the image if necessary, but keep the aspect ratio. 480 485 * The given width or height can be -1 which means this direction is not bounded. 481 * 486 * <p> 482 487 * 'size' and 'maxSize' are not compatible, you should set only one of them. 483 488 * @param maxSize maximum image size … … 492 497 /** 493 498 * Limit the maximum size of the image. 494 * 499 * <p> 495 500 * It will shrink the image if necessary, but keep the aspect ratio. 496 501 * The given width or height can be -1 which means this direction is not bounded. 497 * 502 * <p> 498 503 * This function sets value using the most restrictive of the new or existing set of 499 504 * values. … … 515 520 /** 516 521 * Limit the maximum size of the image. 517 * 522 * <p> 518 523 * It will shrink the image if necessary, but keep the aspect ratio. 519 524 * The given width or height can be -1 which means this direction is not bounded. 520 * 525 * <p> 521 526 * 'size' and 'maxSize' are not compatible, you should set only one of them. 522 527 * @param size maximum image size … … 561 566 /** 562 567 * Decide, if an exception should be thrown, when the image cannot be located. 563 * 568 * <p> 564 569 * Set to true, when the image URL comes from user data and the image may be missing. 565 570 * … … 575 580 /** 576 581 * Suppresses warning on the command line in case the image cannot be found. 577 * 582 * <p> 578 583 * In combination with setOptional(true); 579 584 * @param suppressWarnings if <code>true</code> warnings are suppressed … … 667 672 /** 668 673 * Load the image in a background thread. 669 * 674 * <p> 670 675 * This method returns immediately and runs the image request asynchronously. 671 676 * @param action the action that will deal with the image … … 712 717 /** 713 718 * Load the image in a background thread. 714 * 719 * <p> 715 720 * This method returns immediately and runs the image request asynchronously. 716 721 * @param action the action that will deal with the image … … 884 889 extensions = new String[] {".png", ".svg"}; 885 890 } 886 final int typeArchive = 0; 887 final int typeLocal = 1; 888 for (int place : new Integer[] {typeArchive, typeLocal}) { 891 for (ImageLocations place : ImageLocations.values()) { 889 892 for (String ext : extensions) { 890 893 … … 906 909 907 910 switch (place) { 908 case typeArchive:911 case ARCHIVE: 909 912 if (archive != null) { 910 913 cacheName = "zip:" + archive.hashCode() + ':' + cacheName; … … 919 922 } 920 923 break; 921 case typeLocal:924 case LOCAL: 922 925 ImageResource ir = cache.get(cacheName); 923 926 if (ir != null) return ir; … … 956 959 switch (type) { 957 960 case SVG: 958 SVGDiagram svg = null;961 SVGDiagram svg; 959 962 synchronized (getSvgUniverse()) { 960 963 URI uri = getSvgUniverse().loadSVG(is, Utils.fileToURL(cf.getFile()).toString()); … … 970 973 } 971 974 return img == null ? null : new ImageResource(img); 972 default:973 throw new AssertionError("Unsupported type: " + type);974 975 } 975 976 } catch (IOException e) { … … 977 978 return null; 978 979 } 980 throw new AssertionError("Unsupported type: " + type); 979 981 } 980 982 … … 1082 1084 */ 1083 1085 private static ImageResource getIfAvailableZip(String fullName, File archive, String inArchiveDir, ImageType type) { 1086 Objects.requireNonNull(type, "ImageType must not be null"); 1084 1087 try (ZipFile zipFile = new ZipFile(archive, StandardCharsets.UTF_8)) { 1085 1088 if (inArchiveDir == null || ".".equals(inArchiveDir)) { … … 1097 1100 switch (type) { 1098 1101 case SVG: 1099 SVGDiagram svg = null;1102 SVGDiagram svg; 1100 1103 synchronized (getSvgUniverse()) { 1101 1104 URI uri = getSvgUniverse().loadSVG(is, entryName, true); … … 1116 1119 } 1117 1120 return img == null ? null : new ImageResource(img); 1118 default:1119 throw new AssertionError("Unknown ImageType: "+type);1120 1121 } 1121 1122 } … … 1135 1136 */ 1136 1137 private static ImageResource getIfAvailableLocalURL(URL path, ImageType type) { 1138 Objects.requireNonNull(type, "ImageType must not be null"); 1137 1139 switch (type) { 1138 1140 case SVG: … … 1174 1176 } 1175 1177 return img == null ? null : new ImageResource(img); 1176 default:1177 throw new AssertionError();1178 }1178 } 1179 // Default 1180 throw new AssertionError(); 1179 1181 } 1180 1182 … … 1379 1381 * one-step technique (only useful in downscaling cases, where {@code targetWidth} or {@code targetHeight} is 1380 1382 * smaller than the original dimensions, and generally only when the {@code BILINEAR} hint is specified). 1381 * 1382 * From https://community.oracle.com/docs/DOC-983611 :"The Perils of Image.getScaledInstance()"1383 * <p> 1384 * From <a href="https://community.oracle.com/docs/DOC-983611">"The Perils of Image.getScaledInstance()"</a> 1383 1385 * 1384 1386 * @param img the original image to be scaled -
trunk/src/org/openstreetmap/josm/tools/ImageWarp.java
r19075 r19307 164 164 */ 165 165 public static BufferedImage warp(BufferedImage srcImg, Dimension targetDim, PointTransform invTransform, Interpolation interpolation) { 166 Objects.requireNonNull(interpolation, "interpolation"); 166 167 BufferedImage imgTarget = new BufferedImage(targetDim.width, targetDim.height, BufferedImage.TYPE_INT_ARGB); 167 168 Rectangle2D srcRect = new Rectangle2D.Double(0, 0, srcImg.getWidth(), srcImg.getHeight()); … … 175 176 Point2D srcCoord = invTransform.transform(i, j); 176 177 if (srcRect.contains(srcCoord)) { 177 int rgba; 178 // Convert to switch expression when we switch to Java 17+. 179 int rgba = 0; // Initialized here so the compiler doesn't complain. Otherwise, BILINEAR needs to have it start at 0. 178 180 switch (interpolation) { 179 181 case NEAREST_NEIGHBOR: … … 189 191 int c10 = getColor(x0 + 1, y0, srcImg, sharedArray); 190 192 int c11 = getColor(x0 + 1, y0 + 1, srcImg, sharedArray); 191 rgba = 0;193 // rgba 192 194 // loop over color components: blue, green, red, alpha 193 195 for (int ch = 0; ch <= 3; ch++) { … … 199 201 } 200 202 break; 201 default:202 throw new AssertionError(Objects.toString(interpolation));203 203 } 204 204 imgTarget.getRaster().setDataElements(i, j, imgTarget.getColorModel().getDataElements(rgba, pixel));
Note:
See TracChangeset
for help on using the changeset viewer.