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

made string s i18nable
changed autocenter visibility

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/livegps/livegps/LiveGpsPlugin.java

    r3076 r3340  
    11package livegps;
    22
     3import static org.openstreetmap.josm.tools.I18n.tr;
    34import java.awt.event.ActionEvent;
    45import java.awt.event.ActionListener;
     
    4041        lgpsmenu.setMnemonic(KeyEvent.VK_G);
    4142        menu.add(lgpsmenu, 2);
    42         lgpscapture = new JCheckBoxMenuItem("Capture GPS Track");
     43        lgpscapture = new JCheckBoxMenuItem(tr("Capture GPS Track"));
    4344        lgpscapture.setSelected(false);
    4445        lgpscapture.setAccelerator(KeyStroke.getKeyStroke("alt R"));
     
    5051        lgpsmenu.add(lgpscapture);
    5152
    52         lgpscenter = new JMenuItem("Center Once", KeyEvent.VK_C);
     53        lgpscenter = new JMenuItem(tr("Center Once"), KeyEvent.VK_C);
    5354        lgpscenter.addActionListener(new ActionListener() {
    5455                public void actionPerformed(ActionEvent ev) {
    55                         lgpslayer.center();
     56                    if(lgpslayer != null) {
     57                        lgpslayer.center();
     58                    }
    5659                }
    5760        });
     
    5962       
    6063       
    61         lgpsautocenter = new JCheckBoxMenuItem("Auto-Center on current position");
    62         lgpsautocenter.setSelected(false);
     64        lgpsautocenter = new JCheckBoxMenuItem(tr("Auto-Center on current position"));
     65        lgpsautocenter.setSelected(true);
     66        lgpsautocenter.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_HOME, 0));
    6367        lgpsautocenter.addActionListener(new ActionListener() {
    6468            public void actionPerformed(ActionEvent ev) {
    65                 lgpslayer.setAutoCenter(lgpsautocenter.isSelected());
    66                 if (lgpsautocenter.isSelected()) lgpslayer.center();
     69                setAutoCenter(lgpsautocenter.isSelected());
    6770            }
    6871        });
    6972        lgpsmenu.add(lgpsautocenter);       
     73    }
     74   
     75    /**
     76     * Set to <code>true</code> if the current position should always be in the center of the map.
     77     * @param autoCenter if <code>true</code> the map is always centered.
     78     */
     79    public void setAutoCenter(boolean autoCenter) {
     80        lgpsautocenter.setSelected(autoCenter); // just in case this method was not called from the menu
     81        if(lgpslayer != null) {
     82            lgpslayer.setAutoCenter(autoCenter);
     83            if (autoCenter) lgpslayer.center();
     84        }
     85    }
     86   
     87    /**
     88     * Returns <code>true</code> if autocenter is selected.
     89     * @return <code>true</code> if autocenter is selected.
     90     */
     91    public boolean isAutoCenter() {
     92        return lgpsautocenter.isSelected();
    7093    }
    7194   
     
    87110                    lgpslayer = new LiveGpsLayer(data);
    88111                    Main.main.addLayer(lgpslayer);
     112                    lgpslayer.setAutoCenter(isAutoCenter());
    89113                }
    90114                // connect layer with acquirer:
Note: See TracChangeset for help on using the changeset viewer.