Changeset 33782 in osm for applications/editors/josm/plugins/editgpx/src/org
- Timestamp:
- 2017-11-05T19:36:58+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/editgpx/src/org/openstreetmap/josm/plugins/editgpx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxLayer.java
r32485 r33782 21 21 import org.openstreetmap.josm.data.gpx.GpxData; 22 22 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 23 import org.openstreetmap.josm.data.projection.Projection; 24 import org.openstreetmap.josm.gui.MainApplication; 23 25 import org.openstreetmap.josm.gui.MapView; 24 26 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; … … 103 105 //don't iterate through dataSet whiling making changes 104 106 synchronized(layerImport.importing) { 107 Projection projection = Main.getProjection(); 105 108 for (EditGpxTrack track: data.getTracks()) { 106 109 for (EditGpxTrackSegment segment: track.getSegments()) { 107 110 for (EditGpxWayPoint wayPoint: segment.getWayPoints()) { 108 111 if (!wayPoint.isDeleted()) { 109 Point pnt = mv.getPoint(wayPoint.getCoor().getEastNorth( ));112 Point pnt = mv.getPoint(wayPoint.getCoor().getEastNorth(projection)); 110 113 g.drawOval(pnt.x - 2, pnt.y - 2, 4, 4); 111 114 } … … 147 150 @Override 148 151 public void actionPerformed(ActionEvent e) { 149 if (Main .map.mapMode instanceof EditGpxMode && !Main.map.selectSelectTool(false)) {150 Main .map.selectZoomTool(false); // Select tool might not be support of active layer, zoom is always supported152 if (MainApplication.getMap().mapMode instanceof EditGpxMode && !MainApplication.getMap().selectSelectTool(false)) { 153 MainApplication.getMap().selectZoomTool(false); // Select tool might not be support of active layer, zoom is always supported 151 154 } 152 Main .getLayerManager().addLayer(new GpxLayer(toGpxData(false), tr("Converted from: {0}", getName())));153 Main .getLayerManager().removeLayer(EditGpxLayer.this);155 MainApplication.getLayerManager().addLayer(new GpxLayer(toGpxData(false), tr("Converted from: {0}", getName()))); 156 MainApplication.getLayerManager().removeLayer(EditGpxLayer.this); 154 157 } 155 158 } … … 167 170 @Override 168 171 public void actionPerformed(ActionEvent e) { 169 if (Main .map.mapMode instanceof EditGpxMode && !Main.map.selectSelectTool(false)) {170 Main .map.selectZoomTool(false); // Select tool might not be support of active layer, zoom is always supported172 if (MainApplication.getMap().mapMode instanceof EditGpxMode && !MainApplication.getMap().selectSelectTool(false)) { 173 MainApplication.getMap().selectZoomTool(false); // Select tool might not be support of active layer, zoom is always supported 171 174 } 172 Main .getLayerManager().addLayer(new GpxLayer(toGpxData(true), tr("Converted from: {0}", getName())));173 Main .getLayerManager().removeLayer(EditGpxLayer.this);175 MainApplication.getLayerManager().addLayer(new GpxLayer(toGpxData(true), tr("Converted from: {0}", getName()))); 176 MainApplication.getLayerManager().removeLayer(EditGpxLayer.this); 174 177 } 175 178 } -
applications/editors/josm/plugins/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxMode.java
r32485 r33782 17 17 import org.openstreetmap.josm.Main; 18 18 import org.openstreetmap.josm.actions.mapmode.MapMode; 19 import org.openstreetmap.josm.data.projection.Projection; 20 import org.openstreetmap.josm.gui.MainApplication; 19 21 import org.openstreetmap.josm.gui.MapFrame; 20 22 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; … … 41 43 */ 42 44 public EditGpxMode(MapFrame mapFrame) { 43 super("editgpx", "editgpx_mode.png", tr("edit gpx tracks"), Main.map,Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));45 super("editgpx", "editgpx_mode.png", tr("edit gpx tracks"), Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); 44 46 this.mapFrame = mapFrame; 45 47 } … … 48 50 public void enterMode() { 49 51 super.enterMode(); 50 Main .map.mapView.addMouseListener(this);51 Main .map.mapView.addMouseMotionListener(this);52 Main .map.mapView.getLayerManager().addLayerChangeListener(this);52 MainApplication.getMap().mapView.addMouseListener(this); 53 MainApplication.getMap().mapView.addMouseMotionListener(this); 54 MainApplication.getMap().mapView.getLayerManager().addLayerChangeListener(this); 53 55 updateLayer(); 54 56 } … … 57 59 public void exitMode() { 58 60 super.exitMode(); 59 Main .map.mapView.removeMouseListener(this);60 Main .map.mapView.removeMouseMotionListener(this);61 Main .map.mapView.getLayerManager().removeLayerChangeListener(this);61 MainApplication.getMap().mapView.removeMouseListener(this); 62 MainApplication.getMap().mapView.removeMouseMotionListener(this); 63 MainApplication.getMap().mapView.getLayerManager().removeLayerChangeListener(this); 62 64 } 63 65 … … 87 89 //go through nodes and mark the ones in the selection rect as deleted 88 90 if (currentEditLayer != null) { 91 Projection projection = Main.getProjection(); 89 92 for (EditGpxTrack track: currentEditLayer.data.getTracks()) { 90 93 for (EditGpxTrackSegment segment: track.getSegments()) { 91 94 for (EditGpxWayPoint wayPoint: segment.getWayPoints()) { 92 Point p = Main .map.mapView.getPoint(wayPoint.getCoor().getEastNorth());95 Point p = MainApplication.getMap().mapView.getPoint(wayPoint.getCoor().getEastNorth(projection)); 93 96 if (r.contains(p)) { 94 97 wayPoint.setDeleted(true); … … 99 102 } 100 103 oldRect = null; 101 Main .map.mapView.repaint();104 MainApplication.getMap().mapView.repaint(); 102 105 } 103 106 … … 160 163 private void updateLayer() { 161 164 162 List<EditGpxLayer> layers = Main .map.mapView.getLayerManager().getLayersOfType(EditGpxLayer.class);165 List<EditGpxLayer> layers = MainApplication.getMap().mapView.getLayerManager().getLayersOfType(EditGpxLayer.class); 163 166 currentEditLayer = layers.isEmpty() ? null : layers.get(0); 164 167 165 168 if(currentEditLayer == null) { 166 169 currentEditLayer = new EditGpxLayer(new EditGpxData()); 167 Main .getLayerManager().addLayer(currentEditLayer);170 MainApplication.getLayerManager().addLayer(currentEditLayer); 168 171 currentEditLayer.initializeImport(); 169 172 } 170 Main .map.mapView.repaint();173 MainApplication.getMap().mapView.repaint(); 171 174 } 172 175 … … 180 183 if (e.getRemovedLayer() instanceof EditGpxLayer) { 181 184 currentEditLayer = null; 182 if (Main .map.mapMode instanceof EditGpxMode) {183 if (Main .map.mapView.getLayerManager().getActiveLayer() instanceof OsmDataLayer) {184 Main .map.selectSelectTool(false);185 if (MainApplication.getMap().mapMode instanceof EditGpxMode) { 186 if (MainApplication.getMap().mapView.getLayerManager().getActiveLayer() instanceof OsmDataLayer) { 187 MainApplication.getMap().selectSelectTool(false); 185 188 } else { 186 Main .map.selectZoomTool(false);189 MainApplication.getMap().selectZoomTool(false); 187 190 } 188 191 } -
applications/editors/josm/plugins/editgpx/src/org/openstreetmap/josm/plugins/editgpx/EditGpxPlugin.java
r32263 r33782 6 6 import javax.swing.ImageIcon; 7 7 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.gui.IconToggleButton; 9 import org.openstreetmap.josm.gui.MainApplication; 10 10 import org.openstreetmap.josm.gui.MapFrame; 11 11 import org.openstreetmap.josm.plugins.Plugin; … … 40 40 if (newFrame != null) { 41 41 EditGpxMode mode = new EditGpxMode(newFrame); 42 if (Main .map!= null)43 Main .map.addMapMode(new IconToggleButton(mode));42 if (MainApplication.getMap() != null) 43 MainApplication.getMap().addMapMode(new IconToggleButton(mode)); 44 44 } 45 45 } -
applications/editors/josm/plugins/editgpx/src/org/openstreetmap/josm/plugins/editgpx/GPXLayerImportAction.java
r32263 r33782 24 24 25 25 import org.openstreetmap.josm.Main; 26 import org.openstreetmap.josm.gui.MainApplication; 26 27 import org.openstreetmap.josm.gui.layer.GpxLayer; 27 28 import org.openstreetmap.josm.gui.layer.Layer; … … 54 55 int layerCnt = 0; 55 56 56 for (Layer l : Main .map.mapView.getLayerManager().getLayers()){57 for (Layer l : MainApplication.getMap().mapView.getLayerManager().getLayers()){ 57 58 if (l instanceof GpxLayer){ 58 59 dModel.addElement((GpxLayer) l); … … 103 104 } 104 105 } 105 Main .map.mapView.repaint();106 MainApplication.getMap().mapView.repaint(); 106 107 107 108 } else { -
applications/editors/josm/plugins/editgpx/src/org/openstreetmap/josm/plugins/editgpx/data/EditGpxWayPoint.java
r30737 r33782 45 45 } 46 46 47 @Override 47 48 public int compareTo(EditGpxWayPoint o) { 48 49 return Double.compare(getTime(), o.getTime());
Note:
See TracChangeset
for help on using the changeset viewer.