Changeset 4088 in osm for applications/editors/josm/plugins/nearclick/src
- Timestamp:
- 2007-08-12T13:08:46+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/nearclick/src/nearclick/NearClickPlugin.java
r2397 r4088 8 8 import java.awt.event.AWTEventListener; 9 9 import java.awt.event.MouseEvent; 10 import org.openstreetmap.josm.Main; 10 11 11 12 public class NearClickPlugin implements AWTEventListener { … … 14 15 private int mouseDownY = -1; 15 16 private long mouseDownTime = -1; 17 private int radiussquared = 49; 18 private int delay = 250; 16 19 17 20 public NearClickPlugin() { 18 21 Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK); 22 try { 23 int radius = Integer.parseInt(Main.pref.get("nearclick.radius", "7")); 24 radiussquared = radius * radius; 25 delay = Integer.parseInt(Main.pref.get("nearclick.delay", "250")); 26 } catch (NumberFormatException ex) { 27 delay = 250; 28 radiussquared = 7 * 7; 29 } 19 30 } 20 31 … … 24 35 if ( e.getButton() != MouseEvent.BUTTON1 ) 25 36 return; 37 int xdiff = e.getPoint().x - mouseDownX; 38 int ydiff = e.getPoint().y - mouseDownY; 39 26 40 if (e.getID() == MouseEvent.MOUSE_RELEASED) { 27 if ( e.getWhen() - mouseDownTime < 250&&28 e.getPoint().x - mouseDownX < 7 && 29 e.getPoint().y - mouseDownY < 7&&30 e.getPoint().x != mouseDownX && 31 e.getPoint().y != mouseDownY) {41 if ( e.getWhen() - mouseDownTime < delay && 42 ( e.getPoint().x != mouseDownX || 43 e.getPoint().y != mouseDownY) && 44 xdiff * xdiff + ydiff * ydiff < radiussquared 45 ) { 32 46 try { 33 47 Robot r = new Robot(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice());
Note:
See TracChangeset
for help on using the changeset viewer.