Changeset 29244 in osm


Ignore:
Timestamp:
2013-02-10T23:21:45+01:00 (11 years ago)
Author:
the111
Message:

Fix #josm8420 - change cursor when user mouses over attribution links

Location:
applications/viewer/jmapviewer
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/AttributionSupport.java

    r26806 r29244  
    107107    }
    108108
     109    public boolean handleAttributionCursor(Point p) {
     110        if (attrTextBounds != null && attrTextBounds.contains(p)) {
     111            return true;
     112        } else if (attrImageBounds != null && attrImageBounds.contains(p)) {
     113            return true;
     114        } else if (attrToUBounds != null && attrToUBounds.contains(p)) {
     115            return true;
     116        }
     117        return false;
     118    }
     119   
    109120    public boolean handleAttribution(Point p, boolean click) {
    110121        if (source == null || !source.requiresAttribution())
    111122            return false;
    112 
    113         /* TODO: Somehow indicate the link is clickable state to user */
    114123
    115124        if (attrTextBounds != null && attrTextBounds.contains(p)) {
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java

    r29170 r29244  
    44
    55import java.awt.BorderLayout;
     6import java.awt.Cursor;
    67import java.awt.event.ActionEvent;
    78import java.awt.event.ActionListener;
    89import java.awt.event.ItemEvent;
    910import java.awt.event.ItemListener;
     11import java.awt.event.MouseAdapter;
     12import java.awt.event.MouseEvent;
    1013import java.io.IOException;
    1114
     
    162165        // map.setDisplayPositionByLatLon(49.807, 8.6, 11);
    163166        // map.setTileGridVisible(true);
     167       
     168        map.addMouseListener(new MouseAdapter() {
     169            @Override
     170            public void mouseClicked(MouseEvent e) {
     171                if (e.getButton() == MouseEvent.BUTTON1) {
     172                    map.getAttribution().handleAttribution(e.getPoint(), true);
     173                }
     174            }
     175        });
     176       
     177        map.addMouseMotionListener(new MouseAdapter() {
     178            @Override
     179            public void mouseMoved(MouseEvent e) {
     180                boolean cursorHand = map.getAttribution().handleAttributionCursor(e.getPoint());
     181                if (cursorHand) {
     182                    map.setCursor(new Cursor(Cursor.HAND_CURSOR));
     183                } else {
     184                    map.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
     185                }
     186            }
     187        });
    164188    }
    165189
  • applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java

    r29193 r29244  
    10221022    }
    10231023
     1024    public AttributionSupport getAttribution() {
     1025        return attribution;
     1026    }
     1027
    10241028    protected EventListenerList listenerList = new EventListenerList();
    10251029
Note: See TracChangeset for help on using the changeset viewer.