source: subversion/applications/editors/josm/plugins/print/src/org/openstreetmap/josm/plugins/print/PrintAction.java

Last change on this file was 34547, checked in by donvip, 8 months ago

update to JOSM 14153

File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.plugins.print;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7import java.awt.event.KeyEvent;
8
9import javax.swing.SwingUtilities;
10
11import org.openstreetmap.josm.actions.JosmAction;
12import org.openstreetmap.josm.gui.MainApplication;
13import org.openstreetmap.josm.tools.Shortcut;
14
15/**
16 * The PrintAction controls basic printing of the MapView
17 * and takes care of reasonable temporary adjustments to the preferences.
18 * @author Kai Pastor
19 */
20public class PrintAction extends JosmAction implements Runnable {
21
22    /**
23     * Create a new PrintAction.
24     */
25    public PrintAction() {
26        super(tr("Print..."), (String) null, tr("Print the map"),
27                Shortcut.registerShortcut("system:print", tr("File: {0}", tr("Print...")),
28                        KeyEvent.VK_P, Shortcut.CTRL), true, "print/print", true);
29    }
30
31    /**
32     * Trigger the printing dialog.
33     *
34     * @param e not used.
35     */
36    @Override
37    public void actionPerformed(ActionEvent e) {
38        // Allow the JOSM GUI to be redrawn before modifying preferences
39        SwingUtilities.invokeLater(this);
40    }
41
42    /**
43     * Open the printing dialog
44     *
45     * This will temporarily modify the mappaint preferences.
46     */
47    @Override
48    public void run() {
49        PrintPlugin.adjustPrefs();
50        PrintDialog window = new PrintDialog(MainApplication.getMainFrame());
51        window.setVisible(true);
52        PrintPlugin.restorePrefs();
53    }
54}
Note: See TracBrowser for help on using the repository browser.