source: josm/trunk/src/org/openstreetmap/josm/actions/ZoomInAction.java@ 6815

Last change on this file since 6815 was 6710, checked in by Don-vip, 10 years ago

fix #5630 - use Equals as another shortcut to zoom in

  • Property svn:eol-style set to native
File size: 2.1 KB
RevLine 
[6380]1// License: GPL. For details, see LICENSE file.
[770]2package org.openstreetmap.josm.actions;
3
[2550]4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
[770]5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9
10import org.openstreetmap.josm.Main;
[1084]11import org.openstreetmap.josm.tools.Shortcut;
[770]12
[6363]13/**
14 * Zoom in map.
15 * @since 770
16 */
[770]17public final class ZoomInAction extends JosmAction {
18
[6363]19 /**
20 * Constructs a new {@code ZoomInAction}.
21 */
[1169]22 public ZoomInAction() {
[2550]23 super(
24 tr("Zoom In"),
25 "dialogs/zoomin",
26 tr("Zoom In"),
[6363]27 // Although it might be possible on few custom keyboards, the vast majority of layouts do not have a direct '+' key, see below
[4982]28 Shortcut.registerShortcut("view:zoomin", tr("View: {0}", tr("Zoom In")),KeyEvent.VK_PLUS, Shortcut.DIRECT),
[2550]29 true
30 );
[2323]31 putValue("help", ht("/Action/ZoomIn"));
[6363]32 // On standard QWERTY, AZERTY and other common layouts the '+' key is obtained with Shift+EQUALS
33 Main.registerActionShortcut(this,
34 Shortcut.registerShortcut("view:zoominbis", tr("View: {0}", tr("Zoom In")),
35 KeyEvent.VK_EQUALS, Shortcut.SHIFT));
[6710]36 // But on some systems (Belgian keyboard under Ubuntu) it seems not to work, so use also EQUALS
37 Main.registerActionShortcut(this,
38 Shortcut.registerShortcut("view:zoominter", tr("View: {0}", tr("Zoom In")),
39 KeyEvent.VK_EQUALS, Shortcut.DIRECT));
[3252]40 // make numpad + behave like +
[4891]41 Main.registerActionShortcut(this,
42 Shortcut.registerShortcut("view:zoominkeypad", tr("View: {0}", tr("Zoom In (Keypad)")),
[4982]43 KeyEvent.VK_ADD, Shortcut.DIRECT));
[1169]44 }
[770]45
[6084]46 @Override
[1169]47 public void actionPerformed(ActionEvent e) {
[2343]48 if (!Main.isDisplayingMapView()) return;
[4494]49 Main.map.mapView.zoomToFactor(1/Math.sqrt(2));
[1169]50 }
[1854]51
52 @Override
53 protected void updateEnabledState() {
54 setEnabled(
[2343]55 Main.isDisplayingMapView()
[1895]56 && Main.map.mapView.hasLayers()
[1854]57 );
58 }
59
[770]60}
Note: See TracBrowser for help on using the repository browser.