Changeset 10704 in osm for applications/editors/josm/plugins/wmsplugin/src
- Timestamp:
- 2008-09-15T13:40:32+02:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/wmsplugin/src/wmsplugin
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Map_Rectifier_WMSmenuAction.java
r8721 r10704 28 28 "&srs=EPSG:4326&Service=WMS&Version=1.1.0&Request=GetMap&format=image/png"; 29 29 30 DownloadWMSTask.download(WMSDownloadAction.getLayer(31 new WMSInfo(tr("rectifier id={0}",newid), newURL, -1)));30 WMSLayer wmsLayer = new WMSLayer(tr("rectifier id={0}",newid), newURL); 31 Main.main.addLayer(wmsLayer); 32 32 } 33 33 } -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSDownloadAction.java
r10382 r10704 23 23 System.out.println(info.url); 24 24 25 WMSLayer wmsLayer = getLayer(info); 26 MapView mv = Main.map.mapView; 27 28 Bounds b = new Bounds( 29 mv.getLatLon(0, mv.getHeight()), 30 mv.getLatLon(mv.getWidth(), 0)); 31 double pixelPerDegree = mv.getWidth() / (b.max.lon() - b.min.lon()); 32 33 wmsLayer.grab(b, pixelPerDegree); 25 WMSLayer wmsLayer = new WMSLayer(info.name, info.url); 26 Main.main.addLayer(wmsLayer); 34 27 } 35 28 36 29 public static WMSLayer getLayer(WMSInfo info) { 37 // simply check if we already have a layer created. if not, create; if yes, reuse.38 for (Layer l : Main.main.map.mapView.getAllLayers()) {39 if (l instanceof WMSLayer && l.name.equals(info.name)) {40 return (WMSLayer) l;41 }42 }43 44 30 // FIXME: move this to WMSPlugin/WMSInfo/preferences. 45 31 WMSLayer wmsLayer = new WMSLayer(info.name, info.url); … … 48 34 } 49 35 }; 50 -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java
r10684 r10704 49 49 50 50 public int messageNum = 5; //limit for messages per layer 51 protected MapView mv; 52 protected String resolution; 51 53 protected boolean stopAfterPaint = false; 52 54 protected int ImageSize = 500; … … 56 58 protected double pixelPerDegree; 57 59 protected GeorefImage[][] images = new GeorefImage[dax][day]; 58 60 JCheckBoxMenuItem startstop = new JCheckBoxMenuItem(tr("Automatic downloading"), true); 59 61 60 62 protected String baseURL; … … 66 68 this(tr("Blank Layer"), null); 67 69 initializeImages(); 70 mv = Main.map.mapView; 68 71 } 69 72 … … 72 75 initializeImages(); 73 76 this.baseURL = baseURL; 77 mv = Main.map.mapView; 78 getPPD(); 74 79 75 80 executor = Executors.newFixedThreadPool(3); 81 } 82 83 public void getPPD(){ 84 pixelPerDegree = mv.getWidth() / (bounds().max.lon() - bounds().min.lon()); 76 85 } 77 86 … … 83 92 } 84 93 85 public void grab(Bounds b, double _pixelPerDegree) {86 if (baseURL == null) return;87 //set resolution88 if(startstop.isSelected() || Math.round(pixelPerDegree/10000) != Math.round(_pixelPerDegree/10000))89 initializeImages();90 pixelPerDegree = _pixelPerDegree;91 if(!startstop.isSelected()) stopAfterPaint = true;92 startstop.setSelected(true);93 }94 95 94 @Override public Icon getIcon() { 96 95 return icon; 97 96 } 98 97 98 public String scale(){ 99 LatLon ll1 = mv.getLatLon(0,0); 100 LatLon ll2 = mv.getLatLon(100,0); 101 double dist = ll1.greatCircleDistance(ll2); 102 return dist > 1000 ? (Math.round(dist/100)/10.0)+" km" : Math.round(dist*10)/10+" m"; 103 } 104 99 105 @Override public String getToolTipText() { 100 106 if(startstop.isSelected()) 101 return tr("WMS layer ({0}), automaticaly downloading in zoom {1}", name, Math.round(pixelPerDegree/10000));107 return tr("WMS layer ({0}), automaticaly downloading in zoom {1}", name, resolution); 102 108 else 103 return tr("WMS layer ({0}), downloading in zoom {1}", name, Math.round(pixelPerDegree/10000));109 return tr("WMS layer ({0}), downloading in zoom {1}", name, resolution); 104 110 } 105 111 … … 125 131 126 132 @Override public void paint(Graphics g, final MapView mv) { 133 if(baseURL == null) return; 127 134 Bounds b = new Bounds( 128 135 mv.getLatLon(0, mv.getHeight()), … … 152 159 } 153 160 } 154 if(stopAfterPaint){155 startstop.setSelected(false);156 stopAfterPaint = false;157 }158 161 } 159 162 … … 180 183 new JSeparator(), 181 184 startstop, 185 new JMenuItem(new changeResolutionAction()), 182 186 new JSeparator(), 183 new JMenuItem(new LayerListPopup.InfoAction(this)) };184 187 new JMenuItem(new LayerListPopup.InfoAction(this)) 188 }; 185 189 } 186 190 … … 196 200 } 197 201 202 public class changeResolutionAction extends AbstractAction { 203 public changeResolutionAction() { 204 super(tr("Change resolution")); 205 } 206 public void actionPerformed(ActionEvent ev) { 207 initializeImages(); 208 resolution = scale(); 209 getPPD(); 210 mv.repaint(); 211 } 212 } 198 213 199 214 public class SaveWmsAction extends AbstractAction {
Note:
See TracChangeset
for help on using the changeset viewer.