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.JComponent;
|
---|
11 | import javax.swing.KeyStroke;
|
---|
12 |
|
---|
13 | import org.openstreetmap.josm.Main;
|
---|
14 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
15 |
|
---|
16 | public final class ZoomInAction extends JosmAction {
|
---|
17 |
|
---|
18 | public ZoomInAction() {
|
---|
19 | super(
|
---|
20 | tr("Zoom In"),
|
---|
21 | "dialogs/zoomin",
|
---|
22 | tr("Zoom In"),
|
---|
23 | Shortcut.registerShortcut("view:zoomin", tr("View: {0}", tr("Zoom In")),KeyEvent.VK_PLUS, Shortcut.GROUP_DIRECT),
|
---|
24 | true
|
---|
25 | );
|
---|
26 | putValue("help", ht("/Action/ZoomIn"));
|
---|
27 | // make numpad + behave like + (action is already registred)
|
---|
28 | Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD,0), tr("Zoom In"));
|
---|
29 | }
|
---|
30 |
|
---|
31 | public void actionPerformed(ActionEvent e) {
|
---|
32 | Object name = Main.contentPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).get(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0));
|
---|
33 | Main.contentPane.getActionMap().put(name, this);
|
---|
34 |
|
---|
35 | if (!Main.isDisplayingMapView()) return;
|
---|
36 | Main.map.mapView.zoomToFactor(0.9);
|
---|
37 | }
|
---|
38 |
|
---|
39 | @Override
|
---|
40 | protected void updateEnabledState() {
|
---|
41 | setEnabled(
|
---|
42 | Main.isDisplayingMapView()
|
---|
43 | && Main.map.mapView.hasLayers()
|
---|
44 | );
|
---|
45 | }
|
---|
46 |
|
---|
47 | }
|
---|