Changeset 16308 in osm for applications/editors/josm/plugins/wmsplugin/src
- Timestamp:
- 2009-07-04T20:28:12+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/wmsplugin/src/wmsplugin
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/HTMLGrabber.java
r16302 r16308 10 10 import javax.imageio.ImageIO; 11 11 12 import org.openstreetmap.josm.Main; 12 13 import org.openstreetmap.josm.data.ProjectionBounds; 13 14 import org.openstreetmap.josm.gui.MapView; 14 15 import org.openstreetmap.josm.io.CacheFiles; 15 16 16 17 public class YAHOOGrabber extends WMSGrabber { 18 protected String browserCmd; 19 20 YAHOOGrabber(ProjectionBounds b, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache) { 17 public class HTMLGrabber extends WMSGrabber { 18 HTMLGrabber(ProjectionBounds b, GeorefImage image, MapView mv, WMSLayer layer, CacheFiles cache) { 21 19 super(b, image, mv, layer, cache); 22 this.baseURL = "file:///" + WMSPlugin.getPrefsPath() + "ymap.html?"; 23 this.browserCmd = layer.baseURL.replaceFirst("yahoo://", ""); 20 this.baseURL = layer.baseURL.replaceFirst("html:", ""); 24 21 } 25 22 … … 27 24 protected BufferedImage grab(URL url) throws IOException { 28 25 String urlstring = url.toExternalForm(); 29 // work around a problem in URL removing 2 slashes30 if(!urlstring.startsWith("file:///"))31 urlstring = urlstring.replaceFirst("file:", "file://");32 26 33 27 BufferedImage cached = cache.getImg(urlstring); … … 35 29 36 30 ArrayList<String> cmdParams = new ArrayList<String>(); 37 StringTokenizer st = new StringTokenizer(MessageFormat.format(browserCmd, urlstring)); 31 StringTokenizer st = new StringTokenizer(MessageFormat.format( 32 Main.pref.get("wmsplugin.browser", "webkit-image {0}"), urlstring)); 38 33 while( st.hasMoreTokens() ) 39 34 cmdParams.add(st.nextToken()); 40 35 41 System.out.println("WMS::Browsing YAHOO: " + cmdParams);42 36 ProcessBuilder builder = new ProcessBuilder( cmdParams); 43 37 -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSDownloadAction.java
r15858 r16308 19 19 20 20 public void actionPerformed(ActionEvent e) { 21 System.out.println(info.url);21 //System.out.println(info.url); 22 22 23 23 WMSLayer wmsLayer = new WMSLayer(info.name, info.url, info.cookies); -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSGrabber.java
r16290 r16308 43 43 this.baseURL = layer.baseURL; 44 44 /* URL containing placeholders? */ 45 urlWithPatterns = baseURL != null && baseURL.contains("{ 1}");45 urlWithPatterns = baseURL != null && baseURL.contains("{") && baseURL.contains("}"); 46 46 } 47 47 … … 62 62 image.max = b.max; 63 63 64 System.out.println(url + " " + b + " " + image.min + " " + image.max);65 64 if(image.isVisible(mv)) { //don't download, if the image isn't visible already 66 65 image.image = grab(url); … … 81 80 if(Main.proj instanceof Mercator) // don't use mercator code directly 82 81 { 83 LatLon sw = Main.proj.eastNorth2latlon(new EastNorth( s, w));84 LatLon ne = Main.proj.eastNorth2latlon(new EastNorth( n, e));82 LatLon sw = Main.proj.eastNorth2latlon(new EastNorth(w, s)); 83 LatLon ne = Main.proj.eastNorth2latlon(new EastNorth(e, n)); 85 84 proj = "EPSG:4326"; 86 85 s = sw.lat(); … … 89 88 e = ne.lon(); 90 89 } 91 /* else if(!(Main.proj instanceof Epsg4326)) 92 { 93 EastNorth sw = Main.proj.latlon2eastNorth(new LatLon(s, w)); 94 EastNorth ne = Main.proj.latlon2eastNorth(new LatLon(n, e)); 95 s = sw.north(); 96 w = sw.east(); 97 n = ne.north(); 98 e = ne.east(); 99 } 100 */ 90 101 91 String str = baseURL; 102 92 String bbox = latLonFormat.format(w) + "," … … 106 96 107 97 if (urlWithPatterns) { 108 str = MessageFormat.format(str, proj, bbox, wi, ht); 98 str = str.replaceAll("{proj}", proj) 99 .replaceAll("{bbox}", bbox) 100 .replaceAll("{width}", String.valueOf(wi)) 101 .replaceAll("{height}", String.valueOf(ht)); 109 102 } else { 110 if(!str.endsWith("?")) 103 if(!str.contains("?")) 104 str += "?"; 105 else if(!str.endsWith("?")) 111 106 str += "&"; 112 107 str += "bbox=" -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java
r16290 r16308 48 48 49 49 public WMSPlugin() { 50 try51 {52 copy("/resources/ymap.html", "ymap.html");53 }54 catch(IOException e) {55 e.printStackTrace();56 }57 50 refreshMenu(); 58 51 cache.setExpire(cache.EXPIRE_MONTHLY, false); … … 190 183 191 184 public static Grabber getGrabber(ProjectionBounds bounds, GeorefImage img, MapView mv, WMSLayer layer){ 192 if(layer.baseURL.startsWith(" yahoo://"))193 return new YAHOOGrabber(bounds, img, mv, layer, cache);185 if(layer.baseURL.startsWith("html:")) 186 return new HTMLGrabber(bounds, img, mv, layer, cache); 194 187 else 195 188 return new WMSGrabber(bounds, img, mv, layer, cache); -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java
r16290 r16308 17 17 import javax.swing.Box; 18 18 import javax.swing.JButton; 19 import javax.swing.JComboBox; 19 20 import javax.swing.JLabel; 20 21 import javax.swing.JOptionPane; … … 32 33 private Map<String,String> orig; 33 34 private DefaultTableModel model; 35 private JComboBox browser; 34 36 private HashMap<Integer, WMSInfo> oldValues = new HashMap<Integer, WMSInfo>(); 35 37 … … 69 71 JPanel p = new JPanel(new GridBagLayout()); 70 72 p.add(new JLabel(tr("Menu Name")), GBC.std().insets(0,0,5,0)); 71 JTextField key = new JTextField( 10);72 JTextField value = new JTextField( 10);73 JTextField key = new JTextField(40); 74 JTextField value = new JTextField(40); 73 75 p.add(key, GBC.eop().insets(5,0,0,0).fill(GBC.HORIZONTAL)); 74 76 p.add(new JLabel(tr("WMS URL")), GBC.std().insets(0,0,5,0)); … … 113 115 p.add(buttonPanel); 114 116 p.add(Box.createHorizontalGlue(), GBC.eol().fill(GBC.HORIZONTAL)); 117 browser = new JComboBox(new String[]{ 118 "webkit-image {0}", 119 "gnome-web-photo --mode=photo --format=png {0} /dev/stdout", 120 "gnome-web-photo-fixed {0}", 121 "webkit-image-gtk {0}"}); 122 browser.setEditable(true); 123 browser.setSelectedItem(Main.pref.get("wmsplugin.browser", "webkit-image {0}")); 124 p.add(new JLabel(tr("Downloader:")), GBC.eol().fill(GBC.HORIZONTAL)); 125 p.add(browser, GBC.eol().fill(GBC.HORIZONTAL)); 115 126 } 116 127 … … 152 163 if (change) WMSPlugin.refreshMenu(); 153 164 165 Main.pref.put("wmsplugin.browser", browser.getEditor().getItem().toString()); 154 166 return false; 155 167 }
Note:
See TracChangeset
for help on using the changeset viewer.