Changeset 33547 in osm for applications/editors/josm/plugins/imagery_offset_db/src
- Timestamp:
- 2017-08-26T21:28:34+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/imagery_offset_db/src/iodb
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery_offset_db/src/iodb/CalibrationLayer.java
r32910 r33547 19 19 import javax.swing.Icon; 20 20 21 import org.openstreetmap.josm.Main;22 21 import org.openstreetmap.josm.actions.AutoScaleAction; 23 22 import org.openstreetmap.josm.data.Bounds; 24 23 import org.openstreetmap.josm.data.coor.LatLon; 25 24 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 25 import org.openstreetmap.josm.gui.MainApplication; 26 26 import org.openstreetmap.josm.gui.MapView; 27 27 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; … … 152 152 double lat = 0.0; 153 153 double lon = 0.0; 154 for ( int i = 0; i <geometry.length; i++) {155 lon += geometry[i].lon();156 lat += geometry[i].lat();154 for (LatLon ll : geometry) { 155 lon += ll.lon(); 156 lat += ll.lat(); 157 157 } 158 158 center = new LatLon(lat / geometry.length, lon / geometry.length); 159 159 } 160 Main .map.mapView.zoomTo(center);160 MainApplication.getMap().mapView.zoomTo(center); 161 161 } 162 162 … … 178 178 public void actionPerformed(ActionEvent e) { 179 179 color = c; 180 Main .map.mapView.repaint();180 MainApplication.getMap().mapView.repaint(); 181 181 } 182 182 } -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/DeprecateOffsetAction.java
r32528 r33547 13 13 import org.openstreetmap.josm.Main; 14 14 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 15 import org.openstreetmap.josm.gui.MainApplication; 15 16 import org.openstreetmap.josm.tools.ImageProvider; 17 import org.openstreetmap.josm.tools.Logging; 16 18 17 19 /** … … 43 45 @Override 44 46 public void actionPerformed(ActionEvent e) { 45 if ( Main.map == null || Main.map.mapView == null|| !Main.map.isVisible())47 if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().isVisible()) 46 48 return; 47 49 … … 98 100 if (listener != null) 99 101 depTask.setListener(listener); 100 Main.worker.submit(depTask); 102 MainApplication.worker.submit(depTask); 101 103 } catch (UnsupportedEncodingException ex) { 102 Main.error(ex);104 Logging.error(ex); 103 105 } 104 106 } -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java
r33309 r33547 21 21 import org.openstreetmap.josm.data.coor.LatLon; 22 22 import org.openstreetmap.josm.data.projection.Projection; 23 import org.openstreetmap.josm.gui.MainApplication; 23 24 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 24 25 import org.openstreetmap.josm.tools.ImageProvider; … … 54 55 @Override 55 56 public void actionPerformed(ActionEvent e) { 56 if ( Main.map == null || Main.map.mapView == null|| !Main.map.isVisible())57 if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().isVisible()) 57 58 return; 58 Projection proj = Main .map.mapView.getProjection();59 LatLon center = proj.eastNorth2latlon(Main .map.mapView.getCenter());59 Projection proj = MainApplication.getMap().mapView.getProjection(); 60 LatLon center = proj.eastNorth2latlon(MainApplication.getMap().mapView.getCenter()); 60 61 AbstractTileSourceLayer layer = ImageryOffsetTools.getTopImageryLayer(); 61 62 String imagery = ImageryOffsetTools.getImageryID(layer); … … 64 65 65 66 DownloadOffsetsTask download = new DownloadOffsetsTask(center, layer, imagery); 66 Main.worker.submit(download); 67 MainApplication.worker.submit(download); 67 68 } 68 69 … … 74 75 protected void updateEnabledState() { 75 76 boolean state = true; 76 if ( Main.map == null || Main.map.mapView == null|| !Main.map.isVisible())77 if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().isVisible()) 77 78 state = false; 78 79 AbstractTileSourceLayer layer = ImageryOffsetTools.getTopImageryLayer(); -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/IODBReader.java
r32910 r33547 15 15 import org.openstreetmap.josm.data.coor.LatLon; 16 16 import org.openstreetmap.josm.io.UTFInputStreamReader; 17 import org.openstreetmap.josm.tools.Logging; 17 18 import org.xml.sax.Attributes; 18 19 import org.xml.sax.InputSource; … … 163 164 // On one hand, we don't care, but this situation is one 164 165 // of those "it can never happen" cases. 165 System.err.println(ex.getMessage());166 Logging.warn(ex); 166 167 } 167 168 parsingOffset = false; -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffset.java
r33309 r33547 3 3 4 4 import java.util.Map; 5 import org.openstreetmap.josm.Main;6 5 7 6 import org.openstreetmap.josm.data.coor.CoordinateFormat; 8 import org.openstreetmap.josm.data.coor.EastNorth;9 7 import org.openstreetmap.josm.data.coor.LatLon; 10 import org.openstreetmap.josm.data.imagery.OffsetBookmark;11 import org.openstreetmap.josm.data.projection.Projection;12 8 13 9 /** -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetPlugin.java
r32528 r33547 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.data.Version; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.gui.preferences.ToolbarPreferences; 15 16 import org.openstreetmap.josm.plugins.Plugin; … … 42 43 int version = Version.getInstance().getVersion(); 43 44 JMenu offsetMenu = version < 5803 44 ? Main .main.menu.addMenu("Offset", tr("Offset"), KeyEvent.VK_O, 6, "help")45 : Main .main.menu.imageryMenu;45 ? MainApplication.getMenu().addMenu("Offset", tr("Offset"), KeyEvent.VK_O, 6, "help") 46 : MainApplication.getMenu().imageryMenu; 46 47 offsetMenu.add(getAction); 47 48 offsetMenu.add(storeAction); … … 53 54 toolbar.add("getoffset"); 54 55 Main.pref.putCollection("toolbar", toolbar); 55 Main .toolbar.refreshToolbarControl();56 MainApplication.getToolbar().refreshToolbarControl(); 56 57 } 57 58 Main.pref.put("iodb.modify.toolbar", false); -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetTools.java
r33309 r33547 12 12 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 13 13 import org.openstreetmap.josm.data.projection.Projection; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.gui.MapView; 15 16 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; … … 36 37 */ 37 38 public static AbstractTileSourceLayer getTopImageryLayer() { 38 if ( Main.map == null || Main.map.mapView == null)39 if (!MainApplication.isDisplayingMapView()) 39 40 return null; 40 List<AbstractTileSourceLayer> layers = Main.getLayerManager().getLayersOfType(AbstractTileSourceLayer.class); 41 List<AbstractTileSourceLayer> layers = MainApplication.getLayerManager().getLayersOfType(AbstractTileSourceLayer.class); 41 42 for (AbstractTileSourceLayer layer : layers) { 42 43 String url = layer.getInfo().getUrl(); … … 54 55 public static LatLon getMapCenter() { 55 56 Projection proj = Main.getProjection(); 56 return Main.map == null || Main.map.mapView == null57 ? new LatLon(0, 0) : proj.eastNorth2latlon(Main .map.mapView.getCenter());57 return !MainApplication.isDisplayingMapView() 58 ? new LatLon(0, 0) : proj.eastNorth2latlon(MainApplication.getMap().mapView.getCenter()); 58 59 } 59 60 … … 67 68 public static LatLon getLayerOffset(AbstractTileSourceLayer layer, LatLon center) { 68 69 Projection proj = Main.getProjection(); 69 EastNorth offsetCenter = Main .map.mapView.getCenter();70 EastNorth offsetCenter = MainApplication.getMap().mapView.getCenter(); 70 71 EastNorth centerOffset = offsetCenter.add(-layer.getDisplaySettings().getDx(), 71 72 -layer.getDisplaySettings().getDy()); … … 121 122 122 123 public static int getCurrentZoom() { 123 if ( Main.map == null || Main.map.mapView == null) {124 if (!MainApplication.isDisplayingMapView()) { 124 125 return 1; 125 126 } 126 MapView mv = Main .map.mapView;127 MapView mv = MainApplication.getMap().mapView; 127 128 LatLon topLeft = mv.getLatLon(0, 0); 128 129 LatLon botRight = mv.getLatLon(mv.getWidth(), mv.getHeight()); -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetWatcher.java
r33309 r33547 15 15 import org.openstreetmap.josm.data.coor.LatLon; 16 16 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 17 import org.openstreetmap.josm.gui.MainApplication; 17 18 import org.openstreetmap.josm.gui.MapView; 18 19 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener; … … 51 52 maxDistance = Main.pref.getDouble("iodb.offset.radius", 15); 52 53 MapView.addZoomChangeListener(this); 53 Main.getLayerManager().addLayerChangeListener(this); 54 Main.getLayerManager().addActiveLayerChangeListener(this); 54 MainApplication.getLayerManager().addLayerChangeListener(this); 55 MainApplication.getLayerManager().addActiveLayerChangeListener(this); 55 56 checkOffset(); // we assume there's at the most one imagery layer at this moment 56 57 time = new Timer(); … … 64 65 public void destroy() { 65 66 MapView.removeZoomChangeListener(this); 66 Main.getLayerManager().removeLayerChangeListener(this); 67 Main.getLayerManager().removeActiveLayerChangeListener(this); 67 MainApplication.getLayerManager().removeLayerChangeListener(this); 68 MainApplication.getLayerManager().removeActiveLayerChangeListener(this); 68 69 time.cancel(); 69 70 } -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java
r33309 r33547 38 38 import org.openstreetmap.josm.data.Bounds; 39 39 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 40 import org.openstreetmap.josm.gui.MainApplication; 40 41 import org.openstreetmap.josm.gui.MapView; 41 42 import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener; … … 154 155 } 155 156 pack(); 156 Main .map.mapView.repaint();157 MainApplication.getMap().mapView.repaint(); 157 158 } 158 159 … … 223 224 MapView.addZoomChangeListener(this); 224 225 if (!MODAL) { 225 Main .map.mapView.addTemporaryLayer(this);226 Main .map.mapView.repaint();226 MainApplication.getMap().mapView.addTemporaryLayer(this); 227 MainApplication.getMap().mapView.repaint(); 227 228 } 228 229 setVisible(true); … … 252 253 if (!MODAL) { 253 254 if (closeDialog) { 254 Main .map.mapView.removeTemporaryLayer(this);255 Main .map.mapView.repaint();255 MainApplication.getMap().mapView.removeTemporaryLayer(this); 256 MainApplication.getMap().mapView.repaint(); 256 257 } 257 258 if (selectedOffset != null) { … … 273 274 ImageryOffsetTools.applyLayerOffset(layer, (ImageryOffset) selectedOffset); 274 275 ImageryOffsetWatcher.getInstance().markGood(); 275 Main .map.repaint();276 MainApplication.getMap().repaint(); 276 277 if (!Main.pref.getBoolean("iodb.offset.message", false)) { 277 278 JOptionPane.showMessageDialog(Main.parent, … … 284 285 } else if (selectedOffset instanceof CalibrationObject) { 285 286 CalibrationLayer clayer = new CalibrationLayer((CalibrationObject) selectedOffset); 286 Main.getLayerManager().addLayer(clayer); 287 MainApplication.getLayerManager().addLayer(clayer); 287 288 clayer.panToCenter(); 288 289 if (!Main.pref.getBoolean("iodb.calibration.message", false)) { -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetInfoAction.java
r32528 r33547 13 13 14 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.gui.MainApplication; 15 16 import org.openstreetmap.josm.tools.ImageProvider; 17 import org.openstreetmap.josm.tools.Logging; 16 18 17 19 /** … … 61 63 SimpleOffsetQueryTask reportTask = 62 64 new SimpleOffsetQueryTask(query, tr("Reporting the offset...")); 63 Main.worker.submit(reportTask); 65 MainApplication.worker.submit(reportTask); 64 66 } catch (UnsupportedEncodingException ex) { 65 Main.error(ex);67 Logging.error(ex); 66 68 } 67 69 } -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/StoreImageryOffsetAction.java
r33309 r33547 20 20 import org.openstreetmap.josm.data.osm.Way; 21 21 import org.openstreetmap.josm.gui.JosmUserIdentityManager; 22 import org.openstreetmap.josm.gui.MainApplication; 22 23 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 24 import org.openstreetmap.josm.tools.Logging; 23 25 24 26 /** … … 49 51 @Override 50 52 public void actionPerformed(ActionEvent e) { 51 if ( Main.map == null || Main.map.mapView == null)53 if (!MainApplication.isDisplayingMapView()) 52 54 return; 53 55 … … 126 128 query.append(key).append('=').append(URLEncoder.encode(params.get(key), "UTF8")); 127 129 } 128 Main.worker.submit(new SimpleOffsetQueryTask(query.toString(), tr("Uploading a new offset..."))); 130 MainApplication.worker.submit(new SimpleOffsetQueryTask(query.toString(), tr("Uploading a new offset..."))); 129 131 } catch (UnsupportedEncodingException ex) { 130 Main.error(ex);132 Logging.error(ex); 131 133 } 132 134 } … … 167 169 protected void updateEnabledState() { 168 170 boolean state = true; 169 if ( Main.map == null || Main.map.mapView == null|| !Main.map.isVisible())171 if (!MainApplication.isDisplayingMapView() || !MainApplication.getMap().isVisible()) 170 172 state = false; 171 173 if (ImageryOffsetTools.getTopImageryLayer() == null)
Note:
See TracChangeset
for help on using the changeset viewer.