Changeset 33290 in osm for applications/editors/josm/plugins/routes/src
- Timestamp:
- 2017-05-06T21:46:49+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes
- Files:
-
- 2 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RouteLayer.java
r32456 r33290 154 154 } 155 155 156 @Override 157 public synchronized void destroy() { 158 /* layer is reused, don't destroy it at all */ 159 } 156 160 } -
applications/editors/josm/plugins/routes/src/org/openstreetmap/josm/plugins/routes/RoutesPlugin.java
r33126 r33290 29 29 30 30 private final List<RouteLayer> routeLayers = new ArrayList<>(); 31 private boolean isShown;32 31 33 32 public RoutesPlugin(PluginInformation info) { … … 70 69 e.printStackTrace(); 71 70 } 72 73 //new RelationEditMode(Main.map);74 //Main.main.addLayer(new RouteLayer("Hiking trails"));75 71 } 76 72 … … 79 75 } 80 76 81 private void checkLayers() { 82 if (Main.map != null && Main.map.mapView != null) { 83 for (Layer layer : Main.getLayerManager().getLayers()) { 84 if (layer instanceof OsmDataLayer) { 85 if (!isShown) { 86 isShown = true; 87 SwingUtilities.invokeLater(() -> { 88 for (RouteLayer routeLayer : routeLayers) { 89 Main.getLayerManager().addLayer(routeLayer); 90 } 91 }); 92 } 93 return; 77 @Override 78 public void layerAdded(LayerAddEvent e) { 79 Layer layer = e.getAddedLayer(); 80 if (layer instanceof OsmDataLayer) { 81 for (RouteLayer routeLayer : routeLayers) { 82 if (!Main.getLayerManager().containsLayer(routeLayer)) { 83 SwingUtilities.invokeLater(() -> { 84 Main.getLayerManager().addLayer(routeLayer); 85 }); 94 86 } 95 }96 if (isShown) {97 isShown = false;98 SwingUtilities.invokeLater(() -> {99 for (RouteLayer routeLayer : routeLayers) {100 if (Main.getLayerManager().containsLayer(routeLayer)) {101 Main.getLayerManager().removeLayer(routeLayer);102 }103 }104 });105 87 } 106 88 } … … 108 90 109 91 @Override 110 public void layerAdded(LayerAddEvent e) {111 checkLayers();112 }113 114 @Override115 92 public void layerRemoving(LayerRemoveEvent e) { 116 checkLayers(); 93 for (Layer layer : e.getSource().getLayers()) { 94 if (layer instanceof OsmDataLayer) { 95 return; /* at least one OSM layer left, do nothing */ 96 } 97 } 98 if(!e.isLastLayer()) { 99 SwingUtilities.invokeLater(() -> { 100 for (RouteLayer routeLayer : routeLayers) { 101 if (Main.getLayerManager().containsLayer(routeLayer)) { 102 Main.getLayerManager().removeLayer(routeLayer); 103 } 104 } 105 }); 106 } 117 107 } 118 108
Note:
See TracChangeset
for help on using the changeset viewer.