001// License: GPL. For details, see LICENSE file. 002package org.openstreetmap.josm.actions; 003 004import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 005import static org.openstreetmap.josm.tools.I18n.tr; 006 007import java.awt.event.ActionEvent; 008import java.awt.event.KeyEvent; 009 010import org.openstreetmap.josm.gui.MainApplication; 011import org.openstreetmap.josm.tools.Shortcut; 012 013/** 014 * Zoom in map. 015 * @since 770 016 */ 017public final class ZoomInAction extends JosmAction { 018 019 /** 020 * Constructs a new {@code ZoomInAction}. 021 */ 022 public ZoomInAction() { 023 super( 024 tr("Zoom In"), 025 "dialogs/zoomin", 026 tr("Zoom In"), 027 // Although it might be possible on few custom keyboards, the vast majority of layouts do not have a direct '+' key, see below 028 Shortcut.registerShortcut("view:zoomin", tr("View: {0}", tr("Zoom In")), KeyEvent.VK_PLUS, Shortcut.DIRECT), 029 true 030 ); 031 putValue("help", ht("/Action/ZoomIn")); 032 // On standard QWERTY, AZERTY and other common layouts the '+' key is obtained with Shift+EQUALS 033 MainApplication.registerActionShortcut(this, 034 Shortcut.registerShortcut("view:zoominbis", tr("View: {0}", tr("Zoom In")), 035 KeyEvent.VK_EQUALS, Shortcut.SHIFT)); 036 // But on some systems (Belgian keyboard under Ubuntu) it seems not to work, so use also EQUALS 037 MainApplication.registerActionShortcut(this, 038 Shortcut.registerShortcut("view:zoominter", tr("View: {0}", tr("Zoom In")), 039 KeyEvent.VK_EQUALS, Shortcut.DIRECT)); 040 // make numpad + behave like + 041 MainApplication.registerActionShortcut(this, 042 Shortcut.registerShortcut("view:zoominkeypad", tr("View: {0}", tr("Zoom In (Keypad)")), 043 KeyEvent.VK_ADD, Shortcut.DIRECT)); 044 } 045 046 @Override 047 public void actionPerformed(ActionEvent e) { 048 if (!MainApplication.isDisplayingMapView()) return; 049 MainApplication.getMap().mapView.zoomIn(); 050 } 051 052 @Override 053 protected void updateEnabledState() { 054 setEnabled(!getLayerManager().getLayers().isEmpty()); 055 } 056 057}