source: josm/trunk/src/org/openstreetmap/josm/actions/ZoomInAction.java@ 2667

Last change on this file since 2667 was 2550, checked in by Gubaer, 14 years ago

fixed #2669: Problem with zoom keys
fixed #3269: Plus/minus buttons don't work
Couldn't get '+' to work on a swiss german keyboard (don't know why) but 'numpad +' and 'numpad -' now zoom in and zoom out too

File size: 1.5 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9
10import javax.swing.JComponent;
11import javax.swing.KeyStroke;
12
13import org.openstreetmap.josm.Main;
14import org.openstreetmap.josm.tools.Shortcut;
15
16public final class ZoomInAction extends JosmAction {
17
18 public ZoomInAction() {
19 super(
20 tr("Zoom In"),
21 "dialogs/zoomin",
22 tr("Zoom In"),
23 Shortcut.registerShortcut("view:zoomin", tr("View: {0}", tr("Zoom In")),KeyEvent.VK_PLUS, Shortcut.GROUP_DIRECT),
24 true
25 );
26 putValue("help", ht("/Action/ZoomIn"));
27 // make numpad + behave like + (action is already registred)
28 Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD,0), tr("Zoom In"));
29 }
30
31 public void actionPerformed(ActionEvent e) {
32 Object name = Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).get(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0));
33 Main.contentPane.getActionMap().put(name, this);
34
35 if (!Main.isDisplayingMapView()) return;
36 Main.map.mapView.zoomToFactor(0.9);
37 }
38
39 @Override
40 protected void updateEnabledState() {
41 setEnabled(
42 Main.isDisplayingMapView()
43 && Main.map.mapView.hasLayers()
44 );
45 }
46
47}
Note: See TracBrowser for help on using the repository browser.