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 |
|
---|
8 | import org.openstreetmap.josm.data.preferences.BooleanProperty;
|
---|
9 | import 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 | */
|
---|
16 | public 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 | }
|
---|