Changeset 24501 in osm for applications/editors/josm
- Timestamp:
- 2010-12-01T18:51:48+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/imagery
- Files:
-
- 10 added
- 12 deleted
- 13 edited
- 24 copied
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery
-
Property svn:ignore
set to
bin
build
dist
-
Property svn:ignore
set to
-
applications/editors/josm/plugins/imagery/README
r23263 r24501 1 README 2 ====== 1 This plugin is an union of slippymap plugin and wmsplugin. 2 Combined by Upliner, licensed under the GNU GPL v2 or later. 3 3 4 Readme for your plugin 4 WMSPlugin authors: 5 ========================================================================== 6 This plugin has been created by tim <chippy2005@gmail.com> 7 and has received major contributions from Frederik Ramm 8 <frederik@remote.org>. It is based on the "Landsat" plugin 9 by Nick Whitelegg <Nick.Whitelegg@solent.ac.uk> and includes 10 some code from Jonathan Stott <jonathan@jstott.me.uk>, Gabriel Ebner 11 <ge@gabrielebner.at> and Ulf Lamping <ulf.lamping@web.de>. 12 The automatic tiles downloading and Yahoo downloader made by Petr Dlouhý <petr.dlouhy@email.cz> 5 13 6 * Plugin author and contact email address. 7 8 * The license for your plugin source code. If you have no special preferences, 9 you can pick the license that is used for JOSM ("GPL v2 or later"). 10 11 * Notes for future developers, if needed. 14 This plugin is licensed under the GNU GPL v2 or later. 15 ========================================================================== 16 17 Slippymap plugin authors: 18 ========================================================================== 19 A plugin for displaying a slippy map grid, with various server interaction 20 options (download tiles, request tile updates etc.) 21 22 Author: Frederik Ramm <frederik@remote.org> 23 Lubomir Varga <lubomir.varga@freemap.sk> or <luvar@plaintext.sk> 24 Public Domain. 25 26 Software with a little bit of customisation, fade background feature, autozoom, autoload tiles e.t.c. Just a begining of the best plugin for josm ;-) 27 ========================================================================== -
applications/editors/josm/plugins/imagery/build.xml
r23263 r24501 28 28 ** 29 29 --> 30 <project name=" myPluginName" default="dist" basedir=".">30 <project name="imagery" default="dist" basedir="."> 31 31 32 32 <!-- enter the SVN commit message --> 33 33 <property name="commit.message" value="Commit message" /> 34 34 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 35 <property name="plugin.main.version" value=" " />35 <property name="plugin.main.version" value="3687" /> 36 36 37 37 … … 41 41 --> 42 42 <property name="josm" location="../../core/dist/josm-custom.jar"/> 43 <property name="remotecontrol" location="../../dist/remotecontrol.jar" /> 43 44 <property name="plugin.build.dir" value="build"/> 44 45 <property name="plugin.src.dir" value="src"/> … … 65 66 <target name="compile" depends="init"> 66 67 <echo message="compiling sources for ${plugin.jar} ... "/> 67 <javac srcdir="src" classpath="${josm} " debug="true" destdir="${plugin.build.dir}">68 <javac srcdir="src" classpath="${josm};${remotecontrol}" debug="true" destdir="${plugin.build.dir}"> 68 69 <compilerarg value="-Xlint:deprecation"/> 69 70 <compilerarg value="-Xlint:unchecked"/> … … 100 101 --> 101 102 <manifest> 102 <attribute name="Author" value=" ..."/>103 <attribute name="Plugin-Class" value=" ..."/>103 <attribute name="Author" value="Tim Waters, Petr Dlouhý, Frederik Ramm, Upliner and others"/> 104 <attribute name="Plugin-Class" value="org.openstreetmap.josm.plugins.imagery.ImageryPlugin"/> 104 105 <attribute name="Plugin-Date" value="${version.entry.commit.date}"/> 105 <attribute name="Plugin-Description" value=" ..."/>106 <attribute name="Plugin-Icon" value=" ..."/>107 <attribute name="Plugin-Link" value=" ..."/>106 <attribute name="Plugin-Description" value="Experimental union of SlippyMap plugin and WMSPlugin"/> 107 <attribute name="Plugin-Icon" value="images/wms.png"/> 108 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/WMSPlugin" /> 108 109 <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/> 109 110 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/> -
applications/editors/josm/plugins/imagery/sources.cfg
r24493 r24501 6 6 # NOTE: default items should be common and worldwide 7 7 # 8 true;Landsat; http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers=global_mosaic&styles=&format=image/jpeg&9 true;Landsat (mirror); http://irs.gis-lab.info/?layers=landsat&10 false;Open Aerial Map; http://openaerialmap.org/wms/?VERSION=1.0&request=GetMap&layers=world&styles=&format=image/jpeg&8 true;Landsat;wms:http://onearth.jpl.nasa.gov/wms.cgi?request=GetMap&layers=global_mosaic&styles=&format=image/jpeg& 9 true;Landsat (mirror);wms:http://irs.gis-lab.info/?layers=landsat& 10 false;Open Aerial Map;wms:http://openaerialmap.org/wms/?VERSION=1.0&request=GetMap&layers=world&styles=&format=image/jpeg& 11 11 # 12 # different forms for web access13 # must be html:<url> 12 # different forms of imagery 13 true;Bing sat;bing:bing 14 14 true;Yahoo Sat;html:http://josm.openstreetmap.de/wmsplugin/YahooDirect.html? 15 false;OpenStreetMap;html:http://josm.openstreetmap.de/wmsplugin/OpenStreetMap.html? 16 false;OpenCycleMap; html:http://josm.openstreetmap.de/wmsplugin/OpenCycleMap.html?17 false;TilesAtHome; html:http://josm.openstreetmap.de/wmsplugin/TilesAtHome.html?15 true;OpenStreetMap;tms:http://tile.openstreetmap.org/ 16 false;OpenCycleMap;tms:http://tile.opencyclemap.org/cycle/ 17 false;TilesAtHome;tms:http://tah.openstreetmap.org/Tiles/tile/ 18 18 # 19 19 # 20 20 # only for Germany 21 false;Streets NRW Geofabrik.de; http://tools.geofabrik.de/osmi/view/strassennrw/josmwms?21 false;Streets NRW Geofabrik.de;wms:http://tools.geofabrik.de/osmi/view/strassennrw/josmwms? 22 22 # 23 23 # 24 24 # only for North America 25 25 # Terraserver USCG - High resolution maps 26 false;Terraserver Topo; http://terraservice.net/ogcmap.ashx?version=1.1.1&request=GetMap&Layers=drg&styles=&format=image/jpeg&27 false;Terraserver Urban; http://terraservice.net/ogcmap.ashx?version=1.1.1&request=GetMap&Layers=urbanarea&styles=&format=image/jpeg&26 false;Terraserver Topo;wms:http://terraservice.net/ogcmap.ashx?version=1.1.1&request=GetMap&Layers=drg&styles=&format=image/jpeg& 27 false;Terraserver Urban;wms:http://terraservice.net/ogcmap.ashx?version=1.1.1&request=GetMap&Layers=urbanarea&styles=&format=image/jpeg& 28 28 # 29 29 # 30 30 # only for Czech Republic 31 false;Czech CUZK:KM; http://wms.cuzk.cz/wms.asp?service=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&LAYERS=parcelni_cisla_i,obrazy_parcel_i,RST_KMD_I,hranice_parcel_i,DEF_BUDOVY,RST_KN_I,dalsi_p_mapy_i,prehledka_kat_prac,prehledka_kat_uz,prehledka_kraju-linie&FORMAT=image/png&transparent=TRUE&32 false;Czech UHUL:ORTOFOTO; http://geoportal2.uhul.cz/cgi-bin/oprl.asp?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&LAYERS=Ortofoto_cb&STYLES=default&FORMAT=image/jpeg&TRANSPARENT=TRUE&31 false;Czech CUZK:KM;wms:http://wms.cuzk.cz/wms.asp?service=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&LAYERS=parcelni_cisla_i,obrazy_parcel_i,RST_KMD_I,hranice_parcel_i,DEF_BUDOVY,RST_KN_I,dalsi_p_mapy_i,prehledka_kat_prac,prehledka_kat_uz,prehledka_kraju-linie&FORMAT=image/png&transparent=TRUE& 32 false;Czech UHUL:ORTOFOTO;wms:http://geoportal2.uhul.cz/cgi-bin/oprl.asp?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&LAYERS=Ortofoto_cb&STYLES=default&FORMAT=image/jpeg&TRANSPARENT=TRUE& 33 33 # 34 34 # 35 35 # only for GB 36 36 # fails with division by zero error 37 false;NPE Maps; http://nick.dev.openstreetmap.org/openpaths/freemap.php?layers=npe&38 false;NPE Maps (Tim); http://dev.openstreetmap.org/~timsc/wms2/map.php?39 false;7th Series (OS7); http://ooc.openstreetmap.org/wms/map.php?source=os7&37 false;NPE Maps;wms:http://nick.dev.openstreetmap.org/openpaths/freemap.php?layers=npe& 38 false;NPE Maps (Tim);wms:http://dev.openstreetmap.org/~timsc/wms2/map.php? 39 false;7th Series (OS7);wms:http://ooc.openstreetmap.org/wms/map.php?source=os7& 40 40 # 41 41 # 42 42 # only for Japan 43 false;MLIT Japan (ORTHO); http://orthophoto.mlit.go.jp:8888/wms/service/wmsRasterTileMap?VERSION=1.3.0&REQUEST=GetMap&LAYERS=ORTHO&STYLES=Default&CRS=EPSG:4612&BBOX={s},{w},{n},{e}&WIDTH={width}&HEIGHT={height}&FORMAT=image/png&BGCOLOR=OxFFFFFF44 false;MLIT Japan (ORTHO01); http://orthophoto.mlit.go.jp:8888/wms/service/wmsRasterTileMap?VERSION=1.3.0&REQUEST=GetMap&LAYERS=ORTHO01&STYLES=Default&CRS=EPSG:4612&BBOX={s},{w},{n},{e}&WIDTH={width}&HEIGHT={height}&FORMAT=image/png&BGCOLOR=OxFFFFFF45 false;MLIT Japan (ORTHO02); http://orthophoto.mlit.go.jp:8888/wms/service/wmsRasterTileMap?VERSION=1.3.0&REQUEST=GetMap&LAYERS=ORTHO02&STYLES=Default&CRS=EPSG:4612&BBOX={s},{w},{n},{e}&WIDTH={width}&HEIGHT={height}&FORMAT=image/png&BGCOLOR=OxFFFFFF46 false;MLIT Japan (ORTHO03); http://orthophoto.mlit.go.jp:8888/wms/service/wmsRasterTileMap?VERSION=1.3.0&REQUEST=GetMap&LAYERS=ORTHO03&STYLES=Default&CRS=EPSG:4612&BBOX={s},{w},{n},{e}&WIDTH={width}&HEIGHT={height}&FORMAT=image/png&BGCOLOR=OxFFFFFF43 false;MLIT Japan (ORTHO);wms:http://orthophoto.mlit.go.jp:8888/wms/service/wmsRasterTileMap?VERSION=1.3.0&REQUEST=GetMap&LAYERS=ORTHO&STYLES=Default&CRS=EPSG:4612&BBOX={s},{w},{n},{e}&WIDTH={width}&HEIGHT={height}&FORMAT=image/png&BGCOLOR=OxFFFFFF 44 false;MLIT Japan (ORTHO01);wms:http://orthophoto.mlit.go.jp:8888/wms/service/wmsRasterTileMap?VERSION=1.3.0&REQUEST=GetMap&LAYERS=ORTHO01&STYLES=Default&CRS=EPSG:4612&BBOX={s},{w},{n},{e}&WIDTH={width}&HEIGHT={height}&FORMAT=image/png&BGCOLOR=OxFFFFFF 45 false;MLIT Japan (ORTHO02);wms:http://orthophoto.mlit.go.jp:8888/wms/service/wmsRasterTileMap?VERSION=1.3.0&REQUEST=GetMap&LAYERS=ORTHO02&STYLES=Default&CRS=EPSG:4612&BBOX={s},{w},{n},{e}&WIDTH={width}&HEIGHT={height}&FORMAT=image/png&BGCOLOR=OxFFFFFF 46 false;MLIT Japan (ORTHO03);wms:http://orthophoto.mlit.go.jp:8888/wms/service/wmsRasterTileMap?VERSION=1.3.0&REQUEST=GetMap&LAYERS=ORTHO03&STYLES=Default&CRS=EPSG:4612&BBOX={s},{w},{n},{e}&WIDTH={width}&HEIGHT={height}&FORMAT=image/png&BGCOLOR=OxFFFFFF 47 47 # 48 48 # 49 49 # only for Italy 50 false;Lodi - Italy; http://sit.provincia.lodi.it/mapserver/mapserv.exe?map=ortofoto_wgs84.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&LAYERS=Terraitaly%20Ortofoto%202007&STYLES=%2C%2C&FORMAT=image/png&TRANSPARENT=TRUE&51 false;Sicily - Italy; http://88.53.214.52/sitr/services/WGS84_F33/Ortofoto_ATA20072008_f33/MapServer/WMSServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS=CRS:84&LAYERS=0&STYLES=default&FORMAT=image/jpeg&52 false;PCN 2006 - Italy; http://wms.pcn.minambiente.it/cgi-bin/mapserv.exe?map=/ms_ogc/service/ortofoto_colore_06.map&LAYERS=ortofoto_colore_06_32,ortofoto_colore_06_33&REQUEST=GetMap&VERSION=1.1.1&FORMAT=image%2Fjpeg&50 false;Lodi - Italy;wms:http://sit.provincia.lodi.it/mapserver/mapserv.exe?map=ortofoto_wgs84.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG:4326&LAYERS=Terraitaly%20Ortofoto%202007&STYLES=%2C%2C&FORMAT=image/png&TRANSPARENT=TRUE& 51 false;Sicily - Italy;wms:http://88.53.214.52/sitr/services/WGS84_F33/Ortofoto_ATA20072008_f33/MapServer/WMSServer?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS=CRS:84&LAYERS=0&STYLES=default&FORMAT=image/jpeg& 52 false;PCN 2006 - Italy;wms:http://wms.pcn.minambiente.it/cgi-bin/mapserv.exe?map=/ms_ogc/service/ortofoto_colore_06.map&LAYERS=ortofoto_colore_06_32,ortofoto_colore_06_33&REQUEST=GetMap&VERSION=1.1.1&FORMAT=image%2Fjpeg& 53 53 # 54 54 # only for France 55 false;SPOTMaps (France); http://spotmaps.youmapps.org/cgi-bin/mapserv?map=/home/ortho/ortho.map&service=wms&version=1.1.1&srs=EPSG:4326&request=GetMap&layers=spotmaps4osm&format=image/jpeg&FORMAT=image/jpeg&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&Layers=demo&;http://www.youmapps.org/licenses/EULA-OSM-J-{lang}.html55 false;SPOTMaps (France);wms:http://spotmaps.youmapps.org/cgi-bin/mapserv?map=/home/ortho/ortho.map&service=wms&version=1.1.1&srs=EPSG:4326&request=GetMap&layers=spotmaps4osm&format=image/jpeg&FORMAT=image/jpeg&VERSION=1.1.1&SERVICE=WMS&REQUEST=GetMap&Layers=demo&;http://www.youmapps.org/licenses/EULA-OSM-J-{lang}.html 56 56 # 57 57 # -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/AddImageryLayerAction.java
r24493 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 8 8 import org.openstreetmap.josm.actions.JosmAction; 9 9 10 public class WMSDownloadAction extends JosmAction {10 public class AddImageryLayerAction extends JosmAction { 11 11 12 private final WMSInfo info;12 private final ImageryInfo info; 13 13 14 public WMSDownloadAction(WMSInfo info) {15 super(info.getMenuName(), "wmsmenu", tr(" Download WMS tile from {0}",info.name), null, false);16 putValue("toolbar", " wms_" + info.getToolbarName());14 public AddImageryLayerAction(ImageryInfo info) { 15 super(info.getMenuName(), "wmsmenu", tr("Add imagery layer {0}",info.getName()), null, false); 16 putValue("toolbar", "imagery_" + info.getToolbarName()); 17 17 this.info = info; 18 18 } 19 19 20 @Override 20 21 public void actionPerformed(ActionEvent e) { 21 WMSLayer wmsLayer = new WMSLayer(info);22 ImageryLayer wmsLayer = ImageryLayer.create(info); 22 23 Main.main.addLayer(wmsLayer); 23 24 } -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryAdjustAction.java
r24493 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 30 30 31 31 32 public class WMSAdjustAction extends MapMode implements MouseListener, MouseMotionListener{ 33 //static private final Logger logger = Logger.getLogger(WMSAdjustAction.class.getName()); 34 35 GeorefImage selectedImage; 32 public class ImageryAdjustAction extends MapMode implements MouseListener, MouseMotionListener{ 33 36 34 boolean mouseDown; 37 35 EastNorth prevEastNorth; 38 private WMSLayer adjustingLayer;39 40 public WMSAdjustAction(MapFrame mapFrame) {41 super(tr("Adjust WMS"), "adjustwms",42 tr("Adjust the position of the selected WMSlayer"), mapFrame,36 private ImageryLayer adjustingLayer; 37 38 public ImageryAdjustAction(MapFrame mapFrame) { 39 super(tr("Adjust imagery"), "adjustwms", 40 tr("Adjust the position of the selected imagery layer"), mapFrame, 43 41 ImageProvider.getCursor("normal", "move")); 44 42 } 45 46 47 43 48 44 @Override public void enterMode() { 49 45 super.enterMode(); 50 if (!has WMSLayersToAdjust()) {51 warnNo WMSLayers();46 if (!hasLayersToAdjust()) { 47 warnNoImageryLayers(); 52 48 return; 53 49 } 54 List< WMSLayer> wmsLayers = Main.map.mapView.getLayersOfType(WMSLayer.class);55 if ( wmsLayers.size() == 1) {56 adjustingLayer = wmsLayers.get(0);50 List<ImageryLayer> imageryLayers = Main.map.mapView.getLayersOfType(ImageryLayer.class); 51 if (imageryLayers.size() == 1) { 52 adjustingLayer = imageryLayers.get(0); 57 53 } else { 58 adjustingLayer = ( WMSLayer)askAdjustLayer(Main.map.mapView.getLayersOfType(WMSLayer.class));54 adjustingLayer = (ImageryLayer)askAdjustLayer(Main.map.mapView.getLayersOfType(ImageryLayer.class)); 59 55 } 60 56 if (adjustingLayer == null) … … 80 76 if (adjustingLayer.isVisible()) { 81 77 prevEastNorth=Main.map.mapView.getEastNorth(e.getX(),e.getY()); 82 selectedImage = adjustingLayer.findImage(prevEastNorth);83 if(selectedImage!=null) {84 78 Main.map.mapView.setCursor 85 79 (Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); 86 }87 80 } 88 81 } 89 82 90 83 @Override public void mouseDragged(MouseEvent e) { 91 if(selectedImage!=null) { 92 EastNorth eastNorth= 93 Main.map.mapView.getEastNorth(e.getX(),e.getY()); 94 adjustingLayer.displace( 95 eastNorth.east()-prevEastNorth.east(), 96 eastNorth.north()-prevEastNorth.north() 97 ); 98 prevEastNorth = eastNorth; 99 Main.map.mapView.repaint(); 100 } 84 EastNorth eastNorth = 85 Main.map.mapView.getEastNorth(e.getX(),e.getY()); 86 adjustingLayer.displace( 87 eastNorth.east()-prevEastNorth.east(), 88 eastNorth.north()-prevEastNorth.north() 89 ); 90 prevEastNorth = eastNorth; 91 Main.map.mapView.repaint(); 101 92 } 102 93 … … 104 95 Main.map.mapView.repaint(); 105 96 Main.map.mapView.setCursor(Cursor.getDefaultCursor()); 106 selectedImage = null;107 97 prevEastNorth = null; 108 98 } … … 124 114 125 115 @Override public boolean layerIsSupported(Layer l) { 126 return has WMSLayersToAdjust();116 return hasLayersToAdjust(); 127 117 } 128 118 … … 155 145 156 146 /** 157 * Prompts the user with a list of WMSlayers which can be adjusted147 * Prompts the user with a list of imagery layers which can be adjusted 158 148 * 159 149 * @param adjustableLayers the list of adjustable layers … … 168 158 JPanel pnl = new JPanel(); 169 159 pnl.setLayout(new GridBagLayout()); 170 pnl.add(new JLabel(tr("Please select the WMSlayer to adjust.")), GBC.eol());160 pnl.add(new JLabel(tr("Please select the imagery layer to adjust.")), GBC.eol()); 171 161 pnl.add(layerList, GBC.eol()); 172 162 173 163 ExtendedDialog diag = new ExtendedDialog( 174 164 Main.parent, 175 tr("Select WMSlayer"),165 tr("Select imagery layer"), 176 166 new String[] { tr("Start adjusting"),tr("Cancel") } 177 167 ); … … 187 177 188 178 /** 189 * Displays a warning message if there are no WMSlayers to adjust190 * 191 */ 192 protected void warnNo WMSLayers() {179 * Displays a warning message if there are no imagery layers to adjust 180 * 181 */ 182 protected void warnNoImageryLayers() { 193 183 JOptionPane.showMessageDialog( 194 184 Main.parent, 195 tr("There are currently no WMSlayer to adjust."),185 tr("There are currently no imagery layer to adjust."), 196 186 tr("No layers to adjust"), 197 187 JOptionPane.WARNING_MESSAGE … … 204 194 * @return true if there is at least one WMS layer 205 195 */ 206 protected boolean has WMSLayersToAdjust() {196 protected boolean hasLayersToAdjust() { 207 197 if (Main.map == null) return false; 208 198 if (Main.map.mapView == null) return false; 209 return ! Main.map.mapView.getLayersOfType( WMSLayer.class).isEmpty();199 return ! Main.map.mapView.getLayersOfType(ImageryLayer.class).isEmpty(); 210 200 } 211 201 212 202 @Override 213 203 protected void updateEnabledState() { 214 setEnabled(has WMSLayersToAdjust());204 setEnabled(hasLayersToAdjust()); 215 205 } 216 206 } -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryInfo.java
r24493 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery; 2 2 3 3 import java.util.ArrayList; … … 9 9 * @author Frederik Ramm <frederik@remote.org> 10 10 */ 11 public class WMSInfo implements Comparable<WMSInfo> { 11 public class ImageryInfo implements Comparable<ImageryInfo> { 12 public enum ImageryType { 13 WMS("wms"), 14 TMS("tms"), 15 HTML("html"), 16 BING("bing"); 17 18 private String urlString; 19 ImageryType(String urlString) { 20 this.urlString = urlString; 21 } 22 public String getUrlString() { 23 return urlString; 24 } 25 } 12 26 13 27 String name; … … 15 29 String cookies = null; 16 30 String eulaAcceptanceRequired = null; 17 boolean html = false;31 ImageryType imageryType = ImageryType.WMS; 18 32 double pixelPerDegree = 0.0; 19 33 20 public WMSInfo(String name) {34 public ImageryInfo(String name) { 21 35 this.name=name; 22 36 } 23 37 24 public WMSInfo(String name, String url) {38 public ImageryInfo(String name, String url) { 25 39 this.name=name; 26 40 setURL(url); 27 41 } 28 42 29 public WMSInfo(String name, String url, String eulaAcceptanceRequired) {43 public ImageryInfo(String name, String url, String eulaAcceptanceRequired) { 30 44 this.name=name; 31 45 setURL(url); … … 33 47 } 34 48 35 public WMSInfo(String name, String url, String eulaAcceptanceRequired, String cookies) {49 public ImageryInfo(String name, String url, String eulaAcceptanceRequired, String cookies) { 36 50 this.name=name; 37 51 setURL(url); … … 39 53 } 40 54 41 public WMSInfo(String name, String url, String cookies, double pixelPerDegree) {55 public ImageryInfo(String name, String url, String cookies, double pixelPerDegree) { 42 56 this.name=name; 43 57 setURL(url); … … 64 78 } 65 79 66 public WMSInfo(Collection<String> list) {80 public ImageryInfo(Collection<String> list) { 67 81 ArrayList<String> array = new ArrayList<String>(list); 68 82 this.name=array.get(0); … … 72 86 } 73 87 74 public WMSInfo(WMSInfo i) {88 public ImageryInfo(ImageryInfo i) { 75 89 this.name=i.name; 76 90 this.url=i.url; 77 91 this.cookies=i.cookies; 78 this. html=i.html;92 this.imageryType=i.imageryType; 79 93 this.pixelPerDegree=i.pixelPerDegree; 80 94 } 81 95 82 public int compareTo(WMSInfo in) 96 @Override 97 public int compareTo(ImageryInfo in) 83 98 { 84 99 int i = name.compareTo(in.name); … … 90 105 } 91 106 92 public boolean equalsBaseValues( WMSInfo in)107 public boolean equalsBaseValues(ImageryInfo in) 93 108 { 94 109 return url.equals(in.url); … … 100 115 101 116 public void setURL(String url) { 102 if(url.startsWith("html:")) { 103 this.url = url.substring(5); 104 html = true; 105 } else { 106 this.url = url; 117 for (ImageryType type : ImageryType.values()) { 118 if (url.startsWith(type.getUrlString() + ":")) { 119 this.url = url.substring(type.getUrlString().length() + 1); 120 this.imageryType = type; 121 return; 122 } 107 123 } 124 125 // Default imagery type is WMS 126 this.url = url; 127 this.imageryType = ImageryType.WMS; 128 } 129 130 public String getName() { 131 return this.name; 132 } 133 134 public void setName(String name) { 135 this.name = name; 136 } 137 138 public String getURL() { 139 return this.url; 140 } 141 142 public String getCookies() { 143 return this.cookies; 144 } 145 146 public double getPixelPerDegree() { 147 return this.pixelPerDegree; 108 148 } 109 149 110 150 public String getFullURL() { 111 return html ? "html:" + url :url;151 return imageryType.getUrlString() + ":" + url; 112 152 } 113 153 … … 127 167 return res; 128 168 } 169 170 public ImageryType getImageryType() { 171 return imageryType; 172 } 129 173 } -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryLayerInfo.java
r24493 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 18 18 import org.openstreetmap.josm.io.MirroredInputStream; 19 19 20 public class WMSLayerInfo { 21 ArrayList<WMSInfo> layers = new ArrayList<WMSInfo>(); 22 ArrayList<WMSInfo> defaultLayers = new ArrayList<WMSInfo>(); 23 private final static String[] DEFAULT_LAYER_SITES = { "http://josm.openstreetmap.de/maps"}; 20 public class ImageryLayerInfo { 21 ArrayList<ImageryInfo> layers = new ArrayList<ImageryInfo>(); 22 ArrayList<ImageryInfo> defaultLayers = new ArrayList<ImageryInfo>(); 23 private final static String[] DEFAULT_LAYER_SITES 24 = { "http://svn.openstreetmap.org/applications/editors/josm/plugins/imagery/sources.cfg"}; 24 25 25 26 public void load() { 26 27 layers.clear(); 27 28 Collection<String> defaults = Main.pref.getCollection( 28 " wmslayers.default", Collections.<String>emptySet());29 for(Collection<String> c : Main.pref.getArray(" wmslayers",29 "imagery.layers.default", Collections.<String>emptySet()); 30 for(Collection<String> c : Main.pref.getArray("imagery.layers", 30 31 Collections.<Collection<String>>emptySet())) { 31 layers.add(new WMSInfo(c));32 layers.add(new ImageryInfo(c)); 32 33 } 33 34 34 35 { /* REMOVE following old block in spring 2011 */ 35 36 defaults = new LinkedList<String>(defaults); 36 Map<String,String> prefs = Main.pref.getAllPrefix(" wmsplugin.default.");37 Map<String,String> prefs = Main.pref.getAllPrefix("imagery.layers.default."); 37 38 for(String s : prefs.keySet()) { 38 39 Main.pref.put(s, null); 39 40 defaults.add(s.substring(18)); 40 41 } 41 prefs = Main.pref.getAllPrefix(" wmsplugin.url.");42 prefs = Main.pref.getAllPrefix("imagery.layers.url."); 42 43 for(String s : prefs.keySet()) { 43 44 Main.pref.put(s, null); … … 45 46 TreeSet<String> keys = new TreeSet<String>(prefs.keySet()); 46 47 47 // And then the names+urls of WMS servers48 // And then the names+urls of imagery layers 48 49 int prefid = 0; 49 50 String name = null; … … 78 79 cookies = prefs.get(key); 79 80 if (name != null && url != null) 80 layers.add(new WMSInfo(name, url, cookies, pixelPerDegree));81 layers.add(new ImageryInfo(name, url, cookies, pixelPerDegree)); 81 82 } 82 83 } 83 84 ArrayList<String> defaultsSave = new ArrayList<String>(); 84 for(String source : Main.pref.getCollection(" wmslayers.sites", Arrays.asList(DEFAULT_LAYER_SITES)))85 for(String source : Main.pref.getCollection("imagery.layers.sites", Arrays.asList(DEFAULT_LAYER_SITES))) 85 86 { 86 87 try 87 88 { 88 MirroredInputStream s = new MirroredInputStream(source, WMSPlugin.instance.getPluginDir(), -1);89 MirroredInputStream s = new MirroredInputStream(source, ImageryPlugin.instance.getPluginDir(), -1); 89 90 InputStreamReader r; 90 91 try … … 110 111 eulaAcceptanceRequired = val[3]; 111 112 } 112 defaultLayers.add(new WMSInfo(name, url, eulaAcceptanceRequired));113 defaultLayers.add(new ImageryInfo(name, url, eulaAcceptanceRequired)); 113 114 114 115 if(force) { 115 116 defaultsSave.add(url); 116 117 if(!defaults.contains(url)) { 117 int id = -1; 118 for(WMSInfo i : layers) { 118 for(ImageryInfo i : layers) { 119 119 if(url.equals(i.url)) 120 120 force = false; 121 121 } 122 122 if(force) 123 layers.add(new WMSInfo(name, url));123 layers.add(new ImageryInfo(name, url)); 124 124 } 125 125 } … … 132 132 } 133 133 134 Main.pref.putCollection(" wmslayers.default", defaultsSave.size() > 0134 Main.pref.putCollection("imagery.layers.default", defaultsSave.size() > 0 135 135 ? defaultsSave : defaults); 136 136 Collections.sort(layers); … … 138 138 } 139 139 140 public void add( WMSInfo info) {140 public void add(ImageryInfo info) { 141 141 layers.add(info); 142 142 } 143 143 144 public void remove( WMSInfo info) {144 public void remove(ImageryInfo info) { 145 145 layers.remove(info); 146 146 } … … 148 148 public void save() { 149 149 LinkedList<Collection<String>> coll = new LinkedList<Collection<String>>(); 150 for ( WMSInfo info : layers) {150 for (ImageryInfo info : layers) { 151 151 coll.add(info.getInfoArray()); 152 152 } 153 Main.pref.putArray(" wmslayers", coll);153 Main.pref.putArray("imagery.layers", coll); 154 154 } 155 155 } -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPlugin.java
r24493 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery; 2 2 3 3 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; … … 18 18 import org.openstreetmap.josm.actions.ExtensionFileFilter; 19 19 import org.openstreetmap.josm.actions.JosmAction; 20 import org.openstreetmap.josm.data.preferences.BooleanProperty;21 import org.openstreetmap.josm.data.preferences.IntegerProperty;22 20 import org.openstreetmap.josm.gui.IconToggleButton; 23 21 import org.openstreetmap.josm.gui.MainMenu; 24 22 import org.openstreetmap.josm.gui.MapFrame; 25 import org.openstreetmap.josm.gui.MapView;26 23 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 27 import org.openstreetmap.josm.io.CacheFiles;28 24 import org.openstreetmap.josm.plugins.Plugin; 29 25 import org.openstreetmap.josm.plugins.PluginHandler; 30 26 import org.openstreetmap.josm.plugins.PluginInformation; 31 27 import org.openstreetmap.josm.plugins.PluginProxy; 32 33 import wmsplugin.io.WMSLayerExporter; 34 import wmsplugin.io.WMSLayerImporter; 35 36 public class WMSPlugin extends Plugin { 37 CacheFiles cache = new CacheFiles("wmsplugin"); 38 39 public final IntegerProperty PROP_SIMULTANEOUS_CONNECTIONS = new IntegerProperty("wmsplugin.simultaneousConnections", 3); 40 public final BooleanProperty PROP_OVERLAP = new BooleanProperty("wmsplugin.url.overlap", false); 41 public final IntegerProperty PROP_OVERLAP_EAST = new IntegerProperty("wmsplugin.url.overlapEast", 14); 42 public final IntegerProperty PROP_OVERLAP_NORTH = new IntegerProperty("wmsplugin.url.overlapNorth", 4); 43 44 JMenu wmsJMenu; 45 static WMSPlugin instance; 46 47 public WMSLayerInfo info = new WMSLayerInfo(); 28 import org.openstreetmap.josm.plugins.imagery.wms.Map_Rectifier_WMSmenuAction; 29 import org.openstreetmap.josm.plugins.imagery.wms.WMSAdapter; 30 import org.openstreetmap.josm.plugins.imagery.wms.WMSLayer; 31 import org.openstreetmap.josm.plugins.imagery.wms.WMSRemoteHandler; 32 import org.openstreetmap.josm.plugins.imagery.wms.io.WMSLayerExporter; 33 import org.openstreetmap.josm.plugins.imagery.wms.io.WMSLayerImporter; 34 35 public class ImageryPlugin extends Plugin { 36 37 JMenu imageryJMenu; 38 39 public static ImageryPlugin instance; 40 public static WMSAdapter wmsAdapter = new WMSAdapter(); 41 42 public ImageryLayerInfo info = new ImageryLayerInfo(); 48 43 49 44 // remember state of menu item to restore on changed preferences … … 207 202 } 208 203 209 public WMSPlugin(PluginInformation info) {204 public ImageryPlugin(PluginInformation info) { 210 205 super(info); 211 206 instance = this; 212 207 this.info.load(); 213 208 refreshMenu(); 214 cache.setExpire(CacheFiles.EXPIRE_MONTHLY, false);215 cache.setMaxSize(70, false);216 initExporterAndImporter();217 209 initRemoteControl(); 218 210 } 219 211 220 public void addLayer( WMSInfo info) {212 public void addLayer(ImageryInfo info) { 221 213 this.info.add(info); 222 214 this.info.save(); … … 227 219 MainMenu menu = Main.main.menu; 228 220 229 if ( wmsJMenu == null)230 wmsJMenu = menu.addMenu(marktr("WMS"), KeyEvent.VK_W, menu.defaultMenuPos, ht("/Plugin/WMS"));221 if (imageryJMenu == null) 222 imageryJMenu = menu.addMenu(marktr("Imagery"), KeyEvent.VK_W, menu.defaultMenuPos, ht("/Plugin/Imagery")); 231 223 else 232 wmsJMenu.removeAll();224 imageryJMenu.removeAll(); 233 225 234 226 // for each configured WMSInfo, add a menu entry. 235 for (final WMSInfo u : info.layers) {236 wmsJMenu.add(new JMenuItem(new WMSDownloadAction(u)));237 } 238 wmsJMenu.addSeparator();239 wmsJMenu.add(new JMenuItem(new Map_Rectifier_WMSmenuAction()));240 241 wmsJMenu.addSeparator();242 wmsJMenu.add(new JMenuItem(new227 for (final ImageryInfo u : info.layers) { 228 imageryJMenu.add(new JMenuItem(new AddImageryLayerAction(u))); 229 } 230 imageryJMenu.addSeparator(); 231 imageryJMenu.add(new JMenuItem(new Map_Rectifier_WMSmenuAction())); 232 233 imageryJMenu.addSeparator(); 234 imageryJMenu.add(new JMenuItem(new 243 235 JosmAction(tr("Blank Layer"), "blankmenu", tr("Open a blank WMS layer to load data from a file"), null, false) { 236 @Override 244 237 public void actionPerformed(ActionEvent ev) { 245 238 Main.main.addLayer(new WMSLayer()); … … 249 242 } 250 243 251 public Grabber getGrabber(MapView mv, WMSLayer layer){252 if(layer.info.html)253 return new HTMLGrabber(mv, layer, cache);254 else255 return new WMSGrabber(mv, layer, cache);256 }257 258 244 private void setEnabledAll(boolean isEnabled) { 259 for(int i=0; i < wmsJMenu.getItemCount(); i++) {260 JMenuItem item = wmsJMenu.getItem(i);245 for(int i=0; i < imageryJMenu.getItemCount(); i++) { 246 JMenuItem item = imageryJMenu.getItem(i); 261 247 262 248 if(item != null) item.setEnabled(isEnabled); … … 270 256 setEnabledAll(true); 271 257 Main.map.addMapMode(new IconToggleButton 272 (new WMSAdjustAction(Main.map)));258 (new ImageryAdjustAction(Main.map))); 273 259 } else if (oldFrame!=null && newFrame==null ) { 274 260 setEnabledAll(false); … … 278 264 @Override 279 265 public PreferenceSetting getPreferenceSetting() { 280 return new WMSPreferenceEditor();266 return new ImageryPreferenceEditor(); 281 267 } 282 268 … … 284 270 public String getPluginDir() 285 271 { 286 return new File(Main.pref.getPluginsDirectory(), " wmsplugin").getPath();272 return new File(Main.pref.getPluginsDirectory(), "imagery").getPath(); 287 273 } 288 274 } -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPreferenceEditor.java
r24493 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 33 33 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 34 34 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 35 import org.openstreetmap.josm.plugins.imagery.wms.AddWMSLayerPanel; 36 import org.openstreetmap.josm.plugins.imagery.wms.WMSAdapter; 35 37 import org.openstreetmap.josm.tools.GBC; 36 38 37 public class WMSPreferenceEditor implements PreferenceSetting {38 private WMSLayerTableModel model;39 public class ImageryPreferenceEditor implements PreferenceSetting { 40 private ImageryLayerTableModel model; 39 41 private JComboBox browser; 40 42 … … 45 47 JCheckBox remoteCheckBox; 46 48 boolean allowRemoteControl = true; 47 WMSPlugin plugin = WMSPlugin.instance; 48 49 WMSAdapter wmsAdapter = ImageryPlugin.wmsAdapter; 50 ImageryPlugin plugin = ImageryPlugin.instance; 51 52 @Override 49 53 public void addGui(final PreferenceTabbedPane gui) { 50 JPanel p = gui.createPreferenceTab("wms", tr(" WMS Plugin Preferences"), tr("Modify list of WMS servers displayed in the WMS pluginmenu"));51 52 model = new WMSLayerTableModel();54 JPanel p = gui.createPreferenceTab("wms", tr("Imagery Preferences"), tr("Modify list of imagery layers displayed in the Imagery menu")); 55 56 model = new ImageryLayerTableModel(); 53 57 final JTable list = new JTable(model) { 54 58 @Override … … 62 66 scroll.setPreferredSize(new Dimension(200, 200)); 63 67 64 final WMSDefaultLayerTableModel modeldef = new WMSDefaultLayerTableModel();68 final ImageryDefaultLayerTableModel modeldef = new ImageryDefaultLayerTableModel(); 65 69 final JTable listdef = new JTable(modeldef) { 66 70 @Override … … 88 92 buttonPanel.add(add, GBC.std().insets(0, 5, 0, 0)); 89 93 add.addActionListener(new ActionListener() { 94 @Override 90 95 public void actionPerformed(ActionEvent e) { 91 96 AddWMSLayerPanel p = new AddWMSLayerPanel(); 92 97 int answer = JOptionPane.showConfirmDialog( 93 98 gui, p, 94 tr("Add WMSURL"),99 tr("Add Imagery URL"), 95 100 JOptionPane.OK_CANCEL_OPTION); 96 101 if (answer == JOptionPane.OK_OPTION) { 97 model.addRow(new WMSInfo(p.getUrlName(), p.getUrl()));102 model.addRow(new ImageryInfo(p.getUrlName(), p.getUrl())); 98 103 } 99 104 } … … 103 108 buttonPanel.add(delete, GBC.std().insets(0, 5, 0, 0)); 104 109 delete.addActionListener(new ActionListener() { 110 @Override 105 111 public void actionPerformed(ActionEvent e) { 106 112 if (list.getSelectedRow() == -1) … … 117 123 buttonPanel.add(copy, GBC.std().insets(0, 5, 0, 0)); 118 124 copy.addActionListener(new ActionListener() { 125 @Override 119 126 public void actionPerformed(ActionEvent e) { 120 127 int[] lines = listdef.getSelectedRows(); … … 129 136 130 137 outer: for (int i = 0; i < lines.length; i++) { 131 WMSInfo info = modeldef.getRow(lines[i]);138 ImageryInfo info = modeldef.getRow(lines[i]); 132 139 133 140 // Check if an entry with exactly the same values already … … 148 155 } 149 156 150 model.addRow(new WMSInfo(info));157 model.addRow(new ImageryInfo(info)); 151 158 int lastLine = model.getRowCount() - 1; 152 159 list.getSelectionModel().setSelectionInterval(lastLine, lastLine); … … 174 181 p.add(Box.createHorizontalGlue(), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 175 182 176 overlapCheckBox = new JCheckBox(tr("Overlap tiles"), plugin.PROP_OVERLAP.get());183 overlapCheckBox = new JCheckBox(tr("Overlap tiles"), wmsAdapter.PROP_OVERLAP.get()); 177 184 JLabel labelEast = new JLabel(tr("% of east:")); 178 185 JLabel labelNorth = new JLabel(tr("% of north:")); 179 spinEast = new JSpinner(new SpinnerNumberModel( plugin.PROP_OVERLAP_EAST.get(), 1, 50, 1));180 spinNorth = new JSpinner(new SpinnerNumberModel( plugin.PROP_OVERLAP_NORTH.get(), 1, 50, 1));186 spinEast = new JSpinner(new SpinnerNumberModel(wmsAdapter.PROP_OVERLAP_EAST.get(), 1, 50, 1)); 187 spinNorth = new JSpinner(new SpinnerNumberModel(wmsAdapter.PROP_OVERLAP_NORTH.get(), 1, 50, 1)); 181 188 182 189 JPanel overlapPanel = new JPanel(new FlowLayout()); … … 192 199 p.add(Box.createHorizontalGlue(), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 193 200 JLabel labelSimConn = new JLabel(tr("Simultaneous connections")); 194 spinSimConn = new JSpinner(new SpinnerNumberModel( plugin.PROP_SIMULTANEOUS_CONNECTIONS.get(), 1, 30, 1));201 spinSimConn = new JSpinner(new SpinnerNumberModel(wmsAdapter.PROP_SIMULTANEOUS_CONNECTIONS.get(), 1, 30, 1)); 195 202 JPanel overlapPanelSimConn = new JPanel(new FlowLayout()); 196 203 overlapPanelSimConn.add(labelSimConn); … … 206 213 } 207 214 215 @Override 208 216 public boolean ok() { 209 217 plugin.info.save(); 210 218 plugin.refreshMenu(); 211 219 212 plugin.PROP_OVERLAP.put(overlapCheckBox.getModel().isSelected());213 plugin.PROP_OVERLAP_EAST.put((Integer) spinEast.getModel().getValue());214 plugin.PROP_OVERLAP_NORTH.put((Integer) spinNorth.getModel().getValue());215 plugin.PROP_SIMULTANEOUS_CONNECTIONS.put((Integer) spinSimConn.getModel().getValue());220 wmsAdapter.PROP_OVERLAP.put(overlapCheckBox.getModel().isSelected()); 221 wmsAdapter.PROP_OVERLAP_EAST.put((Integer) spinEast.getModel().getValue()); 222 wmsAdapter.PROP_OVERLAP_NORTH.put((Integer) spinNorth.getModel().getValue()); 223 wmsAdapter.PROP_SIMULTANEOUS_CONNECTIONS.put((Integer) spinSimConn.getModel().getValue()); 216 224 allowRemoteControl = remoteCheckBox.getModel().isSelected(); 217 225 … … 260 268 * 261 269 */ 262 class WMSLayerTableModel extends DefaultTableModel {263 public WMSLayerTableModel() {264 setColumnIdentifiers(new String[] { tr("Menu Name"), tr(" WMSURL"), trc("layer", "Zoom") });265 } 266 267 public WMSInfo getRow(int row) {270 class ImageryLayerTableModel extends DefaultTableModel { 271 public ImageryLayerTableModel() { 272 setColumnIdentifiers(new String[] { tr("Menu Name"), tr("Imagery URL"), trc("layer", "Zoom") }); 273 } 274 275 public ImageryInfo getRow(int row) { 268 276 return plugin.info.layers.get(row); 269 277 } 270 278 271 public void addRow( WMSInfo i) {279 public void addRow(ImageryInfo i) { 272 280 plugin.info.add(i); 273 281 int p = getRowCount() - 1; … … 288 296 @Override 289 297 public Object getValueAt(int row, int column) { 290 WMSInfo info = plugin.info.layers.get(row);298 ImageryInfo info = plugin.info.layers.get(row); 291 299 switch (column) { 292 300 case 0: … … 302 310 @Override 303 311 public void setValueAt(Object o, int row, int column) { 304 WMSInfo info = plugin.info.layers.get(row);312 ImageryInfo info = plugin.info.layers.get(row); 305 313 switch (column) { 306 314 case 0: … … 321 329 * 322 330 */ 323 class WMSDefaultLayerTableModel extends DefaultTableModel {324 public WMSDefaultLayerTableModel() {325 setColumnIdentifiers(new String[] { tr("Menu Name (Default)"), tr(" WMSURL (Default)") });326 } 327 328 public WMSInfo getRow(int row) {331 class ImageryDefaultLayerTableModel extends DefaultTableModel { 332 public ImageryDefaultLayerTableModel() { 333 setColumnIdentifiers(new String[] { tr("Menu Name (Default)"), tr("Imagery URL (Default)") }); 334 } 335 336 public ImageryInfo getRow(int row) { 329 337 return plugin.info.defaultLayers.get(row); 330 338 } … … 337 345 @Override 338 346 public Object getValueAt(int row, int column) { 339 WMSInfo info = plugin.info.defaultLayers.get(row);347 ImageryInfo info = plugin.info.defaultLayers.get(row); 340 348 switch (column) { 341 349 case 0: -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSKey.java
r24493 r24501 2 2 * 3 3 */ 4 package org.openstreetmap.josm.plugins. slippymap;4 package org.openstreetmap.josm.plugins.imagery.tms; 5 5 6 6 /** … … 14 14 * 15 15 */ 16 public class SlippyMapKey {16 public class TMSKey { 17 17 private final int x; 18 18 private final int y; … … 29 29 */ 30 30 public final boolean valid; 31 public SlippyMapKey(int x, int y, int level) {31 public TMSKey(int x, int y, int level) { 32 32 this.x = x; 33 33 this.y = y; … … 35 35 if (level <= 0 || x < 0 || y < 0) { 36 36 this.valid = false; 37 System.err.println("invalid SlippyMapKey("+level+", "+x+", "+y+")");37 System.err.println("invalid TMSKey("+level+", "+x+", "+y+")"); 38 38 } else { 39 39 this.valid = true; … … 50 50 @Override 51 51 public boolean equals(Object obj) { 52 if (obj instanceof SlippyMapKey) {53 SlippyMapKey smk = (SlippyMapKey) obj;52 if (obj instanceof TMSKey) { 53 TMSKey smk = (TMSKey) obj; 54 54 if((smk.x == this.x) && (smk.y == this.y) && (smk.level == this.level)) { 55 55 return true; … … 73 73 @Override 74 74 public String toString() { 75 return " SlippyMapKey(x=" + this.x + ",y=" + this.y + ",level=" + level + ")";75 return "TMSKey(x=" + this.x + ",y=" + this.y + ",level=" + level + ")"; 76 76 } 77 77 -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSLayer.java
r24493 r24501 1 package org.openstreetmap.josm.plugins. slippymap;1 package org.openstreetmap.josm.plugins.imagery.tms; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 26 26 import javax.swing.AbstractAction; 27 27 import javax.swing.Action; 28 import javax.swing.Icon;29 28 import javax.swing.JCheckBoxMenuItem; 30 29 import javax.swing.JMenuItem; … … 50 49 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 51 50 import org.openstreetmap.josm.gui.layer.Layer; 52 import org.openstreetmap.josm.tools.ImageProvider; 51 import org.openstreetmap.josm.plugins.imagery.ImageryInfo; 52 import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType; 53 import org.openstreetmap.josm.plugins.imagery.ImageryLayer; 53 54 54 55 /** … … 60 61 * 61 62 */ 62 public class SlippyMapLayer extends Layer implements ImageObserver, 63 TileLoaderListener { 63 public class TMSLayer extends ImageryLayer implements ImageObserver, TileLoaderListener { 64 64 boolean debug = false; 65 65 void out(String s) … … 74 74 75 75 HashSet<Tile> tileRequestsOutstanding = new HashSet<Tile>(); 76 @Override 76 77 public synchronized void tileLoadingFinished(Tile tile, boolean success) 77 78 { … … 83 84 out("tileLoadingFinished() tile: " + tile + " success: " + success); 84 85 } 86 @Override 85 87 public TileCache getTileCache() 86 88 { … … 97 99 /** 98 100 * Actual zoom lvl. Initial zoom lvl is set to 99 * {@link SlippyMapPreferences#getMinZoomLvl()}.100 101 */ 101 102 public int currentZoomLevel; … … 115 116 private static Font ATTR_LINK_FONT = Font.decode("Arial Underline 10"); 116 117 118 protected boolean autoZoom = true; 119 protected boolean autoLoad = true; 120 117 121 void redraw() 118 122 { … … 121 125 } 122 126 123 void newTileStorage()127 private void setTileStorage(TileSource tileSource) 124 128 { 125 129 int origZoom = currentZoomLevel; 126 t ileSource = SlippyMapPreferences.getMapSource();130 this.tileSource = tileSource; 127 131 boolean requireAttr = tileSource.requiresAttribution(); 128 132 if(requireAttr) { … … 133 137 System.out.println("Got an attribution image " + attrImage.getHeight(this) + "x" + attrImage.getWidth(this)); 134 138 } 135 139 136 140 attrTermsUrl = tileSource.getTermsOfUseURL(); 137 141 } 138 142 139 143 // The minimum should also take care of integer parsing 140 144 // errors which would leave us with a zoom of -1 otherwise … … 147 151 out("tileSource.getMinZoom(): " + tileSource.getMinZoom()); 148 152 out("tileSource.getMaxZoom(): " + tileSource.getMaxZoom()); 149 SlippyMapPreferences.setLastZoom(currentZoomLevel);150 153 } 151 154 clearTileCache(); 152 //tile Loader = new OsmTileLoader(this);155 //tileloader = new OsmTileLoader(this); 153 156 tileLoader = new OsmFileCacheTileLoader(this); 154 157 } 155 158 159 @Override 160 public void displace(double dx, double dy) { 161 super.displace(dx, dy); 162 needRedraw = true; 163 } 164 156 165 @SuppressWarnings("serial") 157 public SlippyMapLayer() {158 super( tr("Slippy Map"));166 public TMSLayer(ImageryInfo info) { 167 super(info.getName()); 159 168 160 169 setBackgroundLayer(true); 161 170 this.setVisible(true); 162 171 163 currentZoomLevel = SlippyMapPreferences.getLastZoom(); 164 newTileStorage(); 172 currentZoomLevel = 0; //FIXME: detect current zoom level 173 if (info.getImageryType() == ImageryType.TMS) { 174 setTileStorage(new TMSTileSource(info.getName(),info.getURL())); 175 } else if (info.getImageryType() == ImageryType.BING) { 176 setTileStorage(new BingAerialTileSource()); 177 } else throw new AssertionError(); 165 178 166 179 tileOptionMenu = new JPopupMenu(); … … 168 181 autoZoomPopup = new JCheckBoxMenuItem(); 169 182 autoZoomPopup.setAction(new AbstractAction(tr("Auto Zoom")) { 183 @Override 170 184 public void actionPerformed(ActionEvent ae) { 171 boolean new_state = !SlippyMapPreferences.getAutozoom(); 172 SlippyMapPreferences.setAutozoom(new_state); 185 autoZoom = !autoZoom; 173 186 } 174 187 }); 175 autoZoomPopup.setSelected( SlippyMapPreferences.getAutozoom());188 autoZoomPopup.setSelected(autoZoom); 176 189 tileOptionMenu.add(autoZoomPopup); 177 190 178 191 tileOptionMenu.add(new JMenuItem(new AbstractAction(tr("Load Tile")) { 192 @Override 179 193 public void actionPerformed(ActionEvent ae) { 180 194 if (clickedTile != null) { … … 187 201 tileOptionMenu.add(new JMenuItem(new AbstractAction( 188 202 tr("Show Tile Info")) { 203 @Override 189 204 public void actionPerformed(ActionEvent ae) { 190 205 out("info tile: " + clickedTile); … … 209 224 tileOptionMenu.add(new JMenuItem(new AbstractAction( 210 225 tr("Load All Tiles")) { 226 @Override 211 227 public void actionPerformed(ActionEvent ae) { 212 228 loadAllTiles(true); … … 218 234 tileOptionMenu.add(new JMenuItem( 219 235 new AbstractAction(tr("Increase zoom")) { 236 @Override 220 237 public void actionPerformed(ActionEvent ae) { 221 238 increaseZoomLevel(); … … 226 243 tileOptionMenu.add(new JMenuItem( 227 244 new AbstractAction(tr("Decrease zoom")) { 245 @Override 228 246 public void actionPerformed(ActionEvent ae) { 229 247 decreaseZoomLevel(); … … 236 254 tileOptionMenu.add(new JMenuItem( 237 255 new AbstractAction(tr("Snap to tile size")) { 256 @Override 238 257 public void actionPerformed(ActionEvent ae) { 239 258 if (lastImageScale == null) { … … 252 271 tileOptionMenu.add(new JMenuItem( 253 272 new AbstractAction(tr("Flush Tile Cache")) { 273 @Override 254 274 public void actionPerformed(ActionEvent ae) { 255 275 System.out.print("flushing all tiles..."); … … 261 281 262 282 SwingUtilities.invokeLater(new Runnable() { 283 @Override 263 284 public void run() { 264 285 Main.map.mapView.addMouseListener(new MouseAdapter() { … … 272 293 return; 273 294 } 274 295 275 296 if(attrImageBounds.contains(e.getPoint())) { 276 297 try { … … 297 318 298 319 MapView.addLayerChangeListener(new LayerChangeListener() { 320 @Override 299 321 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 300 322 // 301 323 } 302 324 325 @Override 303 326 public void layerAdded(Layer newLayer) { 304 327 // 305 328 } 306 329 330 @Override 307 331 public void layerRemoved(Layer oldLayer) { 308 332 MapView.removeLayerChangeListener(this); … … 320 344 jobDispatcher.cancelOutstandingJobs(); 321 345 tileRequestsOutstanding.clear(); 322 SlippyMapPreferences.setLastZoom(currentZoomLevel);323 346 } 324 347 325 348 int getMaxZoomLvl() 326 349 { 327 int ret = SlippyMapPreferences.getMaxZoomLvl(); 328 if (tileSource.getMaxZoom() < ret) 329 ret = tileSource.getMaxZoom(); 330 return ret; 350 return tileSource.getMaxZoom(); 331 351 } 332 352 333 353 int getMinZoomLvl() 334 354 { 335 int ret = SlippyMapPreferences.getMinZoomLvl(); 336 if (tileSource.getMinZoom() > ret) 337 ret = tileSource.getMinZoom(); 338 return ret; 355 return tileSource.getMinZoom(); 339 356 } 340 357 … … 466 483 */ 467 484 Image lastScaledImage = null; 485 @Override 468 486 public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { 469 487 boolean done = ((infoflags & (ERROR | FRAMEBITS | ALLBITS)) != 0); … … 641 659 img_x_end, img_y_end, 642 660 this); 643 float fadeBackground = SlippyMapPreferences.getFadeBackground();644 if (fadeBackground != 0f) {645 // dimm by painting opaque rect...646 g.setColor(new Color(1f, 1f, 1f, fadeBackground));647 g.fillRect(target.x, target.y,648 target.width, target.height);649 }650 661 } 651 662 Double lastImageScale = null; … … 692 703 int texty = p.y + 2 + fontHeight; 693 704 694 if (SlippyMapPreferences.getDrawDebug()) {695 g.drawString("x=" + t.getXtile() + " y=" + t.getYtile() + " z=" + zoom + "", p.x + 2, texty);696 texty += 1 + fontHeight;697 if ((t.getXtile() % 32 == 0) && (t.getYtile() % 32 == 0)) {698 g.drawString("x=" + t.getXtile() / 32 + " y=" + t.getYtile() / 32 + " z=7", p.x + 2, texty);699 texty += 1 + fontHeight;700 }701 }// end of if draw debug702 703 705 if (tile == showMetadataTile) { 704 706 String md = tile.toString(); … … 714 716 texty += 1 + fontHeight; 715 717 } 716 717 int xCursor = -1;718 int yCursor = -1;719 if (SlippyMapPreferences.getDrawDebug()) {720 if (yCursor < t.getYtile()) {721 if (t.getYtile() % 32 == 31) {722 g.fillRect(0, p.y - 1, mv.getWidth(), 3);723 } else {724 g.drawLine(0, p.y, mv.getWidth(), p.y);725 }726 yCursor = t.getYtile();727 }728 // This draws the vertical lines for the entire729 // column. Only draw them for the top tile in730 // the column.731 if (xCursor < t.getXtile()) {732 if (SlippyMapPreferences.getDrawDebug()) {733 if (t.getXtile() % 32 == 0) {734 // level 7 tile boundary735 g.fillRect(p.x - 1, 0, 3, mv.getHeight());736 } else {737 g.drawLine(p.x, 0, p.x, mv.getHeight());738 }739 }740 xCursor = t.getXtile();741 }742 }743 718 } 744 719 745 720 public Point pixelPos(LatLon ll) { 746 return Main.map.mapView.getPoint( ll);721 return Main.map.mapView.getPoint(Main.proj.latlon2eastNorth(ll).add(getDx(), getDy())); 747 722 } 748 723 public Point pixelPos(Tile t) { … … 828 803 { 829 804 List<Tile> tiles = this.allTiles(true); 830 boolean autoload = SlippyMapPreferences.getAutoloadTiles();805 boolean autoload = TMSLayer.this.autoLoad; 831 806 if (!autoload && !force) 832 807 return; … … 847 822 if (az_disable) 848 823 return false; 849 return autoZoom Popup.isSelected();824 return autoZoom; 850 825 } 851 826 /** … … 928 903 if (!autoZoomEnabled()) 929 904 break; 930 if (! SlippyMapPreferences.getAutoloadTiles())905 if (!autoLoad) 931 906 break; 932 907 int newzoom = currentZoomLevel + zoomOffset; … … 961 936 Font font = g.getFont(); 962 937 g.setFont(ATTR_LINK_FONT); 963 938 964 939 // Draw terms of use text 965 940 Rectangle2D termsStringBounds = g.getFontMetrics().getStringBounds("Background Terms of Use", g); … … 973 948 g.drawString("Background Terms of Use", x, y); 974 949 } 975 950 976 951 // Draw attribution logo 977 952 int imgWidth = attrImage.getWidth(this); … … 983 958 g.drawImage(attrImage, x, y, this); 984 959 } 985 960 986 961 String attributionText = tileSource.getAttributionText(currentZoomLevel, topLeft, botRight); 987 962 Rectangle2D stringBounds = g.getFontMetrics().getStringBounds(attributionText, g); 988 963 g.drawString(attributionText, mv.getWidth() - (int) stringBounds.getWidth(), mv.getHeight() - textHeight); 989 964 990 965 g.setFont(font); 991 966 } … … 1057 1032 1058 1033 @Override 1059 public Icon getIcon() {1060 return ImageProvider.get("slippymap");1061 }1062 1063 @Override1064 public Object getInfoComponent() {1065 return null;1066 }1067 1068 @Override1069 1034 public Action[] getMenuEntries() { 1070 1035 return new Action[] { … … 1084 1049 1085 1050 @Override 1086 public boolean isMergable(Layer other) {1087 return false;1088 }1089 1090 @Override1091 public void mergeFrom(Layer from) {1092 }1093 1094 @Override1095 1051 public void visitBoundingBox(BoundingXYVisitor v) { 1096 1052 } -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/AddWMSLayerPanel.java
r23904 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery.wms; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 88 88 JButton getLayersButton = new JButton(tr("Get Layers")); 89 89 getLayersButton.addActionListener(new ActionListener() { 90 @Override 90 91 public void actionPerformed(ActionEvent e) { 91 92 Cursor beforeCursor = getCursor(); … … 106 107 layerTree.addTreeSelectionListener(new TreeSelectionListener() { 107 108 109 @Override 108 110 public void valueChanged(TreeSelectionEvent e) { 109 111 TreePath[] selectionRows = layerTree.getSelectionPaths(); … … 152 154 showBoundsButton.setEnabled(false); 153 155 showBoundsButton.addActionListener(new ActionListener() { 156 @Override 154 157 public void actionPerformed(ActionEvent e) { 155 158 if(selectedLayer.bounds != null) { … … 271 274 DocumentBuilder builder = builderFactory.newDocumentBuilder(); 272 275 builder.setEntityResolver(new EntityResolver() { 276 @Override 273 277 public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { 274 278 System.out.println("Ignoring DTD " + publicId + ", " + systemId); -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/GeorefImage.java
r23207 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery.wms; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/Grabber.java
r23207 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery.wms; 2 2 3 3 import org.openstreetmap.josm.Main; … … 7 7 import org.openstreetmap.josm.gui.MapView; 8 8 import org.openstreetmap.josm.io.CacheFiles; 9 10 import wmsplugin.GeorefImage.State;9 import org.openstreetmap.josm.plugins.imagery.ImageryPlugin; 10 import org.openstreetmap.josm.plugins.imagery.wms.GeorefImage.State; 11 11 12 12 abstract public class Grabber implements Runnable { … … 31 31 layer.getEastNorth(request.getXIndex(), request.getYIndex()), 32 32 layer.getEastNorth(request.getXIndex() + 1, request.getYIndex() + 1)); 33 if (b.min != null && b.max != null && WMSPlugin.instance.PROP_OVERLAP.get()) {33 if (b.min != null && b.max != null && ImageryPlugin.wmsAdapter.PROP_OVERLAP.get()) { 34 34 double eastSize = b.max.east() - b.min.east(); 35 35 double northSize = b.max.north() - b.min.north(); 36 36 37 double eastCoef = WMSPlugin.instance.PROP_OVERLAP_EAST.get() / 100.0;38 double northCoef = WMSPlugin.instance.PROP_OVERLAP_NORTH.get() / 100.0;37 double eastCoef = ImageryPlugin.wmsAdapter.PROP_OVERLAP_EAST.get() / 100.0; 38 double northCoef = ImageryPlugin.wmsAdapter.PROP_OVERLAP_NORTH.get() / 100.0; 39 39 40 40 this.b = new ProjectionBounds( new EastNorth(b.min.east(), -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/HTMLGrabber.java
r23207 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery.wms; 2 2 3 3 import java.awt.image.BufferedImage; -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/Map_Rectifier_WMSmenuAction.java
r23207 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery.wms; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 24 24 import org.openstreetmap.josm.actions.JosmAction; 25 25 import org.openstreetmap.josm.gui.ExtendedDialog; 26 import org.openstreetmap.josm.plugins.imagery.ImageryInfo; 26 27 import org.openstreetmap.josm.tools.GBC; 27 28 import org.openstreetmap.josm.tools.Shortcut; … … 108 109 } 109 110 111 @Override 110 112 public void actionPerformed(ActionEvent e) { 111 113 JPanel panel = new JPanel(new GridBagLayout()); … … 212 214 */ 213 215 private void addWMSLayer(String title, String url) { 214 Main.main.addLayer(new WMSLayer(new WMSInfo(title, url)));216 Main.main.addLayer(new WMSLayer(new ImageryInfo(title, url))); 215 217 } 216 218 -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSAdapter.java
r24493 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery.wms; 2 2 3 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;4 import static org.openstreetmap.josm.tools.I18n.marktr;5 import static org.openstreetmap.josm.tools.I18n.tr;6 7 import java.awt.event.ActionEvent;8 import java.awt.event.KeyEvent;9 import java.io.File;10 import java.lang.reflect.InvocationTargetException;11 import java.lang.reflect.Method;12 13 import javax.swing.JMenu;14 import javax.swing.JMenuItem;15 import javax.swing.JOptionPane;16 17 import org.openstreetmap.josm.Main;18 3 import org.openstreetmap.josm.actions.ExtensionFileFilter; 19 import org.openstreetmap.josm.actions.JosmAction;20 4 import org.openstreetmap.josm.data.preferences.BooleanProperty; 21 5 import org.openstreetmap.josm.data.preferences.IntegerProperty; 22 import org.openstreetmap.josm.gui.IconToggleButton;23 import org.openstreetmap.josm.gui.MainMenu;24 import org.openstreetmap.josm.gui.MapFrame;25 6 import org.openstreetmap.josm.gui.MapView; 26 import org.openstreetmap.josm.gui.preferences.PreferenceSetting;27 7 import org.openstreetmap.josm.io.CacheFiles; 28 import org.openstreetmap.josm.plugins.Plugin; 29 import org.openstreetmap.josm.plugins.PluginHandler; 30 import org.openstreetmap.josm.plugins.PluginInformation; 31 import org.openstreetmap.josm.plugins.PluginProxy; 8 import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType; 9 import org.openstreetmap.josm.plugins.imagery.wms.io.WMSLayerExporter; 10 import org.openstreetmap.josm.plugins.imagery.wms.io.WMSLayerImporter; 32 11 33 import wmsplugin.io.WMSLayerExporter; 34 import wmsplugin.io.WMSLayerImporter; 35 36 public class WMSPlugin extends Plugin { 12 // WMSPlugin-specific functions 13 public class WMSAdapter { 37 14 CacheFiles cache = new CacheFiles("wmsplugin"); 38 15 … … 42 19 public final IntegerProperty PROP_OVERLAP_NORTH = new IntegerProperty("wmsplugin.url.overlapNorth", 4); 43 20 44 JMenu wmsJMenu;45 static WMSPlugin instance;46 47 public WMSLayerInfo info = new WMSLayerInfo();48 49 // remember state of menu item to restore on changed preferences50 private boolean menuEnabled = false;51 52 /***************************************************************53 * Remote control initialization:54 * If you need remote control in some other plug-in55 * copy this stuff and the call to initRemoteControl below56 * and replace the RequestHandler subclass in initRemoteControl57 ***************************************************************/58 59 /** name of remote control plugin */60 private final String REMOTECONTROL_NAME = "remotecontrol";61 62 /* if necessary change these version numbers to ensure compatibility */63 64 /** RemoteControlPlugin older than this SVN revision is not compatible */65 final int REMOTECONTROL_MIN_REVISION = 22734;66 /** WMSPlugin needs this specific API major version of RemoteControlPlugin */67 final int REMOTECONTROL_NEED_API_MAJOR = 1;68 /** All API minor versions starting from this should be compatible */69 final int REMOTECONTROL_MIN_API_MINOR = 0;70 71 /* these fields will contain state and version of remote control plug-in */72 boolean remoteControlAvailable = false;73 boolean remoteControlCompatible = true;74 boolean remoteControlInitialized = false;75 int remoteControlRevision = 0;76 int remoteControlApiMajor = 0;77 int remoteControlApiMinor = 0;78 int remoteControlProtocolMajor = 0;79 int remoteControlProtocolMinor = 0;80 81 /**82 * Check if remote control plug-in is available and if its version is83 * high enough and register remote control command for this plug-in.84 */85 private void initRemoteControl() {86 for(PluginProxy pp: PluginHandler.pluginList)87 {88 PluginInformation info = pp.getPluginInformation();89 if(REMOTECONTROL_NAME.equals(info.name))90 {91 remoteControlAvailable = true;92 remoteControlRevision = Integer.parseInt(info.version);93 if(REMOTECONTROL_MIN_REVISION > remoteControlRevision)94 {95 remoteControlCompatible = false;96 }97 }98 }99 100 if(remoteControlAvailable && remoteControlCompatible)101 {102 Plugin plugin =103 (Plugin) PluginHandler.getPlugin(REMOTECONTROL_NAME);104 try {105 Method method;106 method = plugin.getClass().getMethod("getVersion");107 Object obj = method.invoke(plugin);108 if((obj != null ) && (obj instanceof int[]))109 {110 int[] versions = (int[]) obj;111 if(versions.length >= 4)112 {113 remoteControlApiMajor = versions[0];114 remoteControlApiMinor = versions[1];115 remoteControlProtocolMajor = versions[2];116 remoteControlProtocolMinor = versions[3];117 }118 }119 120 if((remoteControlApiMajor != REMOTECONTROL_NEED_API_MAJOR) ||121 (remoteControlApiMinor < REMOTECONTROL_MIN_API_MINOR))122 {123 remoteControlCompatible = false;124 }125 if(remoteControlCompatible)126 {127 System.out.println(this.getClass().getSimpleName() + ": initializing remote control");128 method = plugin.getClass().getMethod("addRequestHandler", String.class, Class.class);129 // replace command and class when you copy this to some other plug-in130 // for compatibility with old remotecontrol add leading "/"131 method.invoke(plugin, "/" + WMSRemoteHandler.command, WMSRemoteHandler.class);132 remoteControlInitialized = true;133 }134 } catch (SecurityException e) {135 e.printStackTrace();136 } catch (NoSuchMethodException e) {137 e.printStackTrace();138 } catch (IllegalArgumentException e) {139 e.printStackTrace();140 } catch (IllegalAccessException e) {141 e.printStackTrace();142 } catch (InvocationTargetException e) {143 e.printStackTrace();144 }145 }146 if(remoteControlAvailable)147 {148 String msg = null;149 150 if(remoteControlCompatible)151 {152 if(!remoteControlInitialized)153 {154 msg = tr("Could not initialize remote control.");155 }156 }157 else158 {159 msg = tr("Remote control plugin is not compatible with {0}.",160 this.getClass().getSimpleName());161 }162 163 if(msg != null)164 {165 String additionalMessage = tr("{0} will work but remote control for this plugin is disabled.\n"166 + "You should update the plugins.",167 this.getClass().getSimpleName());168 String versionMessage = tr("Current version of \"{1}\": {2}, internal version {3}. "169 + "Need version {4}, internal version {5}.\n"170 + "If updating the plugins does not help report a bug for \"{0}\".",171 this.getClass().getSimpleName(),172 REMOTECONTROL_NAME,173 ""+remoteControlRevision,174 (remoteControlApiMajor != 0) ?175 ""+remoteControlApiMajor+"."+remoteControlApiMinor :176 tr("unknown"),177 ""+REMOTECONTROL_MIN_REVISION,178 ""+REMOTECONTROL_NEED_API_MAJOR+"."+REMOTECONTROL_MIN_API_MINOR );179 180 String title = tr("{0}: Problem with remote control",181 this.getClass().getSimpleName());182 183 System.out.println(this.getClass().getSimpleName() + ": " +184 msg + "\n" + versionMessage);185 186 JOptionPane.showMessageDialog(187 Main.parent,188 msg + "\n" + additionalMessage,189 title,190 JOptionPane.WARNING_MESSAGE191 );192 }193 }194 195 if(!remoteControlAvailable) {196 System.out.println(this.getClass().getSimpleName() + ": remote control not available");197 }198 }199 200 /***************************************201 * end of remote control initialization202 ***************************************/203 204 21 protected void initExporterAndImporter() { 205 22 ExtensionFileFilter.exporters.add(new WMSLayerExporter()); … … 207 24 } 208 25 209 public WMSPlugin(PluginInformation info) { 210 super(info); 211 instance = this; 212 this.info.load(); 213 refreshMenu(); 26 public WMSAdapter() { 214 27 cache.setExpire(CacheFiles.EXPIRE_MONTHLY, false); 215 28 cache.setMaxSize(70, false); 216 29 initExporterAndImporter(); 217 initRemoteControl();218 }219 220 public void addLayer(WMSInfo info) {221 this.info.add(info);222 this.info.save();223 refreshMenu();224 }225 226 public void refreshMenu() {227 MainMenu menu = Main.main.menu;228 229 if (wmsJMenu == null)230 wmsJMenu = menu.addMenu(marktr("WMS"), KeyEvent.VK_W, menu.defaultMenuPos, ht("/Plugin/WMS"));231 else232 wmsJMenu.removeAll();233 234 // for each configured WMSInfo, add a menu entry.235 for (final WMSInfo u : info.layers) {236 wmsJMenu.add(new JMenuItem(new WMSDownloadAction(u)));237 }238 wmsJMenu.addSeparator();239 wmsJMenu.add(new JMenuItem(new Map_Rectifier_WMSmenuAction()));240 241 wmsJMenu.addSeparator();242 wmsJMenu.add(new JMenuItem(new243 JosmAction(tr("Blank Layer"), "blankmenu", tr("Open a blank WMS layer to load data from a file"), null, false) {244 public void actionPerformed(ActionEvent ev) {245 Main.main.addLayer(new WMSLayer());246 }247 }));248 setEnabledAll(menuEnabled);249 30 } 250 31 251 32 public Grabber getGrabber(MapView mv, WMSLayer layer){ 252 if(layer.info. html)33 if(layer.info.getImageryType() == ImageryType.HTML) 253 34 return new HTMLGrabber(mv, layer, cache); 254 else 35 else if(layer.info.getImageryType() == ImageryType.WMS) 255 36 return new WMSGrabber(mv, layer, cache); 37 else throw new AssertionError(); 256 38 } 257 39 258 private void setEnabledAll(boolean isEnabled) {259 for(int i=0; i < wmsJMenu.getItemCount(); i++) {260 JMenuItem item = wmsJMenu.getItem(i);261 262 if(item != null) item.setEnabled(isEnabled);263 }264 menuEnabled = isEnabled;265 }266 267 @Override268 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {269 if (oldFrame==null && newFrame!=null) {270 setEnabledAll(true);271 Main.map.addMapMode(new IconToggleButton272 (new WMSAdjustAction(Main.map)));273 } else if (oldFrame!=null && newFrame==null ) {274 setEnabledAll(false);275 }276 }277 278 @Override279 public PreferenceSetting getPreferenceSetting() {280 return new WMSPreferenceEditor();281 }282 283 @Override284 public String getPluginDir()285 {286 return new File(Main.pref.getPluginsDirectory(), "wmsplugin").getPath();287 }288 40 } -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSGrabber.java
r23207 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery.wms; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 31 31 import org.openstreetmap.josm.io.OsmTransferException; 32 32 import org.openstreetmap.josm.io.ProgressInputStream; 33 34 import wmsplugin.GeorefImage.State; 33 import org.openstreetmap.josm.plugins.imagery.wms.GeorefImage.State; 35 34 36 35 … … 45 44 WMSGrabber(MapView mv, WMSLayer layer, CacheFiles cache) { 46 45 super(mv, layer, cache); 47 this.baseURL = layer.info. url;46 this.baseURL = layer.info.getURL(); 48 47 /* URL containing placeholders? */ 49 48 urlWithPatterns = isUrlWithPatterns(baseURL); … … 169 168 170 169 HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 171 if(layer.info. cookies != null && !layer.info.cookies.equals(""))172 conn.setRequestProperty("Cookie", layer.info. cookies);170 if(layer.info.getCookies() != null && !layer.info.getCookies().equals("")) 171 conn.setRequestProperty("Cookie", layer.info.getCookies()); 173 172 conn.setRequestProperty("User-Agent", Main.pref.get("wmsplugin.user_agent", Version.getInstance().getAgentString())); 174 173 conn.setConnectTimeout(Main.pref.getInteger("wmsplugin.timeout.connect", 30) * 1000); -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSLayer.java
r24221 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery.wms; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 6 6 import java.awt.Graphics; 7 7 import java.awt.Graphics2D; 8 import java.awt.Toolkit;9 8 import java.awt.event.ActionEvent; 10 9 import java.io.File; … … 23 22 import javax.swing.AbstractAction; 24 23 import javax.swing.Action; 25 import javax.swing.Icon;26 import javax.swing.ImageIcon;27 24 import javax.swing.JCheckBoxMenuItem; 28 25 import javax.swing.JFileChooser; … … 44 41 import org.openstreetmap.josm.gui.layer.Layer; 45 42 import org.openstreetmap.josm.io.CacheFiles; 43 import org.openstreetmap.josm.plugins.imagery.ImageryInfo; 44 import org.openstreetmap.josm.plugins.imagery.ImageryInfo.ImageryType; 45 import org.openstreetmap.josm.plugins.imagery.ImageryLayer; 46 import org.openstreetmap.josm.plugins.imagery.ImageryPlugin; 47 import org.openstreetmap.josm.plugins.imagery.wms.GeorefImage.State; 46 48 import org.openstreetmap.josm.tools.ImageProvider; 47 48 import wmsplugin.GeorefImage.State;49 49 50 50 /** … … 52 52 * fetched this way is tiled and managed to the disc to reduce server load. 53 53 */ 54 public class WMSLayer extends Layer implements PreferenceChangedListener { 55 56 protected static final Icon icon = 57 new ImageIcon(Toolkit.getDefaultToolkit().createImage(WMSPlugin.class.getResource("/images/wms_small.png"))); 54 public class WMSLayer extends ImageryLayer implements PreferenceChangedListener { 58 55 59 56 public static final BooleanProperty PROP_ALPHA_CHANNEL = new BooleanProperty("wmsplugin.alpha_channel", true); 60 WMS Plugin plugin = WMSPlugin.instance;57 WMSAdapter plugin = ImageryPlugin.wmsAdapter; 61 58 62 59 public int messageNum = 5; //limit for messages per layer 63 protected MapView mv;64 60 protected String resolution; 65 61 protected int imageSize = 500; … … 69 65 protected int minZoom = 3; 70 66 71 protected double dx = 0.0;72 protected double dy = 0.0;73 74 67 protected GeorefImage[][] images; 75 68 protected final int serializeFormatVersion = 5; 76 69 protected boolean autoDownloadEnabled = true; 77 70 protected boolean settingsChanged; 78 protected WMSInfo info;71 protected ImageryInfo info; 79 72 80 73 // Image index boundary for current view … … 104 97 105 98 public WMSLayer() { 106 this(new WMSInfo(tr("Blank Layer")));107 } 108 109 public WMSLayer( WMSInfo info) {110 super(info. name);99 this(new ImageryInfo(tr("Blank Layer"))); 100 } 101 102 public WMSLayer(ImageryInfo info) { 103 super(info.getName()); 111 104 setBackgroundLayer(true); /* set global background variable */ 112 105 initializeImages(); 113 this.info = new WMSInfo(info);106 this.info = new ImageryInfo(info); 114 107 mv = Main.map.mapView; 115 if(this.info. pixelPerDegree== 0.0)108 if(this.info.getPixelPerDegree() == 0.0) 116 109 this.info.setPixelPerDegree(getPPD()); 117 110 resolution = mv.getDist100PixelText(); 118 111 119 if(info. url!= null) {120 WMSGrabber.getProjection(info. url, true);112 if(info.getURL() != null) { 113 WMSGrabber.getProjection(info.getURL(), true); 121 114 startGrabberThreads(); 122 if( !info.url.startsWith("html:") && !WMSGrabber.isUrlWithPatterns(info.url)) {123 if (!(info. url.endsWith("&") || info.url.endsWith("?"))) {124 if (!confirmMalformedUrl(info. url)) {125 System.out.println(tr("Warning: WMS layer deactivated because of malformed base url ''{0}''", info. url));115 if(info.getImageryType() == ImageryType.WMS && !WMSGrabber.isUrlWithPatterns(info.getURL())) { 116 if (!(info.getURL().endsWith("&") || info.getURL().endsWith("?"))) { 117 if (!confirmMalformedUrl(info.getURL())) { 118 System.out.println(tr("Warning: WMS layer deactivated because of malformed base url ''{0}''", info.getURL())); 126 119 usesInvalidUrl = true; 127 120 setName(getName() + tr("(deactivated)")); … … 139 132 public void doSetName(String name) { 140 133 setName(name); 141 info. name = name;134 info.setName(name); 142 135 } 143 136 … … 173 166 } 174 167 175 @Override public Icon getIcon() {176 return icon;177 }178 179 168 @Override public String getToolTipText() { 180 169 if(autoDownloadEnabled) … … 197 186 private boolean zoomIsTooBig() { 198 187 //don't download when it's too outzoomed 199 return info. pixelPerDegree/ getPPD() > minZoom;188 return info.getPixelPerDegree() / getPPD() > minZoom; 200 189 } 201 190 202 191 @Override public void paint(Graphics2D g, final MapView mv, Bounds b) { 203 if(info. url== null || (usesInvalidUrl && !isInvalidUrlConfirmed)) return;192 if(info.getURL() == null || (usesInvalidUrl && !isInvalidUrlConfirmed)) return; 204 193 205 194 settingsChanged = false; … … 254 243 } 255 244 256 public double getPPD(){ 257 ProjectionBounds bounds = mv.getProjectionBounds(); 258 return mv.getWidth() / (bounds.max.east() - bounds.min.east()); 259 } 260 245 @Override 261 246 public void displace(double dx, double dy) { 247 super.displace(dx, dy); 262 248 settingsChanged = true; 263 this.dx += dx;264 this.dy += dy;265 }266 267 public double getDx() {268 return dx;269 }270 271 public double getDy() {272 return dy;273 249 } 274 250 275 251 public int getImageXIndex(double coord) { 276 return (int)Math.floor( ((coord - dx) * info. pixelPerDegree) / imageSize);252 return (int)Math.floor( ((coord - dx) * info.getPixelPerDegree()) / imageSize); 277 253 } 278 254 279 255 public int getImageYIndex(double coord) { 280 return (int)Math.floor( ((coord - dy) * info. pixelPerDegree) / imageSize);256 return (int)Math.floor( ((coord - dy) * info.getPixelPerDegree()) / imageSize); 281 257 } 282 258 283 259 public int getImageX(int imageIndex) { 284 return (int)(imageIndex * imageSize * (getPPD() / info. pixelPerDegree) + dx * getPPD());260 return (int)(imageIndex * imageSize * (getPPD() / info.getPixelPerDegree()) + dx * getPPD()); 285 261 } 286 262 287 263 public int getImageY(int imageIndex) { 288 return (int)(imageIndex * imageSize * (getPPD() / info. pixelPerDegree) + dy * getPPD());264 return (int)(imageIndex * imageSize * (getPPD() / info.getPixelPerDegree()) + dy * getPPD()); 289 265 } 290 266 291 267 public int getImageWidth(int xIndex) { 292 int overlap = (int)(plugin.PROP_OVERLAP.get()?plugin.PROP_OVERLAP_EAST.get() * imageSize * getPPD() / info. pixelPerDegree/ 100:0);268 int overlap = (int)(plugin.PROP_OVERLAP.get()?plugin.PROP_OVERLAP_EAST.get() * imageSize * getPPD() / info.getPixelPerDegree() / 100:0); 293 269 return getImageX(xIndex + 1) - getImageX(xIndex) + overlap; 294 270 } 295 271 296 272 public int getImageHeight(int yIndex) { 297 int overlap = (int)(plugin.PROP_OVERLAP.get()?plugin.PROP_OVERLAP_NORTH.get() * imageSize * getPPD() / info. pixelPerDegree/ 100:0);273 int overlap = (int)(plugin.PROP_OVERLAP.get()?plugin.PROP_OVERLAP_NORTH.get() * imageSize * getPPD() / info.getPixelPerDegree() / 100:0); 298 274 return getImageY(yIndex + 1) - getImageY(yIndex) + overlap; 299 275 } … … 325 301 */ 326 302 public EastNorth getEastNorth(int xIndex, int yIndex) { 327 return new EastNorth((xIndex * imageSize) / info. pixelPerDegree, (yIndex * imageSize) / info.pixelPerDegree);303 return new EastNorth((xIndex * imageSize) / info.getPixelPerDegree(), (yIndex * imageSize) / info.getPixelPerDegree()); 328 304 } 329 305 … … 360 336 GeorefImage img = images[modulo(x,dax)][modulo(y,day)]; 361 337 if (!img.paint(g, mv, x, y, leftEdge, bottomEdge)) { 362 WMSRequest request = new WMSRequest(x, y, info. pixelPerDegree, real);338 WMSRequest request = new WMSRequest(x, y, info.getPixelPerDegree(), real); 363 339 addRequest(request); 364 340 } … … 375 351 } 376 352 } 377 }378 379 @Override public Object getInfoComponent() {380 return getToolTipText();381 353 } 382 354 … … 418 390 */ 419 391 private int getRequestPriority(WMSRequest request) { 420 if (request.getPixelPerDegree() != info. pixelPerDegree) {392 if (request.getPixelPerDegree() != info.getPixelPerDegree()) { 421 393 return -1; 422 394 } … … 528 500 super(tr("Download visible tiles")); 529 501 } 502 @Override 530 503 public void actionPerformed(ActionEvent ev) { 531 504 if (zoomIsTooBig()) { … … 546 519 super(tr("Change resolution")); 547 520 } 521 @Override 548 522 public void actionPerformed(ActionEvent ev) { 549 523 initializeImages(); … … 559 533 super(tr("Reload erroneous tiles")); 560 534 } 535 @Override 561 536 public void actionPerformed(ActionEvent ev) { 562 537 // Delete small files, because they're probably blank tiles. … … 568 543 GeorefImage img = images[modulo(x,dax)][modulo(y,day)]; 569 544 if(img.getState() == State.FAILED){ 570 addRequest(new WMSRequest(img.getXIndex(), img.getYIndex(), info. pixelPerDegree, true));545 addRequest(new WMSRequest(img.getXIndex(), img.getYIndex(), info.getPixelPerDegree(), true)); 571 546 mv.repaint(); 572 547 } … … 580 555 super(tr("Alpha channel")); 581 556 } 557 @Override 582 558 public void actionPerformed(ActionEvent ev) { 583 559 JCheckBoxMenuItem checkbox = (JCheckBoxMenuItem) ev.getSource(); … … 594 570 mv.repaint(); 595 571 } 572 @Override 596 573 public Component createMenuComponent() { 597 574 JCheckBoxMenuItem item = new JCheckBoxMenuItem(this); … … 599 576 return item; 600 577 } 578 @Override 601 579 public boolean supportLayers(List<Layer> layers) { 602 580 return layers.size() == 1 && layers.get(0) instanceof WMSLayer; … … 608 586 super(tr("Save WMS layer to file"), ImageProvider.get("save")); 609 587 } 588 @Override 610 589 public void actionPerformed(ActionEvent ev) { 611 590 File f = SaveActionBase.createAndOpenSaveFileChooser( … … 620 599 oos.writeInt(day); 621 600 oos.writeInt(imageSize); 622 oos.writeDouble(info. pixelPerDegree);623 oos.writeObject(info. name);601 oos.writeDouble(info.getPixelPerDegree()); 602 oos.writeObject(info.getName()); 624 603 oos.writeObject(info.getFullURL()); 625 604 oos.writeObject(images); … … 636 615 super(tr("Load WMS layer from file"), ImageProvider.get("load")); 637 616 } 617 @Override 638 618 public void actionPerformed(ActionEvent ev) { 639 619 JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true, … … 673 653 settingsChanged = true; 674 654 mv.repaint(); 675 if(info. url!= null)655 if(info.getURL() != null) 676 656 { 677 657 startGrabberThreads(); … … 698 678 super(tr("Set WMS Bookmark")); 699 679 } 680 @Override 700 681 public void actionPerformed(ActionEvent ev) { 701 plugin.addLayer(new WMSInfo(info));682 ImageryPlugin.instance.addLayer(new ImageryInfo(info)); 702 683 } 703 684 } … … 709 690 } 710 691 692 @Override 711 693 public Component createMenuComponent() { 712 694 JCheckBoxMenuItem item = new JCheckBoxMenuItem(this); … … 715 697 } 716 698 699 @Override 717 700 public boolean supportLayers(List<Layer> layers) { 718 701 return layers.size() == 1 && layers.get(0) instanceof WMSLayer; 719 702 } 720 703 704 @Override 721 705 public void actionPerformed(ActionEvent e) { 722 706 autoDownloadEnabled = !autoDownloadEnabled; … … 782 766 } 783 767 768 @Override 784 769 public void preferenceChanged(PreferenceChangeEvent event) { 785 770 if (event.getKey().equals(plugin.PROP_SIMULTANEOUS_CONNECTIONS.getKey())) { -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSRemoteHandler.java
r23207 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery.wms; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 9 9 10 10 import org.openstreetmap.josm.Main; 11 import org.openstreetmap.josm.plugins.imagery.ImageryInfo; 11 12 import org.openstreetmap.josm.plugins.remotecontrol.PermissionPrefWithDefault; 12 13 import org.openstreetmap.josm.plugins.remotecontrol.RequestHandler; … … 47 48 } 48 49 String cookies = args.get("cookies"); 49 WMSLayer wmsLayer = new WMSLayer(new WMSInfo(title, url, cookies));50 WMSLayer wmsLayer = new WMSLayer(new ImageryInfo(title, url, cookies)); 50 51 Main.main.addLayer(wmsLayer); 51 52 -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/WMSRequest.java
r23207 r24501 1 package wmsplugin;1 package org.openstreetmap.josm.plugins.imagery.wms; 2 2 3 3 import java.awt.image.BufferedImage; 4 4 5 import wmsplugin.GeorefImage.State;5 import org.openstreetmap.josm.plugins.imagery.wms.GeorefImage.State; 6 6 7 7 public class WMSRequest implements Comparable<WMSRequest> { … … 78 78 } 79 79 80 @Override 80 81 public int compareTo(WMSRequest o) { 81 82 return priority - o.priority; -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/io/WMSLayerExporter.java
r23207 r24501 1 package wmsplugin.io;1 package org.openstreetmap.josm.plugins.imagery.wms.io; 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; … … 7 7 8 8 public class WMSLayerExporter extends FileExporter{ 9 9 10 10 public WMSLayerExporter() { 11 11 super(new ExtensionFileFilter("wms", "wms", tr("WMS Files (*.wms)"))); -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/wms/io/WMSLayerImporter.java
r23207 r24501 1 package wmsplugin.io; 1 package org.openstreetmap.josm.plugins.imagery.wms.io; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.actions.ExtensionFileFilter; 4 6 import org.openstreetmap.josm.io.FileImporter; 5 import static org.openstreetmap.josm.tools.I18n.tr;6 7 7 8 public class WMSLayerImporter extends FileImporter{ … … 10 11 super(new ExtensionFileFilter("wms", "wms", tr("WMS Files (*.wms)"))); 11 12 } 12 13 13 14 }
Note:
See TracChangeset
for help on using the changeset viewer.