Ticket #2589: patch-wms-adding-overlap.diff
File patch-wms-adding-overlap.diff, 8.9 KB (added by , 16 years ago) |
---|
-
src/wmsplugin/WMSLayer.java
83 83 executor = Executors.newFixedThreadPool(3); 84 84 } 85 85 86 @Override 86 87 public void destroy() { 87 88 try { 88 89 executor.shutdown(); … … 175 176 for(int x = bminx; x<bmaxx; ++x) 176 177 for(int y = bminy; y<bmaxy; ++y){ 177 178 GeorefImage img = images[modulo(x,dax)][modulo(y,day)]; 179 g.drawRect(x, y, dax, bminy); 178 180 if(!img.paint(g, mv, dx, dy) && !img.downloadingStarted){ 179 181 img.downloadingStarted = true; 180 182 img.image = null; -
src/wmsplugin/Grabber.java
11 11 import java.awt.Color; 12 12 import java.awt.Font; 13 13 import javax.swing.JOptionPane; 14 import org.openstreetmap.josm.data.coor.LatLon; 14 15 15 16 abstract public class Grabber implements Runnable { 16 17 protected Bounds b; … … 22 23 23 24 Grabber(Bounds b, Projection proj, 24 25 double pixelPerDegree, GeorefImage image, MapView mv, WMSLayer layer) { 25 this.b = b; 26 27 28 if (b.min != null && b.max != null && WMSPlugin.doOverlap) { 29 double latCent = (b.min.lat() + b.max.lat()) / 2; 30 double lonCent = (b.min.lon() + b.max.lon()) / 2; 31 32 double latSize = b.max.lat() - b.min.lat(); 33 double lonSize = b.max.lon() - b.min.lon(); 34 35 double latCoef = (100.0 + WMSPlugin.overlapLat) / 100.0 / 2.0; 36 double lonCoef = (100.0 + WMSPlugin.overlapLon) / 100.0 / 2.0; 37 38 this.b = new Bounds( new LatLon(latCent - latCoef * latSize, 39 lonCent - lonCoef * lonSize), 40 new LatLon(latCent + latCoef * latSize, 41 lonCent + lonCoef * lonSize)); 42 } else 43 this.b = b; 44 26 45 this.proj = proj; 27 46 this.pixelPerDegree = pixelPerDegree; 28 47 this.image = image; -
src/wmsplugin/WMSPlugin.java
37 37 static ArrayList<WMSInfo> wmsList = new ArrayList<WMSInfo>(); 38 38 static TreeMap<String,String> wmsListDefault = new TreeMap<String,String>(); 39 39 40 static boolean doOverlap = false; 41 static int overlapLat = 4; 42 static int overlapLon = 14; 43 40 44 // remember state of menu item to restore on changed preferences 41 45 static private boolean menuEnabled = false; 42 46 … … 76 80 Map<String,String> prefs = Main.pref.getAllPrefix("wmsplugin.url."); 77 81 78 82 TreeSet<String> keys = new TreeSet<String>(prefs.keySet()); 83 84 // Here we load the settings for "overlap" checkbox and spinboxes. 85 86 try { 87 doOverlap = Boolean.valueOf(prefs.get("wmsplugin.url.overlap")); 88 } catch (Exception e) {} // If sth fails, we drop to default settings. 89 90 try { 91 overlapLat = Integer.valueOf(prefs.get("wmsplugin.url.overlapLat")); 92 } catch (Exception e) {} // If sth fails, we drop to default settings. 93 94 try { 95 overlapLon = Integer.valueOf(prefs.get("wmsplugin.url.overlapLon")); 96 } catch (Exception e) {} // If sth fails, we drop to default settings. 97 98 // And then the names+urls of WMS servers 79 99 int prefid = 0; 80 100 String name = null; 81 101 String url = null; -
src/wmsplugin/GeorefImage.java
1 1 package wmsplugin; 2 2 3 import java.awt.Color; 3 4 import java.awt.Dimension; 4 5 import java.awt.Graphics; 5 6 import java.awt.Image; … … 79 80 // but the performance improvements when moving are huge 80 81 // Zooming is still slow because the images need to be resized 81 82 if(diffx >= 0 && diffx <= 2 && diffy >= 0 && diffy <= 2 && reImg != null) { 83 /*g.setColor(Color.RED); 84 g.drawRect(minPt.x, minPt.y-height, width, height);*/ 82 85 g.drawImage(reImg, minPt.x, maxPt.y, null); 83 86 return true; 84 87 } … … 119 122 reImg.getGraphics().dispose(); 120 123 121 124 reImgHash.setSize(width, height); 125 /*g.setColor(Color.RED); 126 g.drawRect(minPt.x, minPt.y-height, width, height);*/ 122 127 g.drawImage(reImg, minPt.x, maxPt.y, null); 123 128 } 124 129 } catch(Exception e) { -
src/wmsplugin/WMSPreferenceEditor.java
1 1 package wmsplugin; 2 2 3 import java.awt.BorderLayout; 4 import java.awt.FlowLayout; 5 import javax.swing.JCheckBox; 6 import javax.swing.JSpinner; 7 import javax.swing.SpinnerNumberModel; 8 import org.openstreetmap.josm.Main; 3 9 import static org.openstreetmap.josm.tools.I18n.tr; 4 10 5 11 import java.awt.Dimension; … … 31 37 private DefaultTableModel model; 32 38 private HashMap<Integer, WMSInfo> oldValues = new HashMap<Integer, WMSInfo>(); 33 39 40 JCheckBox overlapCheckBox; 41 JSpinner spinLat; 42 JSpinner spinLon; 43 34 44 public void addGui(final PreferenceDialog gui) { 35 45 JPanel p = gui.createPreferenceTab("wms", tr("WMS Plugin Preferences"), tr("Modify list of WMS servers displayed in the WMS plugin menu")); 36 46 37 47 model = new DefaultTableModel(new String[]{tr("Menu Name"), tr("WMS URL")}, 0); 38 48 final JTable list = new JTable(model); 39 49 JScrollPane scroll = new JScrollPane(list); … … 58 68 modeldef.addRow(new String[]{i.getKey(), i.getValue()}); 59 69 } 60 70 71 JPanel buttonPanel = new JPanel(new FlowLayout()); 72 61 73 JButton add = new JButton(tr("Add")); 62 p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 63 p.add(add, GBC.std().insets(0,5,0,0)); 74 buttonPanel.add(add, GBC.std().insets(0,5,0,0)); 64 75 add.addActionListener(new ActionListener(){ 65 76 public void actionPerformed(ActionEvent e) { 66 77 JPanel p = new JPanel(new GridBagLayout()); … … 78 89 }); 79 90 80 91 JButton delete = new JButton(tr("Delete")); 81 p.add(delete, GBC.std().insets(0,5,0,0));92 buttonPanel.add(delete, GBC.std().insets(0,5,0,0)); 82 93 delete.addActionListener(new ActionListener(){ 83 94 public void actionPerformed(ActionEvent e) { 84 95 if (list.getSelectedRow() == -1) … … 93 104 }); 94 105 95 106 JButton copy = new JButton(tr("Copy Default")); 96 p.add(copy, GBC.std().insets(0,5,0,0));107 buttonPanel.add(copy, GBC.std().insets(0,5,0,0)); 97 108 copy.addActionListener(new ActionListener(){ 98 109 public void actionPerformed(ActionEvent e) { 99 110 Integer line = listdef.getSelectedRow(); … … 106 117 } 107 118 } 108 119 }); 120 121 p.add(buttonPanel); 122 p.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 123 124 overlapCheckBox = new JCheckBox(tr("Overlap tiles"), WMSPlugin.doOverlap ); 125 JLabel labelLat = new JLabel(tr("% of lat:")); 126 JLabel labelLon = new JLabel(tr("% of lon:")); 127 spinLat = new JSpinner(new SpinnerNumberModel(WMSPlugin.overlapLat, 1, 50, 1)); 128 spinLon = new JSpinner(new SpinnerNumberModel(WMSPlugin.overlapLon, 1, 50, 1)); 129 130 JPanel overlapPanel = new JPanel(new FlowLayout()); 131 overlapPanel.add(overlapCheckBox); 132 overlapPanel.add(labelLat); 133 overlapPanel.add(spinLat); 134 overlapPanel.add(labelLon); 135 overlapPanel.add(spinLon); 136 137 p.add(overlapPanel); 109 138 } 110 139 111 140 public boolean ok() { … … 144 173 } 145 174 146 175 if (change) WMSPlugin.refreshMenu(); 176 177 WMSPlugin.doOverlap = overlapCheckBox.getModel().isSelected(); 178 WMSPlugin.overlapLat = (Integer) spinLat.getModel().getValue(); 179 WMSPlugin.overlapLon = (Integer) spinLon.getModel().getValue(); 180 181 Main.pref.put("wmsplugin.url.overlap", String.valueOf(WMSPlugin.doOverlap)); 182 Main.pref.put("wmsplugin.url.overlapLat", String.valueOf(WMSPlugin.overlapLat)); 183 Main.pref.put("wmsplugin.url.overlapLon", String.valueOf(WMSPlugin.overlapLon)); 184 147 185 return false; 148 186 } 149 187