Changeset 24487 in osm for applications


Ignore:
Timestamp:
2010-12-01T05:23:56+01:00 (14 years ago)
Author:
yellowbkpk
Message:

Clicking the attribution image will open a browser window to the URL.

Location:
applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java

    r24486 r24487  
    1515import java.awt.event.MouseEvent;
    1616import java.awt.image.ImageObserver;
     17import java.io.IOException;
     18import java.net.URI;
     19import java.net.URISyntaxException;
    1720import java.util.ArrayList;
    1821import java.util.HashSet;
     
    106109    Tile showMetadataTile;
    107110    private Image attrImage;
     111    private Rectangle attrImageBounds;
    108112    private Font attrFont = Font.decode("Arial-10");
    109113
     
    256260                    @Override
    257261                    public void mouseClicked(MouseEvent e) {
    258                         if (e.getButton() != MouseEvent.BUTTON3)
    259                             return;
    260                         clickedTile = getTileForPixelpos(e.getX(), e.getY());
    261                         tileOptionMenu.show(e.getComponent(), e.getX(), e.getY());
     262                        if (e.getButton() == MouseEvent.BUTTON3) {
     263                            clickedTile = getTileForPixelpos(e.getX(), e.getY());
     264                            tileOptionMenu.show(e.getComponent(), e.getX(), e.getY());
     265                        } else if (e.getButton() == MouseEvent.BUTTON1) {
     266                            if(attrImageBounds.contains(e.getPoint()) && tileSource.requiresAttribution()) {
     267                                try {
     268                                    java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
     269                                    desktop.browse(new URI(tileSource.getAttributionLinkURL()));
     270                                } catch (IOException e1) {
     271                                    e1.printStackTrace();
     272                                } catch (URISyntaxException e1) {
     273                                    e1.printStackTrace();
     274                                }
     275                            }
     276                        }
    262277                    }
    263278                });
     
    933948            // Draw attribution logo
    934949            if(attrImage != null) {
    935                 g.drawImage(attrImage, 5, mv.getHeight() - attrImage.getHeight(this) - 5, this);
     950                int x = 5;
     951                int y = mv.getHeight() - attrImage.getHeight(this) - 5;
     952                attrImageBounds = new Rectangle(x, y, attrImage.getWidth(this), attrImage.getHeight(this));
     953                g.drawImage(attrImage, x, y, this);
    936954            }
    937955        }
  • applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapPreferences.java

    r24486 r24487  
    406406        }
    407407       
     408        public String getAttributionLinkURL() {
     409            return "http://bing.com/maps";
     410        }
     411       
    408412        public String getAttributionText(int zoom, LatLon topLeft, LatLon botRight) {
    409413            Bounds windowBounds = new Bounds(topLeft, botRight);
     
    418422                        a.append(attr.attribution);
    419423                        a.append(" ");
    420                     } else {
    421424                    }
    422425                }
Note: See TracChangeset for help on using the changeset viewer.