1 | // License: GPL. Copyright 2007 by Immanuel Scholz and others
|
---|
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 javax.swing.KeyStroke;
|
---|
11 |
|
---|
12 | import org.openstreetmap.josm.Main;
|
---|
13 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
14 |
|
---|
15 | public final class ZoomOutAction extends JosmAction {
|
---|
16 |
|
---|
17 | public ZoomOutAction() {
|
---|
18 | super(tr("Zoom Out"), "dialogs/zoomout", tr("Zoom Out"),
|
---|
19 | Shortcut.registerShortcut("view:zoomout", tr("View: {0}", tr("Zoom Out")), KeyEvent.VK_MINUS, Shortcut.GROUP_DIRECT), true);
|
---|
20 | putValue("help", ht("/Action/ZoomOut"));
|
---|
21 | // make numpad - behave like -
|
---|
22 | Main.registerActionShortcut(this, KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT,0));
|
---|
23 | }
|
---|
24 |
|
---|
25 | public void actionPerformed(ActionEvent e) {
|
---|
26 | if (!Main.isDisplayingMapView()) return;
|
---|
27 | Main.map.mapView.zoomToFactor(1/0.9);
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Override
|
---|
31 | protected void updateEnabledState() {
|
---|
32 | setEnabled(
|
---|
33 | Main.isDisplayingMapView()
|
---|
34 | && Main.map.mapView.hasLayers()
|
---|
35 | );
|
---|
36 | }
|
---|
37 | }
|
---|