| 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.DIRECT), true); |
|---|
| 20 | putValue("help", ht("/Action/ZoomOut")); |
|---|
| 21 | // make numpad - behave like - |
|---|
| 22 | Main.registerActionShortcut(this, |
|---|
| 23 | Shortcut.registerShortcut("view:zoomoutkeypad", tr("View: {0}", tr("Zoom Out (Keypad)")), |
|---|
| 24 | KeyEvent.VK_SUBTRACT, Shortcut.DIRECT)); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | public void actionPerformed(ActionEvent e) { |
|---|
| 28 | if (!Main.isDisplayingMapView()) return; |
|---|
| 29 | Main.map.mapView.zoomToFactor(Math.sqrt(2)); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | @Override |
|---|
| 33 | protected void updateEnabledState() { |
|---|
| 34 | setEnabled( |
|---|
| 35 | Main.isDisplayingMapView() |
|---|
| 36 | && Main.map.mapView.hasLayers() |
|---|
| 37 | ); |
|---|
| 38 | } |
|---|
| 39 | } |
|---|