Changeset 4506 in josm for trunk/src/org
- Timestamp:
- 2011-10-08T13:04:58+02:00 (13 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r4492 r4506 2 2 package org.openstreetmap.josm.data.imagery; 3 3 4 import java.awt.Image; 4 5 import java.util.Arrays; 5 6 import java.util.ArrayList; … … 18 19 import org.openstreetmap.josm.tools.CheckParameterUtil; 19 20 import org.openstreetmap.josm.tools.ImageProvider; 21 import org.openstreetmap.gui.jmapviewer.Coordinate; 22 import org.openstreetmap.gui.jmapviewer.interfaces.Attributed; 20 23 import org.openstreetmap.gui.jmapviewer.tilesources.OsmTileSource.Mapnik; 21 import org.openstreetmap.gui.jmapviewer.tilesources. TMSTileSource;24 import org.openstreetmap.gui.jmapviewer.tilesources.AbstractTileSource; 22 25 23 26 /** … … 26 29 * @author Frederik Ramm <frederik@remote.org> 27 30 */ 28 public class ImageryInfo implements Comparable<ImageryInfo> {31 public class ImageryInfo implements Comparable<ImageryInfo>, Attributed { 29 32 30 33 public enum ImageryType { … … 325 328 } 326 329 327 public String getAttributionText() { 330 @Override 331 public boolean requiresAttribution() { 332 return attributionText != null || attributionImage != null || termsOfUseText != null || termsOfUseURL != null; 333 } 334 335 @Override 336 public String getAttributionText(int zoom, Coordinate topLeft, Coordinate botRight) { 328 337 return attributionText; 338 } 339 340 @Override 341 public String getAttributionLinkURL() { 342 return attributionLinkURL; 343 } 344 345 @Override 346 public Image getAttributionImage() { 347 ImageIcon i = ImageProvider.getIfAvailable(attributionImage); 348 if (i != null) { 349 return i.getImage(); 350 } 351 return null; 352 } 353 354 @Override 355 public String getAttributionImageURL() { 356 return attributionImageURL; 357 } 358 359 @Override 360 public String getTermsOfUseText() { 361 return termsOfUseText; 362 } 363 364 @Override 365 public String getTermsOfUseURL() { 366 return termsOfUseURL; 329 367 } 330 368 … … 333 371 } 334 372 373 public void setAttributionImageURL(String text) { 374 attributionImageURL = text; 375 } 376 335 377 public void setAttributionImage(String text) { 336 378 attributionImage = text; 337 379 } 338 380 339 public void setAttributionImageURL(String text) {340 attributionImageURL = text;341 }342 343 public String getAttributionLinkURL() {344 return attributionLinkURL;345 }346 347 381 public void setAttributionLinkURL(String text) { 348 382 attributionLinkURL = text; … … 351 385 public void setTermsOfUseText(String text) { 352 386 termsOfUseText = text; 353 }354 355 public String getTermsOfUseURL() {356 return termsOfUseURL;357 387 } 358 388 … … 542 572 * Applies the attribution from this object to a TMSTileSource. 543 573 */ 544 public void setAttribution( TMSTileSource s) {574 public void setAttribution(AbstractTileSource s) { 545 575 if (attributionText != null) { 546 576 if (attributionText.equals("osm")) { -
trunk/src/org/openstreetmap/josm/gui/layer/TMSLayer.java
r4492 r4506 1216 1216 this.paintTileText(ts, t, g, mv, displayZoomLevel, t); 1217 1217 } 1218 1218 1219 1219 attribution.paintAttribution(g, mv.getWidth(), mv.getHeight(), getShiftedCoord(topLeft), getShiftedCoord(botRight), displayZoomLevel, this); 1220 1220 -
trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java
r4492 r4506 7 7 import java.awt.Graphics; 8 8 import java.awt.Graphics2D; 9 import java.awt.Image; 9 10 import java.awt.event.ActionEvent; 11 import java.awt.event.MouseAdapter; 12 import java.awt.event.MouseEvent; 10 13 import java.awt.image.BufferedImage; 14 import java.awt.image.ImageObserver; 11 15 import java.io.File; 12 16 import java.io.FileInputStream; … … 30 34 import javax.swing.JMenuItem; 31 35 import javax.swing.JOptionPane; 32 36 import javax.swing.SwingUtilities; 37 38 import org.openstreetmap.gui.jmapviewer.AttributionSupport; 33 39 import org.openstreetmap.josm.Main; 34 40 import org.openstreetmap.josm.actions.DiskAccessAction; … … 51 57 import org.openstreetmap.josm.data.preferences.IntegerProperty; 52 58 import org.openstreetmap.josm.gui.MapView; 59 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 53 60 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 54 61 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; … … 63 70 * fetched this way is tiled and managed to the disc to reduce server load. 64 71 */ 65 public class WMSLayer extends ImageryLayer implements PreferenceChangedListener {72 public class WMSLayer extends ImageryLayer implements ImageObserver, PreferenceChangedListener { 66 73 public static final BooleanProperty PROP_ALPHA_CHANNEL = new BooleanProperty("imagery.wms.alpha_channel", true); 67 74 public static final IntegerProperty PROP_SIMULTANEOUS_CONNECTIONS = new IntegerProperty("imagery.wms.simultaneousConnections", 3); … … 85 92 protected final MapView mv; 86 93 public WmsCache cache; 87 94 private AttributionSupport attribution = new AttributionSupport(); 88 95 89 96 // Image index boundary for current view … … 142 149 resolution = mv.getDist100PixelText(); 143 150 151 attribution.initialize(this.info); 152 144 153 if(info.getUrl() != null) 145 154 startGrabberThreads(); 146 155 147 156 Main.pref.addPreferenceChangeListener(this); 157 158 SwingUtilities.invokeLater(new Runnable() { 159 @Override 160 public void run() { 161 final MouseAdapter adapter = new MouseAdapter() { 162 @Override 163 public void mouseClicked(MouseEvent e) { 164 if (!isVisible()) return; 165 if (e.getButton() == MouseEvent.BUTTON1) { 166 attribution.handleAttribution(e.getPoint(), true); 167 } 168 } 169 }; 170 Main.map.mapView.addMouseListener(adapter); 171 172 MapView.addLayerChangeListener(new LayerChangeListener() { 173 @Override 174 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 175 // 176 } 177 178 @Override 179 public void layerAdded(Layer newLayer) { 180 // 181 } 182 183 @Override 184 public void layerRemoved(Layer oldLayer) { 185 if (oldLayer == WMSLayer.this) { 186 Main.map.mapView.removeMouseListener(adapter); 187 MapView.removeLayerChangeListener(this); 188 } 189 } 190 }); 191 } 192 }); 148 193 } 149 194 … … 230 275 downloadAndPaintVisible(g, mv, false); 231 276 } 277 278 attribution.paintAttribution(g, mv.getWidth(), mv.getHeight(), null, null, 0, this); 279 232 280 } 233 281 … … 289 337 290 338 /** 291 * 339 * 292 340 * @return When overlapping is enabled, return visible part of tile. Otherwise return original image 293 341 */ … … 886 934 return tr("Supported projections are: {0}", res); 887 935 } 936 937 @Override 938 public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { 939 boolean done = ((infoflags & (ERROR | FRAMEBITS | ALLBITS)) != 0); 940 Main.map.repaint(done ? 0 : 100); 941 return !done; 942 } 943 888 944 } -
trunk/src/org/openstreetmap/josm/tools/ImageProvider.java
r4403 r4506 99 99 public static ImageIcon get(String name) { 100 100 return get("", name); 101 } 102 103 public static ImageIcon getIfAvailable(String name) { 104 return getIfAvailable((Collection<String>) null, null, "", name); 101 105 } 102 106
Note:
See TracChangeset
for help on using the changeset viewer.