[2711] | 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;
|
---|
[4087] | 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;
|
---|
[2711] | 13 | import org.openstreetmap.josm.tools.Shortcut;
|
---|
| 14 |
|
---|
[6220] | 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 | */
|
---|
[2711] | 24 | public WireframeToggleAction() {
|
---|
[6220] | 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 */
|
---|
[2711] | 30 | );
|
---|
[6069] | 31 | putValue("toolbar", "wireframe");
|
---|
[4177] | 32 | Main.toolbar.register(this);
|
---|
[6220] | 33 | setSelected(MapRendererFactory.getInstance().isWireframeMapRendererActive());
|
---|
[4175] | 34 | notifySelectedState();
|
---|
[2711] | 35 | }
|
---|
| 36 |
|
---|
[6220] | 37 | @Override
|
---|
| 38 | protected void updateEnabledState() {
|
---|
[6336] | 39 | setEnabled(Main.main.hasEditLayer());
|
---|
[4175] | 40 | }
|
---|
[2711] | 41 |
|
---|
[6220] | 42 | @Override
|
---|
| 43 | public void actionPerformed(ActionEvent e) {
|
---|
[6327] | 44 | toggleSelectedState(e);
|
---|
[6220] | 45 | if (isSelected()) {
|
---|
| 46 | MapRendererFactory.getInstance().activate(WireframeMapRenderer.class);
|
---|
| 47 | } else {
|
---|
| 48 | MapRendererFactory.getInstance().activate(StyledMapRenderer.class);
|
---|
[2711] | 49 | }
|
---|
[4175] | 50 |
|
---|
| 51 | notifySelectedState();
|
---|
[5460] | 52 | if (Main.isDisplayingMapView()) {
|
---|
[2711] | 53 | Main.map.mapView.repaint();
|
---|
| 54 | }
|
---|
| 55 | }
|
---|
| 56 | }
|
---|