1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
|
---|
5 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
6 |
|
---|
7 | import java.awt.event.ActionEvent;
|
---|
8 | import java.awt.event.KeyEvent;
|
---|
9 |
|
---|
10 | import org.openstreetmap.josm.Main;
|
---|
11 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
12 |
|
---|
13 | /**
|
---|
14 | * Zoom in map.
|
---|
15 | * @since 770
|
---|
16 | */
|
---|
17 | public 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 | // But on some systems (Belgian keyboard under Ubuntu) it seems not to work, so use also EQUALS
|
---|
37 | Main.registerActionShortcut(this,
|
---|
38 | Shortcut.registerShortcut("view:zoominter", tr("View: {0}", tr("Zoom In")),
|
---|
39 | KeyEvent.VK_EQUALS, Shortcut.DIRECT));
|
---|
40 | // make numpad + behave like +
|
---|
41 | Main.registerActionShortcut(this,
|
---|
42 | Shortcut.registerShortcut("view:zoominkeypad", tr("View: {0}", tr("Zoom In (Keypad)")),
|
---|
43 | KeyEvent.VK_ADD, Shortcut.DIRECT));
|
---|
44 | }
|
---|
45 |
|
---|
46 | @Override
|
---|
47 | public void actionPerformed(ActionEvent e) {
|
---|
48 | if (!Main.isDisplayingMapView()) return;
|
---|
49 | Main.map.mapView.zoomIn();
|
---|
50 | }
|
---|
51 |
|
---|
52 | @Override
|
---|
53 | protected void updateEnabledState() {
|
---|
54 | setEnabled(!Main.getLayerManager().getLayers().isEmpty());
|
---|
55 | }
|
---|
56 |
|
---|
57 | }
|
---|