Changeset 23193 in osm for applications/editors/josm/plugins/touchscreenhelper
- Timestamp:
- 2010-09-15T19:01:04+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/touchscreenhelper/src/touchscreenhelper
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/touchscreenhelper/src/touchscreenhelper/BrowseAction.java
r21569 r23193 16 16 MouseMotionListener { 17 17 18 19 20 21 18 public BrowseAction(MapFrame mapFrame) { 19 super(tr("Browse"), "browse", tr("Browse map with left button"), 20 mapFrame, Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); 21 } 22 22 23 24 23 @Override public void enterMode() { 24 super.enterMode(); 25 25 26 27 28 26 Main.map.mapView.addMouseListener(this); 27 Main.map.mapView.addMouseMotionListener(this); 28 } 29 29 30 31 30 @Override public void exitMode() { 31 super.exitMode(); 32 32 33 34 35 33 Main.map.mapView.removeMouseListener(this); 34 Main.map.mapView.removeMouseMotionListener(this); 35 } 36 36 37 38 39 40 41 42 37 public void mouseDragged(MouseEvent e) { 38 if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) != 39 MouseEvent.BUTTON1_DOWN_MASK) { 40 endMovement(); 41 return; 42 } 43 43 44 45 46 47 48 49 50 51 44 if (mousePosMove == null) 45 startMovement(e); 46 EastNorth center = Main.map.mapView.getCenter(); 47 EastNorth mouseCenter = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 48 Main.map.mapView.zoomTo(new EastNorth( 49 mousePosMove.east() + center.east() - mouseCenter.east(), 50 mousePosMove.north() + center.north() - mouseCenter.north())); 51 } 52 52 53 54 55 56 53 @Override public void mousePressed(MouseEvent e) { 54 if (e.getButton() == MouseEvent.BUTTON1) 55 startMovement(e); 56 } 57 57 58 59 60 61 58 @Override public void mouseReleased(MouseEvent e) { 59 if (e.getButton() == MouseEvent.BUTTON1) 60 endMovement(); 61 } 62 62 63 64 63 private EastNorth mousePosMove; 64 private boolean movementInPlace = false; 65 65 66 67 68 69 70 71 66 private void startMovement(MouseEvent e) { 67 if (movementInPlace) 68 return; 69 movementInPlace = true; 70 mousePosMove = Main.map.mapView.getEastNorth(e.getX(), e.getY()); 71 } 72 72 73 74 75 76 77 78 73 private void endMovement() { 74 if (!movementInPlace) 75 return; 76 movementInPlace = false; 77 mousePosMove = null; 78 } 79 79 } -
applications/editors/josm/plugins/touchscreenhelper/src/touchscreenhelper/TouchScreenHelperPlugin.java
r21569 r23193 8 8 9 9 public class TouchScreenHelperPlugin extends Plugin { 10 11 12 13 14 15 16 17 18 10 public TouchScreenHelperPlugin(PluginInformation info) { 11 super(info); 12 } 13 @Override public void mapFrameInitialized(MapFrame oldFrame, 14 MapFrame newFrame) { 15 if (oldFrame == null && newFrame != null) { 16 Main.map.addMapMode(new IconToggleButton(new BrowseAction(Main.map))); 17 } 18 } 19 19 }
Note:
See TracChangeset
for help on using the changeset viewer.