Changeset 23193 in osm for applications/editors/josm/plugins/touchscreenhelper/src
- Timestamp:
- 2010-09-15T19:01:04+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/touchscreenhelper/src/touchscreenhelper
- Files:
-
- 2 edited
-
BrowseAction.java (modified) (1 diff)
-
TouchScreenHelperPlugin.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified applications/editors/josm/plugins/touchscreenhelper/src/touchscreenhelper/BrowseAction.java ¶
r21569 r23193 16 16 MouseMotionListener { 17 17 18 public BrowseAction(MapFrame mapFrame) {19 super(tr("Browse"), "browse", tr("Browse map with left button"),20 mapFrame, Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));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 @Override public void enterMode() {24 super.enterMode();23 @Override public void enterMode() { 24 super.enterMode(); 25 25 26 Main.map.mapView.addMouseListener(this);27 Main.map.mapView.addMouseMotionListener(this);28 }26 Main.map.mapView.addMouseListener(this); 27 Main.map.mapView.addMouseMotionListener(this); 28 } 29 29 30 @Override public void exitMode() {31 super.exitMode();30 @Override public void exitMode() { 31 super.exitMode(); 32 32 33 Main.map.mapView.removeMouseListener(this);34 Main.map.mapView.removeMouseMotionListener(this);35 }33 Main.map.mapView.removeMouseListener(this); 34 Main.map.mapView.removeMouseMotionListener(this); 35 } 36 36 37 public void mouseDragged(MouseEvent e) {38 if ((e.getModifiersEx() & MouseEvent.BUTTON1_DOWN_MASK) !=39 MouseEvent.BUTTON1_DOWN_MASK) {40 endMovement();41 return;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 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 }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 @Override public void mousePressed(MouseEvent e) {54 if (e.getButton() == MouseEvent.BUTTON1)55 startMovement(e);56 }53 @Override public void mousePressed(MouseEvent e) { 54 if (e.getButton() == MouseEvent.BUTTON1) 55 startMovement(e); 56 } 57 57 58 @Override public void mouseReleased(MouseEvent e) {59 if (e.getButton() == MouseEvent.BUTTON1)60 endMovement();61 }58 @Override public void mouseReleased(MouseEvent e) { 59 if (e.getButton() == MouseEvent.BUTTON1) 60 endMovement(); 61 } 62 62 63 private EastNorth mousePosMove;64 private boolean movementInPlace = false;63 private EastNorth mousePosMove; 64 private boolean movementInPlace = false; 65 65 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 }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 private void endMovement() {74 if (!movementInPlace)75 return;76 movementInPlace = false;77 mousePosMove = null;78 }73 private void endMovement() { 74 if (!movementInPlace) 75 return; 76 movementInPlace = false; 77 mousePosMove = null; 78 } 79 79 } -
TabularUnified applications/editors/josm/plugins/touchscreenhelper/src/touchscreenhelper/TouchScreenHelperPlugin.java ¶
r21569 r23193 8 8 9 9 public class TouchScreenHelperPlugin extends Plugin { 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 }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.
