Changeset 3347 in osm for applications/editors


Ignore:
Timestamp:
2007-06-25T19:16:56+02:00 (17 years ago)
Author:
christofd
Message:

added hotkeys for zoomin, zoomout and autocenter to component

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/surveyor/src/at/dallermassl/josm/plugin/surveyor/SurveyorShowAction.java

    r2946 r3347  
    77
    88import java.awt.event.ActionEvent;
     9import java.awt.event.KeyEvent;
    910import java.io.BufferedReader;
    1011import java.io.FileInputStream;
     
    1718
    1819import javax.swing.AbstractAction;
     20import javax.swing.ActionMap;
     21import javax.swing.InputMap;
    1922import javax.swing.JFrame;
    2023import javax.swing.JOptionPane;
     24import javax.swing.KeyStroke;
    2125
    2226import livegps.LiveGpsPlugin;
     
    3135 */
    3236public class SurveyorShowAction extends AbstractAction {
     37    private static final long serialVersionUID = 2184570223633094734L;
    3338    private static final String DEFAULT_SOURCE = "resource://surveyor.xml";
    3439    private JFrame surveyorFrame;
     
    6772            // add component as gps event listener:
    6873            gpsPlugin.addPropertyChangeListener(comp);
     74           
     75            // add some hotkeys to the component:
     76            ActionMap actionMap = comp.getActionMap();
     77            InputMap inputMap = comp.getInputMap();
     78            // zoomout:
     79            actionMap.put("zoomout", new AbstractAction() {
     80                public void actionPerformed(ActionEvent e) {
     81                    if(Main.map != null && Main.map.mapView != null) {
     82                        Main.map.mapView.zoomTo(Main.map.mapView.getCenter(), Main.map.mapView.getScale()*2);
     83                    }
     84                }
     85            });
     86            inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_UP, 0), "zoomout");
     87            // zoomin:
     88            actionMap.put("zoomin", new AbstractAction() {
     89                public void actionPerformed(ActionEvent e) {
     90                    if(Main.map != null && Main.map.mapView != null) {
     91                        Main.map.mapView.zoomTo(Main.map.mapView.getCenter(), Main.map.mapView.getScale()/2);
     92                    }
     93                }
     94            });
     95            inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PAGE_DOWN, 0), "zoomin");
     96            // autocenter:
     97            actionMap.put("autocenter", new AbstractAction() {
     98                public void actionPerformed(ActionEvent e) {
     99                    // toggle autocenter
     100                    gpsPlugin.setAutoCenter(!gpsPlugin.isAutoCenter());
     101                }
     102            });
     103            inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0), "autocenter");
     104           
    69105            surveyorFrame.add(comp);
    70106            surveyorFrame.pack();
Note: See TracChangeset for help on using the changeset viewer.