source: josm/trunk/src/org/openstreetmap/josm/actions/HatchAreaOutsideDownloadAction.java@ 14388

Last change on this file since 14388 was 14388, checked in by simon04, 5 years ago

Add checkbox to main menu to toggle hatched background rendering of areas outside of the downloaded areas

This is useful, e.g, for mapping public transport relations when one
downloads a relation modify by id and missing stops by bbox.

File size: 1.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.actions;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.event.ActionEvent;
7
8import org.openstreetmap.josm.data.preferences.BooleanProperty;
9import org.openstreetmap.josm.gui.MainApplication;
10
11/**
12 * This class toggles hatched background rendering of areas outside of the downloaded areas.
13 *
14 * @since 14388
15 */
16public class HatchAreaOutsideDownloadAction extends PreferenceToggleAction {
17
18 private static final BooleanProperty PROP = new BooleanProperty("mappaint.hatch-outside-download-area", true);
19
20 /**
21 * Constructs a new {@link HatchAreaOutsideDownloadAction}.
22 */
23 public HatchAreaOutsideDownloadAction() {
24 super(tr("Hatch area outside download"),
25 tr("Enable/disable hatched background rendering of areas outside of the downloaded areas."),
26 PROP.getKey(), PROP.getDefaultValue()
27 );
28 }
29
30 @Override
31 protected void updateEnabledState() {
32 setEnabled(MainApplication.getLayerManager().getEditLayer() != null);
33 }
34
35 @Override
36 public void actionPerformed(ActionEvent e) {
37 super.actionPerformed(e);
38 if (MainApplication.isDisplayingMapView()) {
39 MainApplication.getMap().mapView.repaint();
40 }
41 }
42
43 /**
44 * Determines whether hatched background rendering is enabled
45 *
46 * @return whether hatched background rendering is enabled
47 */
48 public static boolean isHatchEnabled() {
49 return PROP.get();
50 }
51}
Note: See TracBrowser for help on using the repository browser.