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