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

Last change on this file since 6501 was 6380, checked in by Don-vip, 10 years ago

update license/copyright information

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
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 org.openstreetmap.josm.Main;
11import org.openstreetmap.josm.tools.Shortcut;
12
13/**
14 * Zoom in map.
15 * @since 770
16 */
17public final class ZoomInAction extends JosmAction {
18
19 /**
20 * Constructs a new {@code ZoomInAction}.
21 */
22 public ZoomInAction() {
23 super(
24 tr("Zoom In"),
25 "dialogs/zoomin",
26 tr("Zoom In"),
27 // Although it might be possible on few custom keyboards, the vast majority of layouts do not have a direct '+' key, see below
28 Shortcut.registerShortcut("view:zoomin", tr("View: {0}", tr("Zoom In")),KeyEvent.VK_PLUS, Shortcut.DIRECT),
29 true
30 );
31 putValue("help", ht("/Action/ZoomIn"));
32 // On standard QWERTY, AZERTY and other common layouts the '+' key is obtained with Shift+EQUALS
33 Main.registerActionShortcut(this,
34 Shortcut.registerShortcut("view:zoominbis", tr("View: {0}", tr("Zoom In")),
35 KeyEvent.VK_EQUALS, Shortcut.SHIFT));
36 // make numpad + behave like +
37 Main.registerActionShortcut(this,
38 Shortcut.registerShortcut("view:zoominkeypad", tr("View: {0}", tr("Zoom In (Keypad)")),
39 KeyEvent.VK_ADD, Shortcut.DIRECT));
40 }
41
42 @Override
43 public void actionPerformed(ActionEvent e) {
44 if (!Main.isDisplayingMapView()) return;
45 Main.map.mapView.zoomToFactor(1/Math.sqrt(2));
46 }
47
48 @Override
49 protected void updateEnabledState() {
50 setEnabled(
51 Main.isDisplayingMapView()
52 && Main.map.mapView.hasLayers()
53 );
54 }
55
56}
Note: See TracBrowser for help on using the repository browser.