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.gui.MainApplication;
|
---|
12 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Zoom out map.
|
---|
16 | * @since 770
|
---|
17 | */
|
---|
18 | public final class ZoomOutAction extends JosmAction {
|
---|
19 |
|
---|
20 | /**
|
---|
21 | * Constructs a new {@code ZoomOutAction}.
|
---|
22 | */
|
---|
23 | public ZoomOutAction() {
|
---|
24 | super(tr("Zoom Out"), "dialogs/zoomout", tr("Zoom Out"),
|
---|
25 | Shortcut.registerShortcut("view:zoomout", tr("View: {0}", tr("Zoom Out")), KeyEvent.VK_MINUS, Shortcut.DIRECT), true);
|
---|
26 | putValue("help", ht("/Action/ZoomOut"));
|
---|
27 | // make numpad - behave like -
|
---|
28 | Main.registerActionShortcut(this,
|
---|
29 | Shortcut.registerShortcut("view:zoomoutkeypad", tr("View: {0}", tr("Zoom Out (Keypad)")),
|
---|
30 | KeyEvent.VK_SUBTRACT, Shortcut.DIRECT));
|
---|
31 | }
|
---|
32 |
|
---|
33 | @Override
|
---|
34 | public void actionPerformed(ActionEvent e) {
|
---|
35 | if (!MainApplication.isDisplayingMapView()) return;
|
---|
36 | MainApplication.getMap().mapView.zoomOut();
|
---|
37 | }
|
---|
38 |
|
---|
39 | @Override
|
---|
40 | protected void updateEnabledState() {
|
---|
41 | setEnabled(!Main.getLayerManager().getLayers().isEmpty());
|
---|
42 | }
|
---|
43 | }
|
---|