| 73 | | public WMSLayer(String name, String baseURL, String cookies) { |
| 74 | | super(name); |
| 75 | | alphaChannel.setSelected(Main.pref.getBoolean("wmsplugin.alpha_channel")); |
| 76 | | background = true; /* set global background variable */ |
| 77 | | initializeImages(); |
| 78 | | this.baseURL = baseURL; |
| 79 | | this.cookies = cookies; |
| 80 | | WMSGrabber.getProjection(baseURL, true); |
| 81 | | mv = Main.map.mapView; |
| 82 | | resolution = mv.getDist100PixelText(); |
| 83 | | pixelPerDegree = getPPD(); |
| | 75 | public WMSLayer(String name, String baseURL, String cookies) { |
| | 76 | super(name); |
| | 77 | alphaChannel.setSelected(Main.pref.getBoolean("wmsplugin.alpha_channel")); |
| | 78 | background = true; /* set global background variable */ |
| | 79 | initializeImages(); |
| | 80 | this.baseURL = baseURL; |
| | 81 | this.cookies = cookies; |
| | 82 | WMSGrabber.getProjection(baseURL, true); |
| | 83 | mv = Main.map.mapView; |
| | 84 | |
| | 85 | // quick hack to predefine the PixelDensity to reuse the cache |
| | 86 | int codeIndex = getName().indexOf("#PPD="); |
| | 87 | if (codeIndex != -1) { |
| | 88 | pixelPerDegree = Double.valueOf(getName().substring(codeIndex+5)); |
| | 89 | } else { |
| | 90 | pixelPerDegree = getPPD(); |
| | 91 | } |
| 203 | | @Override public Component[] getMenuEntries() { |
| 204 | | return new Component[]{ |
| 205 | | new JMenuItem(LayerListDialog.getInstance().createShowHideLayerAction(this)), |
| 206 | | new JMenuItem(LayerListDialog.getInstance().createDeleteLayerAction(this)), |
| 207 | | new JSeparator(), |
| 208 | | new JMenuItem(new LoadWmsAction()), |
| 209 | | new JMenuItem(new SaveWmsAction()), |
| 210 | | new JSeparator(), |
| 211 | | startstop, |
| 212 | | alphaChannel, |
| 213 | | new JMenuItem(new changeResolutionAction()), |
| 214 | | new JMenuItem(new reloadErrorTilesAction()), |
| 215 | | new JMenuItem(new downloadAction()), |
| 216 | | new JSeparator(), |
| 217 | | new JMenuItem(new LayerListPopup.InfoAction(this)) |
| 218 | | }; |
| 219 | | } |
| | 212 | @Override public Component[] getMenuEntries() { |
| | 213 | return new Component[]{ |
| | 214 | new JMenuItem(LayerListDialog.getInstance().createShowHideLayerAction(this)), |
| | 215 | new JMenuItem(LayerListDialog.getInstance().createDeleteLayerAction(this)), |
| | 216 | new JSeparator(), |
| | 217 | new JMenuItem(new LoadWmsAction()), |
| | 218 | new JMenuItem(new SaveWmsAction()), |
| | 219 | new JMenuItem(new BookmarkWmsAction()), |
| | 220 | new JSeparator(), |
| | 221 | startstop, |
| | 222 | alphaChannel, |
| | 223 | new JMenuItem(new changeResolutionAction()), |
| | 224 | new JMenuItem(new reloadErrorTilesAction()), |
| | 225 | new JMenuItem(new downloadAction()), |
| | 226 | new JSeparator(), |
| | 227 | new JMenuItem(new LayerListPopup.InfoAction(this)) |
| | 228 | }; |
| | 229 | } |
| 253 | | public reloadErrorTilesAction() { |
| 254 | | super(tr("Reload erroneous tiles")); |
| 255 | | } |
| 256 | | public void actionPerformed(ActionEvent ev) { |
| 257 | | // Delete small files, because they're probably blank tiles. |
| 258 | | // See https://josm.openstreetmap.de/ticket/2307 |
| 259 | | WMSPlugin.cache.customCleanUp(WMSPlugin.cache.CLEAN_SMALL_FILES, 2048); |
| | 263 | public reloadErrorTilesAction() { |
| | 264 | super(tr("Reload erroneous tiles")); |
| | 265 | } |
| | 266 | public void actionPerformed(ActionEvent ev) { |
| | 267 | // Delete small files, because they're probably blank tiles. |
| | 268 | // See https://josm.openstreetmap.de/ticket/2307 |
| | 269 | WMSPlugin.cache.customCleanUp(CacheFiles.CLEAN_SMALL_FILES, 4096); |
| | 377 | |
| | 378 | /** |
| | 379 | * This action will add a WMS layer menu entry with the current WMS layer URL and name extended by the current resolution. |
| | 380 | * When using the menu entry again, the WMS cache will be used properly. |
| | 381 | * |
| | 382 | * @author <alex@addismap.com> |
| | 383 | */ |
| | 384 | public class BookmarkWmsAction extends AbstractAction { |
| | 385 | public BookmarkWmsAction() { |
| | 386 | super(tr("Set WMS Bookmark")); |
| | 387 | } |
| | 388 | public void actionPerformed(ActionEvent ev) { |
| | 389 | int i = 0; |
| | 390 | while (Main.pref.hasKey("wmsplugin.url."+i+".url")) { |
| | 391 | i++; |
| | 392 | } |
| | 393 | String baseName; |
| | 394 | // cut old parameter |
| | 395 | int parameterIndex = getName().indexOf("#PPD="); |
| | 396 | if (parameterIndex != -1) { |
| | 397 | baseName = getName().substring(0,parameterIndex); |
| | 398 | } |
| | 399 | else { |
| | 400 | baseName = getName(); |
| | 401 | } |
| | 402 | Main.pref.put("wmsplugin.url."+ i +".url",baseURL ); |
| | 403 | Main.pref.put("wmsplugin.url."+String.valueOf(i)+".name", baseName + "#" + getPPD() ); |
| | 404 | WMSPlugin.refreshMenu(); |
| | 405 | } |
| | 406 | } |
| | 407 | |