Changeset 22794 in osm for applications/editors/josm/plugins/wmsplugin
- Timestamp:
- 2010-08-26T19:47:34+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/wmsplugin/src/wmsplugin
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/GeorefImage.java
r22779 r22794 99 99 100 100 private BufferedImage createImage() { 101 int left = layer.getImageX(xIndex); 102 int bottom = layer.getImageY(yIndex); 103 int width = layer.getImageX(xIndex + 1) - left; 104 int height = layer.getImageY(yIndex + 1) - bottom; 105 106 return new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); 101 return new BufferedImage(layer.getImageWidth(xIndex), layer.getImageHeight(yIndex), BufferedImage.TYPE_INT_RGB); 107 102 } 108 103 … … 117 112 int left = layer.getImageX(xIndex); 118 113 int bottom = layer.getImageY(yIndex); 119 int width = layer.getImage X(xIndex + 1) - left;120 int height = layer.getImage Y(yIndex + 1) - bottom;114 int width = layer.getImageWidth(xIndex); 115 int height = layer.getImageHeight(yIndex); 121 116 122 117 int x = left - leftEdge; -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/Grabber.java
r22720 r22794 18 18 protected Projection proj; 19 19 protected double pixelPerDegree; 20 protected WMSRequest request; 20 21 protected volatile boolean canceled; 21 22 … … 30 31 layer.getEastNorth(request.getXIndex(), request.getYIndex()), 31 32 layer.getEastNorth(request.getXIndex() + 1, request.getYIndex() + 1)); 32 if (b.min != null && b.max != null && WMSPlugin. doOverlap) {33 if (b.min != null && b.max != null && WMSPlugin.PROP_OVERLAP.get()) { 33 34 double eastSize = b.max.east() - b.min.east(); 34 35 double northSize = b.max.north() - b.min.north(); 35 36 36 double eastCoef = WMSPlugin. overlapEast/ 100.0;37 double northCoef = WMSPlugin. overlapNorth/ 100.0;37 double eastCoef = WMSPlugin.PROP_OVERLAP_EAST.get() / 100.0; 38 double northCoef = WMSPlugin.PROP_OVERLAP_NORTH.get() / 100.0; 38 39 39 40 this.b = new ProjectionBounds( new EastNorth(b.min.east(), … … 45 46 this.proj = Main.proj; 46 47 this.pixelPerDegree = request.getPixelPerDegree(); 48 this.request = request; 47 49 } 48 50 … … 50 52 51 53 int width(){ 52 return (int) ((b.max.north() - b.min.north()) * pixelPerDegree);54 return layer.getImageWidth(request.getXIndex()); 53 55 } 54 56 int height(){ 55 return (int) ((b.max.east() - b.min.east()) * pixelPerDegree);57 return layer.getImageHeight(request.getYIndex()); 56 58 } 57 59 -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSLayer.java
r22779 r22794 53 53 */ 54 54 public class WMSLayer extends Layer implements PreferenceChangedListener { 55 55 56 protected static final Icon icon = 56 57 new ImageIcon(Toolkit.getDefaultToolkit().createImage(WMSPlugin.class.getResource("/images/wms_small.png"))); … … 67 68 protected int minZoom = 3; 68 69 69 protected boolean deltaChanged;70 70 protected double dx = 0.0; 71 71 protected double dy = 0.0; … … 77 77 protected final int serializeFormatVersion = 5; 78 78 protected boolean autoDownloadEnabled = true; 79 protected boolean settingsChanged; 79 80 80 81 // Image index boundary for current view … … 86 87 private volatile int bottomEdge; 87 88 88 89 // Request queue 89 90 private final List<WMSRequest> requestQueue = new ArrayList<WMSRequest>(); 90 91 private final List<WMSRequest> finishedRequests = new ArrayList<WMSRequest>(); … … 202 203 203 204 @Override public void paint(Graphics2D g, final MapView mv, Bounds b) { 204 deltaChanged = false;205 205 if(baseURL == null) return; 206 206 if (usesInvalidUrl && !isInvalidUrlConfirmed) return; 207 208 settingsChanged = false; 207 209 208 210 ProjectionBounds bounds = mv.getProjectionBounds(); … … 261 263 262 264 public void displace(double dx, double dy) { 263 deltaChanged = true;265 settingsChanged = true; 264 266 this.dx += dx; 265 267 this.dy += dy; … … 280 282 public int getImageY(int imageIndex) { 281 283 return (int)(imageIndex * imageSize * (getPPD() / pixelPerDegree) + dy * getPPD()); 284 } 285 286 public int getImageWidth(int xIndex) { 287 int overlap = (int)(WMSPlugin.PROP_OVERLAP.get()?WMSPlugin.PROP_OVERLAP_EAST.get() * imageSize * getPPD() / pixelPerDegree / 100:0); 288 return getImageX(xIndex + 1) - getImageX(xIndex) + overlap; 289 } 290 291 public int getImageHeight(int yIndex) { 292 int overlap = (int)(WMSPlugin.PROP_OVERLAP.get()?WMSPlugin.PROP_OVERLAP_NORTH.get() * imageSize * getPPD() / pixelPerDegree / 100:0); 293 return getImageY(yIndex + 1) - getImageY(yIndex) + overlap; 282 294 } 283 295 … … 514 526 resolution = mv.getDist100PixelText(); 515 527 pixelPerDegree = getPPD(); 528 settingsChanged = true; 516 529 mv.repaint(); 517 530 } … … 627 640 ois.close(); 628 641 fis.close(); 642 settingsChanged = true; 629 643 mv.repaint(); 630 644 } … … 743 757 requestQueueLock.lock(); 744 758 try { 745 return !finishedRequests.isEmpty() || deltaChanged;759 return !finishedRequests.isEmpty() || settingsChanged; 746 760 } finally { 747 761 requestQueueLock.unlock(); … … 753 767 cancelGrabberThreads(true); 754 768 startGrabberThreads(); 755 } 756 } 769 } else if ( 770 event.getKey().equals(WMSPlugin.PROP_OVERLAP.getKey()) 771 || event.getKey().equals(WMSPlugin.PROP_OVERLAP_EAST.getKey()) 772 || event.getKey().equals(WMSPlugin.PROP_OVERLAP_NORTH.getKey())) { 773 for (int i=0; i<images.length; i++) { 774 for (int k=0; k<images[i].length; k++) { 775 images[i][k] = new GeorefImage(this); 776 } 777 } 778 779 settingsChanged = true; 780 } 781 } 782 757 783 } -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPlugin.java
r22735 r22794 30 30 import org.openstreetmap.josm.actions.ExtensionFileFilter; 31 31 import org.openstreetmap.josm.actions.JosmAction; 32 import org.openstreetmap.josm.data.preferences.BooleanProperty; 32 33 import org.openstreetmap.josm.data.preferences.IntegerProperty; 33 34 import org.openstreetmap.josm.gui.IconToggleButton; … … 50 51 51 52 public static final IntegerProperty PROP_SIMULTANEOUS_CONNECTIONS = new IntegerProperty("wmsplugin.simultaneousConnections", 3); 53 public static final BooleanProperty PROP_OVERLAP = new BooleanProperty("wmsplugin.url.overlap", false); 54 public static final IntegerProperty PROP_OVERLAP_EAST = new IntegerProperty("wmsplugin.url.overlapEast", 14); 55 public static final IntegerProperty PROP_OVERLAP_NORTH = new IntegerProperty("wmsplugin.url.overlapNorth", 4); 52 56 53 57 WMSLayer wmsLayer; … … 57 61 static TreeMap<String,String> wmsListDefault = new TreeMap<String,String>(); 58 62 59 static boolean doOverlap = false;60 static int overlapEast = 14;61 static int overlapNorth = 4;62 63 // remember state of menu item to restore on changed preferences 63 64 static private boolean menuEnabled = false; … … 255 256 TreeSet<String> keys = new TreeSet<String>(prefs.keySet()); 256 257 257 // Here we load the settings for "overlap" checkbox and spinboxes.258 259 try {260 doOverlap = Boolean.valueOf(prefs.get("wmsplugin.url.overlap"));261 } catch (Exception e) {} // If sth fails, we drop to default settings.262 263 try {264 overlapEast = Integer.valueOf(prefs.get("wmsplugin.url.overlapEast"));265 } catch (Exception e) {} // If sth fails, we drop to default settings.266 267 try {268 overlapNorth = Integer.valueOf(prefs.get("wmsplugin.url.overlapNorth"));269 } catch (Exception e) {} // If sth fails, we drop to default settings.270 271 258 // And then the names+urls of WMS servers 272 259 int prefid = 0; -
applications/editors/josm/plugins/wmsplugin/src/wmsplugin/WMSPreferenceEditor.java
r22712 r22794 169 169 p.add(Box.createHorizontalGlue(), GBC.eol().fill(GridBagConstraints.HORIZONTAL)); 170 170 171 overlapCheckBox = new JCheckBox(tr("Overlap tiles"), WMSPlugin. doOverlap);171 overlapCheckBox = new JCheckBox(tr("Overlap tiles"), WMSPlugin.PROP_OVERLAP.get() ); 172 172 JLabel labelEast = new JLabel(tr("% of east:")); 173 173 JLabel labelNorth = new JLabel(tr("% of north:")); 174 spinEast = new JSpinner(new SpinnerNumberModel(WMSPlugin. overlapEast, 1, 50, 1));175 spinNorth = new JSpinner(new SpinnerNumberModel(WMSPlugin. overlapNorth, 1, 50, 1));174 spinEast = new JSpinner(new SpinnerNumberModel(WMSPlugin.PROP_OVERLAP_EAST.get(), 1, 50, 1)); 175 spinNorth = new JSpinner(new SpinnerNumberModel(WMSPlugin.PROP_OVERLAP_NORTH.get(), 1, 50, 1)); 176 176 177 177 JPanel overlapPanel = new JPanel(new FlowLayout()); … … 240 240 if (change) WMSPlugin.refreshMenu(); 241 241 242 WMSPlugin. doOverlap = overlapCheckBox.getModel().isSelected();243 WMSPlugin. overlapEast = (Integer) spinEast.getModel().getValue();244 WMSPlugin. overlapNorth = (Integer) spinNorth.getModel().getValue();242 WMSPlugin.PROP_OVERLAP.put(overlapCheckBox.getModel().isSelected()); 243 WMSPlugin.PROP_OVERLAP_EAST.put((Integer) spinEast.getModel().getValue()); 244 WMSPlugin.PROP_OVERLAP_NORTH.put((Integer) spinNorth.getModel().getValue()); 245 245 WMSPlugin.PROP_SIMULTANEOUS_CONNECTIONS.put((Integer) spinSimConn.getModel().getValue()); 246 246 allowRemoteControl = remoteCheckBox.getModel().isSelected(); 247 248 Main.pref.put("wmsplugin.url.overlap", String.valueOf(WMSPlugin.doOverlap));249 Main.pref.put("wmsplugin.url.overlapEast", String.valueOf(WMSPlugin.overlapEast));250 Main.pref.put("wmsplugin.url.overlapNorth", String.valueOf(WMSPlugin.overlapNorth));251 247 252 248 Main.pref.put("wmsplugin.browser", browser.getEditor().getItem().toString());
Note:
See TracChangeset
for help on using the changeset viewer.