Changeset 11397 in josm
- Timestamp:
- 2016-12-14T15:50:53+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/mapmode/ExtrudeAction.java
r10875 r11397 499 499 } 500 500 } 501 } else {501 } else if (bestMovement != null) { 502 502 if (mode == Mode.extrude || mode == Mode.create_new) { 503 503 //nothing here … … 897 897 // set neighboring segments 898 898 Node prevNode = getPreviousNode(selectedSegment.lowerIndex); 899 EastNorth prevNodeEn = prevNode.getEastNorth(); 900 dualAlignSegment1 = new ReferenceSegment(new EastNorth( 901 initialN1en.getX() - prevNodeEn.getX(), 902 initialN1en.getY() - prevNodeEn.getY() 903 ), initialN1en, prevNodeEn, false); 899 if (prevNode != null) { 900 EastNorth prevNodeEn = prevNode.getEastNorth(); 901 dualAlignSegment1 = new ReferenceSegment(new EastNorth( 902 initialN1en.getX() - prevNodeEn.getX(), 903 initialN1en.getY() - prevNodeEn.getY() 904 ), initialN1en, prevNodeEn, false); 905 } 904 906 905 907 Node nextNode = getNextNode(selectedSegment.lowerIndex + 1); 906 EastNorth nextNodeEn = nextNode.getEastNorth(); 907 dualAlignSegment2 = new ReferenceSegment(new EastNorth( 908 initialN2en.getX() - nextNodeEn.getX(), 909 initialN2en.getY() - nextNodeEn.getY() 910 ), initialN2en, nextNodeEn, false); 908 if (nextNode != null) { 909 EastNorth nextNodeEn = nextNode.getEastNorth(); 910 dualAlignSegment2 = new ReferenceSegment(new EastNorth( 911 initialN2en.getX() - nextNodeEn.getX(), 912 initialN2en.getY() - nextNodeEn.getY() 913 ), initialN2en, nextNodeEn, false); 914 } 911 915 } 912 916 -
trunk/src/org/openstreetmap/josm/data/cache/JCSCachedTileLoaderJob.java
r11331 r11397 213 213 */ 214 214 protected String getServerKey() { 215 return getUrlNoException().getHost(); 215 try { 216 return getUrl().getHost(); 217 } catch (IOException e) { 218 Main.trace(e); 219 return null; 220 } 216 221 } 217 222 … … 255 260 Set<ICachedLoaderListener> listeners; 256 261 synchronized (inProgress) { 257 listeners = inProgress.remove(getUrlNoException().toString()); 262 try { 263 listeners = inProgress.remove(getUrl().toString()); 264 } catch (IOException e) { 265 listeners = null; 266 Main.trace(e); 267 } 258 268 } 259 269 if (listeners == null) { -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r11374 r11397 15 15 import java.util.List; 16 16 import java.util.Map; 17 import java.util.Objects; 17 18 import java.util.Set; 18 19 import java.util.concurrent.CopyOnWriteArrayList; … … 499 500 */ 500 501 public void addPrimitive(OsmPrimitive primitive) { 502 Objects.requireNonNull(primitive, "primitive"); 501 503 beginUpdate(); 502 504 try { -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r11383 r11397 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.awt.geom.Area; 4 5 import java.util.Collection; 5 6 import java.util.Objects; … … 420 421 @Override 421 422 public boolean isOutsideDownloadArea() { 422 return !isNewOrUndeleted() && getDataSet() != null && getDataSet().getDataSourceArea() != null 423 && getCoor() != null && !getCoor().isIn(getDataSet().getDataSourceArea()); 423 if (isNewOrUndeleted() || getDataSet() == null) 424 return false; 425 Area area = getDataSet().getDataSourceArea(); 426 if (area == null) 427 return false; 428 LatLon coor = getCoor(); 429 return coor != null && !coor.isIn(area); 424 430 } 425 431 } -
trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
r11277 r11397 116 116 if (idx == -1) 117 117 return this; 118 return getChild(idx).findBucket(bbox); 118 QBLevel<T> child = getChild(idx); 119 if (child == null) 120 return this; 121 return child.findBucket(bbox); 119 122 } 120 123 } … … 140 143 /* 141 144 * There is a race between this and qb.nextContentNode(). 142 * If nextContentNode() runs into this bucket, it may 143 * attempt to null out 'children' because it thinks this 144 * is a dead end. 145 * If nextContentNode() runs into this bucket, it may attempt to null out 'children' because it thinks this is a dead end. 145 146 */ 146 147 void doSplit() { … … 153 154 doAddContent(o); 154 155 } else { 155 getChild(idx).doAdd(o); 156 QBLevel<T> child = getChild(idx); 157 if (child != null) 158 child.doAdd(o); 156 159 } 157 160 } -
trunk/src/org/openstreetmap/josm/data/osm/WaySegment.java
r11227 r11397 94 94 @Override 95 95 public int compareTo(WaySegment o) { 96 return equals(o) ? 0 : toWay().compareTo(o.toWay());96 return o == null ? -1 : (equals(o) ? 0 : toWay().compareTo(o.toWay())); 97 97 } 98 98 -
trunk/src/org/openstreetmap/josm/data/validation/routines/DomainValidator.java
r11379 r11397 221 221 */ 222 222 public boolean isValidInfrastructureTld(String iTld) { 223 if (iTld == null) return false; 223 224 final String key = chompLeadingDot(unicodeToASCII(iTld).toLowerCase(Locale.ENGLISH)); 224 225 return arrayContains(INFRASTRUCTURE_TLDS, key); … … 233 234 */ 234 235 public boolean isValidGenericTld(String gTld) { 236 if (gTld == null) return false; 235 237 final String key = chompLeadingDot(unicodeToASCII(gTld).toLowerCase(Locale.ENGLISH)); 236 238 return (arrayContains(GENERIC_TLDS, key) || arrayContains(genericTLDsPlus, key)) … … 246 248 */ 247 249 public boolean isValidCountryCodeTld(String ccTld) { 250 if (ccTld == null) return false; 248 251 final String key = chompLeadingDot(unicodeToASCII(ccTld).toLowerCase(Locale.ENGLISH)); 249 252 return (arrayContains(COUNTRY_CODE_TLDS, key) || arrayContains(countryCodeTLDsPlus, key)) … … 259 262 */ 260 263 public boolean isValidLocalTld(String lTld) { 264 if (lTld == null) return false; 261 265 final String key = chompLeadingDot(unicodeToASCII(lTld).toLowerCase(Locale.ENGLISH)); 262 266 return arrayContains(LOCAL_TLDS, key); -
trunk/src/org/openstreetmap/josm/gui/help/HelpUtil.java
r9320 r11397 69 69 public static String getHelpTopicEditUrl(String absoluteHelpTopic) { 70 70 String topicUrl = getHelpTopicUrl(absoluteHelpTopic); 71 topicUrl = topicUrl.replaceAll("#[^#]*$", ""); // remove optional fragment 71 if (topicUrl != null) 72 topicUrl = topicUrl.replaceAll("#[^#]*$", ""); // remove optional fragment 72 73 return topicUrl + "?action=edit"; 73 74 } … … 84 85 if (topic == null) 85 86 return null; 86 String pattern = "/[A-Z][a-z]{1,2}(_[A-Z]{2})?:" + getHelpTopicPrefix(LocaleType.ENGLISH).replaceAll("^\\/+", ""); 87 String topicPrefix = getHelpTopicPrefix(LocaleType.ENGLISH); 88 if (topicPrefix != null) 89 topicPrefix = topicPrefix.replaceAll("^\\/+", ""); 90 String pattern = "/[A-Z][a-z]{1,2}(_[A-Z]{2})?:" + topicPrefix; 87 91 if (url.matches(pattern)) { 88 92 return topic.substring(pattern.length()); … … 100 104 public static String extractAbsoluteHelpTopic(String url) { 101 105 if (url == null || !url.startsWith(getWikiBaseHelpUrl())) return null; 102 url= url.substring(getWikiBaseHelpUrl().length());106 String topic = url.substring(getWikiBaseHelpUrl().length()); 103 107 String prefix = getHelpTopicPrefix(LocaleType.ENGLISH); 104 if ( url.startsWith(prefix))105 return url;108 if (prefix == null || topic.startsWith(prefix)) 109 return topic; 106 110 107 111 String pattern = "/[A-Z][a-z]{1,2}(_[A-Z]{2})?:" + prefix.replaceAll("^\\/+", ""); 108 if ( url.matches(pattern))109 return url;112 if (topic.matches(pattern)) 113 return topic; 110 114 111 115 return null; -
trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java
r11322 r11397 425 425 switch (column) { 426 426 case VersionTableColumnModel.COL_VERSION: 427 return Long.toString(getPrimitive(row).getVersion()); 427 HistoryOsmPrimitive p1 = getPrimitive(row); 428 if (p1 != null) 429 return Long.toString(p1.getVersion()); 430 return null; 428 431 case VersionTableColumnModel.COL_REFERENCE: 429 432 return isReferencePointInTime(row); -
trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java
r11383 r11397 504 504 if (e.hasThumbnail()) { 505 505 Dimension d = scaledDimension(e.getThumbnail()); 506 Rectangle target = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height); 507 if (clip.intersects(target)) { 508 tempG.drawImage(e.getThumbnail(), target.x, target.y, target.width, target.height, null); 506 if (d != null) { 507 Rectangle target = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height); 508 if (clip.intersects(target)) { 509 tempG.drawImage(e.getThumbnail(), target.x, target.y, target.width, target.height, null); 510 } 509 511 } 510 512 } else { // thumbnail not loaded yet … … 540 542 if (useThumbs && e.hasThumbnail()) { 541 543 Dimension d = scaledDimension(e.getThumbnail()); 542 imgWidth = d.width; 543 imgHeight = d.height; 544 if (d != null) { 545 imgWidth = d.width; 546 imgHeight = d.height; 547 } else { 548 imgWidth = -1; 549 imgHeight = -1; 550 } 544 551 } else { 545 552 imgWidth = selectedIcon.getIconWidth(); … … 756 763 if (useThumbs && img.hasThumbnail()) { 757 764 Dimension d = scaledDimension(img.getThumbnail()); 758 r = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height); 765 if (d != null) 766 r = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height); 767 else 768 r = null; 759 769 } else { 760 770 r = new Rectangle(p.x - icon.getIconWidth() / 2, … … 763 773 icon.getIconHeight()); 764 774 } 765 if (r .contains(evt.getPoint())) {775 if (r != null && r.contains(evt.getPoint())) { 766 776 return img; 767 777 } … … 861 871 if (useThumbs && e.hasThumbnail()) { 862 872 Dimension d = scaledDimension(e.getThumbnail()); 863 r = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height); 873 if (d != null) 874 r = new Rectangle(p.x - d.width / 2, p.y - d.height / 2, d.width, d.height); 875 else 876 r = null; 864 877 } else { 865 878 r = new Rectangle(p.x - icon.getIconWidth() / 2, … … 868 881 icon.getIconHeight()); 869 882 } 870 if (r .contains(ev.getPoint())) {883 if (r != null && r.contains(ev.getPoint())) { 871 884 clearOtherCurrentPhotos(); 872 885 currentPhoto = i; -
trunk/src/org/openstreetmap/josm/gui/preferences/PreferenceTabbedPane.java
r11087 r11397 402 402 // create a task for downloading plugins if the user has activated, yet not downloaded, new plugins 403 403 final PluginPreference preference = getPluginPreference(); 404 final Set<PluginInformation> toDownload = preference.getPluginsScheduledForUpdateOrDownload(); 405 final PluginDownloadTask task; 406 if (toDownload != null && !toDownload.isEmpty()) { 407 task = new PluginDownloadTask(this, toDownload, tr("Download plugins")); 408 } else { 409 task = null; 410 } 411 412 // this is the task which will run *after* the plugins are downloaded 413 final Runnable continuation = new PluginDownloadAfterTask(preference, task, toDownload); 414 415 if (task != null) { 416 // if we have to launch a plugin download task we do it asynchronously, followed 417 // by the remaining "save preferences" activites run on the Swing EDT. 418 Main.worker.submit(task); 419 Main.worker.submit(() -> SwingUtilities.invokeLater(continuation)); 420 } else { 421 // no need for asynchronous activities. Simply run the remaining "save preference" 422 // activities on this thread (we are already on the Swing EDT 423 continuation.run(); 404 if (preference != null) { 405 final Set<PluginInformation> toDownload = preference.getPluginsScheduledForUpdateOrDownload(); 406 final PluginDownloadTask task; 407 if (toDownload != null && !toDownload.isEmpty()) { 408 task = new PluginDownloadTask(this, toDownload, tr("Download plugins")); 409 } else { 410 task = null; 411 } 412 413 // this is the task which will run *after* the plugins are downloaded 414 final Runnable continuation = new PluginDownloadAfterTask(preference, task, toDownload); 415 416 if (task != null) { 417 // if we have to launch a plugin download task we do it asynchronously, followed 418 // by the remaining "save preferences" activites run on the Swing EDT. 419 Main.worker.submit(task); 420 Main.worker.submit(() -> SwingUtilities.invokeLater(continuation)); 421 } else { 422 // no need for asynchronous activities. Simply run the remaining "save preference" 423 // activities on this thread (we are already on the Swing EDT 424 continuation.run(); 425 } 424 426 } 425 427 } -
trunk/src/org/openstreetmap/josm/io/BoundingBoxDownloader.java
r11100 r11397 94 94 // API 0.6 does not support requests crossing the 180th meridian, so make two requests 95 95 GpxData result = downloadRawGps(new Bounds(lat1, lon1, lat2, 180.0), progressMonitor); 96 result.mergeFrom(downloadRawGps(new Bounds(lat1, -180.0, lat2, lon2), progressMonitor)); 96 if (result != null) 97 result.mergeFrom(downloadRawGps(new Bounds(lat1, -180.0, lat2, lon2), progressMonitor)); 97 98 return result; 98 99 } else { -
trunk/src/org/openstreetmap/josm/io/GpxReader.java
r10378 r11397 399 399 } else if (currentState != State.LINK) { 400 400 Map<String, Object> attr = getAttr(); 401 if ( !attr.containsKey(META_LINKS)) {401 if (attr != null && !attr.containsKey(META_LINKS)) { 402 402 attr.put(META_LINKS, new LinkedList<GpxLink>()); 403 403 } 404 ((Collection<GpxLink>) attr.get(META_LINKS)).add(currentLink); 404 if (attr != null) 405 ((Collection<GpxLink>) attr.get(META_LINKS)).add(currentLink); 405 406 } 406 407 break; -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r11345 r11397 891 891 Map<String, PluginInformation> infos = loadLocallyAvailablePluginInformation(monitor.createSubTaskMonitor(1, false)); 892 892 List<PluginInformation> ret = new LinkedList<>(); 893 for (Iterator<String> it = plugins.iterator(); it.hasNext();) { 894 String plugin = it.next(); 895 if (infos.containsKey(plugin)) { 896 ret.add(infos.get(plugin)); 897 it.remove(); 893 if (infos != null) { 894 for (Iterator<String> it = plugins.iterator(); it.hasNext();) { 895 String plugin = it.next(); 896 if (infos.containsKey(plugin)) { 897 ret.add(infos.get(plugin)); 898 it.remove(); 899 } 898 900 } 899 901 } -
trunk/src/org/openstreetmap/josm/tools/AudioPlayer.java
r11100 r11397 124 124 */ 125 125 public static void play(URL url) throws Exception { 126 AudioPlayer.getInstance().command.play(url, 0.0, 1.0); 126 AudioPlayer instance = AudioPlayer.getInstance(); 127 if (instance != null) 128 instance.command.play(url, 0.0, 1.0); 127 129 } 128 130 … … 134 136 */ 135 137 public static void play(URL url, double seconds) throws Exception { 136 AudioPlayer.getInstance().command.play(url, seconds, 1.0); 138 AudioPlayer instance = AudioPlayer.getInstance(); 139 if (instance != null) 140 instance.command.play(url, seconds, 1.0); 137 141 } 138 142 … … 145 149 */ 146 150 public static void play(URL url, double seconds, double speed) throws Exception { 147 AudioPlayer.getInstance().command.play(url, seconds, speed); 151 AudioPlayer instance = AudioPlayer.getInstance(); 152 if (instance != null) 153 instance.command.play(url, seconds, speed); 148 154 } 149 155 … … 153 159 */ 154 160 public static void pause() throws Exception { 155 AudioPlayer.getInstance().command.pause(); 161 AudioPlayer instance = AudioPlayer.getInstance(); 162 if (instance != null) 163 instance.command.pause(); 156 164 } 157 165 … … 161 169 */ 162 170 public static URL url() { 163 return AudioPlayer.getInstance().playingUrl; 171 AudioPlayer instance = AudioPlayer.getInstance(); 172 return instance == null ? null : instance.playingUrl; 164 173 } 165 174 … … 169 178 */ 170 179 public static boolean paused() { 171 return AudioPlayer.getInstance().state == State.PAUSED; 180 AudioPlayer instance = AudioPlayer.getInstance(); 181 return instance == null ? false : (instance.state == State.PAUSED); 172 182 } 173 183 … … 177 187 */ 178 188 public static boolean playing() { 179 return AudioPlayer.getInstance().state == State.PLAYING; 189 AudioPlayer instance = AudioPlayer.getInstance(); 190 return instance == null ? false : (instance.state == State.PLAYING); 180 191 } 181 192 … … 185 196 */ 186 197 public static double position() { 187 return AudioPlayer.getInstance().position; 198 AudioPlayer instance = AudioPlayer.getInstance(); 199 return instance == null ? -1 : instance.position; 188 200 } 189 201 … … 193 205 */ 194 206 public static double speed() { 195 return AudioPlayer.getInstance().speed; 207 AudioPlayer instance = AudioPlayer.getInstance(); 208 return instance == null ? -1 : instance.speed; 196 209 } 197 210 -
trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java
r10717 r11397 510 510 return tr("<html>Failed to upload data to or download data from<br>" + "''{0}''<br>" 511 511 + "due to a problem with transferring data.<br>" 512 + "Details (untranslated): {1}</html>", e.getUrl(), 512 + "Details (untranslated): {1}</html>", 513 e != null ? e.getUrl() : "null", 513 514 ioe != null ? ioe.getMessage() : "null"); 514 515 } -
trunk/src/org/openstreetmap/josm/tools/Logging.java
r11165 r11397 261 261 StringWriter sb = new StringWriter(); 262 262 sb.append(getErrorLog(message, t)); 263 sb.append('\n'); 264 t.printStackTrace(new PrintWriter(sb)); 263 if (t != null) { 264 sb.append('\n'); 265 t.printStackTrace(new PrintWriter(sb)); 266 } 265 267 return sb.toString(); 266 268 } -
trunk/src/org/openstreetmap/josm/tools/Shortcut.java
r11340 r11397 205 205 206 206 public boolean isEvent(KeyEvent e) { 207 return getKeyStroke() != null && getKeyStroke().equals(208 KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers()));207 KeyStroke ks = getKeyStroke(); 208 return ks != null && ks.equals(KeyStroke.getKeyStroke(e.getKeyCode(), e.getModifiers())); 209 209 } 210 210
Note:
See TracChangeset
for help on using the changeset viewer.