Changeset 32371 in osm for applications/editors/josm/plugins/seachart/src
- Timestamp:
- 2016-06-23T00:54:03+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/src/seachart/SeachartAction.java
r32088 r32371 10 10 package seachart; 11 11 12 import java.awt.event.*; 13 14 import javax.swing.*; 15 12 import java.awt.event.ActionEvent; 16 13 import java.util.Map.Entry; 17 14 15 import javax.swing.SwingUtilities; 16 17 import org.openstreetmap.josm.Main; 18 18 import org.openstreetmap.josm.actions.JosmAction; 19 import org.openstreetmap.josm.gui.MapView;20 import org.openstreetmap.josm.gui.MapView.EditLayerChangeListener;21 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;22 import org.openstreetmap.josm.gui.layer.*;23 19 import org.openstreetmap.josm.data.Bounds; 24 20 import org.openstreetmap.josm.data.coor.LatLon; 25 21 import org.openstreetmap.josm.data.imagery.ImageryInfo; 26 import org.openstreetmap.josm.data.osm.*; 27 import org.openstreetmap.josm.data.osm.event.*; 28 import org.openstreetmap.josm.Main; 22 import org.openstreetmap.josm.data.osm.DataSet; 23 import org.openstreetmap.josm.data.osm.Node; 24 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 25 import org.openstreetmap.josm.data.osm.Relation; 26 import org.openstreetmap.josm.data.osm.RelationMember; 27 import org.openstreetmap.josm.data.osm.Way; 28 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 29 import org.openstreetmap.josm.data.osm.event.DataChangedEvent; 30 import org.openstreetmap.josm.data.osm.event.DataSetListener; 31 import org.openstreetmap.josm.data.osm.event.NodeMovedEvent; 32 import org.openstreetmap.josm.data.osm.event.PrimitivesAddedEvent; 33 import org.openstreetmap.josm.data.osm.event.PrimitivesRemovedEvent; 34 import org.openstreetmap.josm.data.osm.event.RelationMembersChangedEvent; 35 import org.openstreetmap.josm.data.osm.event.TagsChangedEvent; 36 import org.openstreetmap.josm.data.osm.event.WayNodesChangedEvent; 37 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 38 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 39 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 40 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 41 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 42 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 43 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 29 44 30 45 import s57.S57map; 31 import s57.S57map.*; 32 33 public class SeachartAction extends JosmAction implements EditLayerChangeListener, LayerChangeListener { 46 47 public class SeachartAction extends JosmAction implements ActiveLayerChangeListener, LayerChangeListener { 34 48 private static String title = "SeaChart"; 35 49 private boolean isOpen = false; … … 86 100 87 101 @Override 88 public void activeLayerChange(Layer arg0, Layer arg1) {102 public void layerAdded(LayerAddEvent e) { 89 103 } 90 104 91 105 @Override 92 public void layerAdded(Layer arg0) { 93 } 94 95 @Override 96 public void layerRemoved(Layer arg0) { 97 if (arg0.getName().equals("SeaChart")) { 106 public void layerRemoving(LayerRemoveEvent e) { 107 if ("SeaChart".equals(e.getRemovedLayer().getName())) { 98 108 closeChartLayer(); 99 109 } 100 110 } 101 111 102 @Override 112 @Override 113 public void layerOrderChanged(LayerOrderChangeEvent e) { 114 } 115 116 @Override 103 117 public void actionPerformed(ActionEvent arg0) { 104 118 SwingUtilities.invokeLater(new Runnable() { … … 114 128 rendering = new ChartImage(new ImageryInfo("SeaChart")); 115 129 rendering.setBackgroundLayer(true); 116 Main.main.addLayer(rendering); 117 MapView.addEditLayerChangeListener(this); 118 MapView.addLayerChangeListener(this); 119 editLayerChanged(Main.main.getEditLayer(), Main.main.getEditLayer()); 130 Main.getLayerManager().addLayer(rendering); 131 Main.getLayerManager().addAndFireActiveLayerChangeListener(this); 132 Main.getLayerManager().addLayerChangeListener(this); 120 133 } 121 134 122 135 public void closeChartLayer() { 123 136 if (isOpen) { 124 MapView.removeEditLayerChangeListener(this);125 Ma pView.removeLayerChangeListener(this);126 Main. main.removeLayer(rendering);137 Main.getLayerManager().removeActiveLayerChangeListener(this); 138 Main.getLayerManager().removeLayerChangeListener(this); 139 Main.getLayerManager().removeLayer(rendering); 127 140 } 128 141 isOpen = false; … … 130 143 131 144 @Override 132 public void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer) { 145 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 146 OsmDataLayer oldLayer = e.getPreviousEditLayer(); 133 147 if (oldLayer != null) { 134 148 oldLayer.data.removeDataSetListener(dataSetListener); 135 149 } 150 OsmDataLayer newLayer = Main.getLayerManager().getEditLayer(); 136 151 if (newLayer != null) { 137 152 newLayer.data.addDataSetListener(dataSetListener);
Note:
See TracChangeset
for help on using the changeset viewer.