1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.layer.geoimage;
|
---|
3 |
|
---|
4 | import static org.openstreetmap.josm.tools.I18n.tr;
|
---|
5 |
|
---|
6 | import org.openstreetmap.josm.data.gpx.GpxData;
|
---|
7 | import org.openstreetmap.josm.data.gpx.GpxDataContainer;
|
---|
8 | import org.openstreetmap.josm.data.osm.DownloadPolicy;
|
---|
9 | import org.openstreetmap.josm.data.osm.UploadPolicy;
|
---|
10 | import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
|
---|
11 | import org.openstreetmap.josm.gui.layer.Layer;
|
---|
12 | import org.openstreetmap.josm.gui.layer.OsmDataLayer;
|
---|
13 | import org.openstreetmap.josm.gui.layer.gpx.ConvertFromGpxLayerAction;
|
---|
14 |
|
---|
15 | /**
|
---|
16 | * A support layer meant to be modified by the user to provide real-time images correlation.
|
---|
17 | * @since 18078
|
---|
18 | */
|
---|
19 | public final class CorrelationSupportLayer extends OsmDataLayer implements GpxDataContainer {
|
---|
20 |
|
---|
21 | private static final String CORRELATION_PREFIX = "correlation:";
|
---|
22 |
|
---|
23 | private final GpxData gpxData = new GpxData();
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * Constructs a new {@code CorrelationSupportLayer} with a default name
|
---|
27 | * @param fauxGpxData Faux GPX data to be modified using OSM editing tools
|
---|
28 | */
|
---|
29 | public CorrelationSupportLayer(GpxData fauxGpxData) {
|
---|
30 | this(fauxGpxData, tr("Correlation support layer"));
|
---|
31 | }
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Constructs a new {@code CorrelationSupportLayer} with a given name
|
---|
35 | * @param fauxGpxData Faux GPX data to be modified using OSM editing tools
|
---|
36 | * @param name layer name
|
---|
37 | */
|
---|
38 | public CorrelationSupportLayer(GpxData fauxGpxData, String name) {
|
---|
39 | super(ConvertFromGpxLayerAction.convert(fauxGpxData, "list", CORRELATION_PREFIX), name, null);
|
---|
40 | data.setDownloadPolicy(DownloadPolicy.BLOCKED);
|
---|
41 | data.setUploadPolicy(UploadPolicy.BLOCKED);
|
---|
42 | rebuildGpxData();
|
---|
43 | }
|
---|
44 |
|
---|
45 | private void rebuildGpxData() {
|
---|
46 | gpxData.beginUpdate();
|
---|
47 | try {
|
---|
48 | gpxData.clear();
|
---|
49 | fillGpxData(gpxData, data, null, CORRELATION_PREFIX);
|
---|
50 | } finally {
|
---|
51 | gpxData.endUpdate();
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 | @Override
|
---|
56 | public GpxData getGpxData() {
|
---|
57 | return gpxData;
|
---|
58 | }
|
---|
59 |
|
---|
60 | @Override
|
---|
61 | public void processDatasetEvent(AbstractDatasetChangedEvent event) {
|
---|
62 | invalidate();
|
---|
63 | rebuildGpxData();
|
---|
64 | }
|
---|
65 |
|
---|
66 | @Override
|
---|
67 | protected void setRequiresSaveToFile(boolean newValue) {
|
---|
68 | // Do nothing
|
---|
69 | }
|
---|
70 |
|
---|
71 | @Override
|
---|
72 | protected void setRequiresUploadToServer(boolean newValue) {
|
---|
73 | // Do nothing
|
---|
74 | }
|
---|
75 |
|
---|
76 | @Override
|
---|
77 | public boolean isMergable(Layer other) {
|
---|
78 | return false;
|
---|
79 | }
|
---|
80 |
|
---|
81 | @Override
|
---|
82 | public boolean isDownloadable() {
|
---|
83 | return false;
|
---|
84 | }
|
---|
85 |
|
---|
86 | @Override
|
---|
87 | public boolean isUploadable() {
|
---|
88 | return false;
|
---|
89 | }
|
---|
90 |
|
---|
91 | @Override
|
---|
92 | public boolean requiresUploadToServer() {
|
---|
93 | return false;
|
---|
94 | }
|
---|
95 |
|
---|
96 | @Override
|
---|
97 | public boolean requiresSaveToFile() {
|
---|
98 | return false;
|
---|
99 | }
|
---|
100 |
|
---|
101 | @Override
|
---|
102 | public boolean isSavable() {
|
---|
103 | return false;
|
---|
104 | }
|
---|
105 | }
|
---|