| 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 ZoomInAction extends JosmAction { |
|---|
| 16 | |
|---|
| 17 | public ZoomInAction() { |
|---|
| 18 | super( |
|---|
| 19 | tr("Zoom In"), |
|---|
| 20 | "dialogs/zoomin", |
|---|
| 21 | tr("Zoom In"), |
|---|
| 22 | Shortcut.registerShortcut("view:zoomin", tr("View: {0}", tr("Zoom In")),KeyEvent.VK_PLUS, Shortcut.DIRECT), |
|---|
| 23 | true |
|---|
| 24 | ); |
|---|
| 25 | putValue("help", ht("/Action/ZoomIn")); |
|---|
| 26 | // make numpad + behave like + |
|---|
| 27 | Main.registerActionShortcut(this, |
|---|
| 28 | Shortcut.registerShortcut("view:zoominkeypad", tr("View: {0}", tr("Zoom In (Keypad)")), |
|---|
| 29 | KeyEvent.VK_ADD, Shortcut.DIRECT)); |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | public void actionPerformed(ActionEvent e) { |
|---|
| 33 | if (!Main.isDisplayingMapView()) return; |
|---|
| 34 | Main.map.mapView.zoomToFactor(1/Math.sqrt(2)); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | @Override |
|---|
| 38 | protected void updateEnabledState() { |
|---|
| 39 | setEnabled( |
|---|
| 40 | Main.isDisplayingMapView() |
|---|
| 41 | && Main.map.mapView.hasLayers() |
|---|
| 42 | ); |
|---|
| 43 | } |
|---|
| 44 | |
|---|
| 45 | } |
|---|