1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.actions;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import java.awt.event.ActionEvent;
|
---|
7 | import java.awt.event.KeyEvent;
|
---|
8 |
|
---|
9 | import org.openstreetmap.josm.Main;
|
---|
10 | import org.openstreetmap.josm.data.osm.visitor.paint.MapRendererFactory;
|
---|
11 | import org.openstreetmap.josm.data.osm.visitor.paint.StyledMapRenderer;
|
---|
12 | import org.openstreetmap.josm.data.osm.visitor.paint.WireframeMapRenderer;
|
---|
13 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * This class toggles the wireframe rendering mode.
|
---|
17 | * @since 2530
|
---|
18 | */
|
---|
19 | public class WireframeToggleAction extends ToggleAction {
|
---|
20 |
|
---|
21 | /**
|
---|
22 | * Constructs a new {@code WireframeToggleAction}.
|
---|
23 | */
|
---|
24 | public WireframeToggleAction() {
|
---|
25 | super(tr("Wireframe View"),
|
---|
26 | null, /* no icon */
|
---|
27 | tr("Enable/disable rendering the map as wireframe only"),
|
---|
28 | Shortcut.registerShortcut("menu:view:wireframe", tr("Toggle Wireframe view"), KeyEvent.VK_W, Shortcut.CTRL),
|
---|
29 | false /* register toolbar */
|
---|
30 | );
|
---|
31 | putValue("toolbar", "wireframe");
|
---|
32 | Main.toolbar.register(this);
|
---|
33 | setSelected(MapRendererFactory.getInstance().isWireframeMapRendererActive());
|
---|
34 | notifySelectedState();
|
---|
35 | }
|
---|
36 |
|
---|
37 | @Override
|
---|
38 | protected void updateEnabledState() {
|
---|
39 | setEnabled(Main.getLayerManager().getEditLayer() != null);
|
---|
40 | }
|
---|
41 |
|
---|
42 | @Override
|
---|
43 | public void actionPerformed(ActionEvent e) {
|
---|
44 | toggleSelectedState(e);
|
---|
45 | if (isSelected()) {
|
---|
46 | MapRendererFactory.getInstance().activate(WireframeMapRenderer.class);
|
---|
47 | } else {
|
---|
48 | MapRendererFactory.getInstance().activate(StyledMapRenderer.class);
|
---|
49 | }
|
---|
50 |
|
---|
51 | notifySelectedState();
|
---|
52 | if (Main.isDisplayingMapView()) {
|
---|
53 | Main.map.mapView.repaint();
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|