Changeset 34466 in osm for applications/editors/josm
- Timestamp:
- 2018-08-15T02:05:27+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/imagery_offset_db
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery_offset_db/build.xml
r34209 r34466 5 5 <property name="commit.message" value="Imagery Offset Database"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="1 3797"/>7 <property name="plugin.main.version" value="14153"/> 8 8 <property name="plugin.canloadatruntime" value="true"/> 9 9 -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/DeprecateOffsetAction.java
r33774 r34466 11 11 import javax.swing.JOptionPane; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.data.UserIdentityManager; 15 14 import org.openstreetmap.josm.gui.MainApplication; … … 51 50 tr("Are you sure this imagery offset is wrong?") : 52 51 tr("Are you sure this calibration geometry is aligned badly?"); 53 if (JOptionPane.showConfirmDialog(Main .parent,52 if (JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), 54 53 tr("Warning: deprecation is basically irreversible!")+ "\n" + desc, 55 54 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE) != JOptionPane.YES_OPTION) { … … 81 80 String userName = UserIdentityManager.getInstance().getUserName(); 82 81 if (userName == null) { 83 JOptionPane.showMessageDialog(Main .parent, tr("To store imagery offsets you must be a registered OSM user."),82 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("To store imagery offsets you must be a registered OSM user."), 84 83 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.ERROR_MESSAGE); 85 84 return; -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/GetImageryOffsetAction.java
r33774 r34466 16 16 import javax.swing.JOptionPane; 17 17 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.actions.JosmAction; 20 19 import org.openstreetmap.josm.data.coor.LatLon; … … 23 22 import org.openstreetmap.josm.gui.MainApplication; 24 23 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 24 import org.openstreetmap.josm.spi.preferences.Config; 25 25 import org.openstreetmap.josm.tools.ImageProvider; 26 26 import org.openstreetmap.josm.tools.Shortcut; … … 90 90 private void showOffsetDialog(List<ImageryOffsetBase> offsets) { 91 91 if (offsets.isEmpty()) { 92 JOptionPane.showMessageDialog(Main .parent,92 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 93 93 tr("No data for this region. Please adjust imagery layer and upload an offset."), 94 94 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE); … … 137 137 + "&lon=" + DecimalDegreesCoordinateFormat.INSTANCE.lonToString(center) 138 138 + "&imagery=" + URLEncoder.encode(imagery, "UTF8"); 139 int radius = Main.pref.getInt("iodb.radius", -1);139 int radius = Config.getPref().getInt("iodb.radius", -1); 140 140 if (radius > 0) 141 141 query = query + "&radius=" + radius; -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetPlugin.java
r33774 r34466 10 10 import javax.swing.JMenu; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.Version; 14 13 import org.openstreetmap.josm.gui.MainApplication; … … 16 15 import org.openstreetmap.josm.plugins.Plugin; 17 16 import org.openstreetmap.josm.plugins.PluginInformation; 17 import org.openstreetmap.josm.spi.preferences.Config; 18 18 19 19 /** … … 49 49 50 50 // an ugly hack to add this plugin to the toolbar 51 if ( Main.pref.getBoolean("iodb.modify.toolbar", true)) {51 if (Config.getPref().getBoolean("iodb.modify.toolbar", true)) { 52 52 List<String> toolbar = new LinkedList<>(ToolbarPreferences.getToolString()); 53 53 if (!toolbar.contains("getoffset")) { 54 54 toolbar.add("getoffset"); 55 Main.pref.putList("toolbar", toolbar);55 Config.getPref().putList("toolbar", toolbar); 56 56 MainApplication.getToolbar().refreshToolbarControl(); 57 57 } 58 Main.pref.putBoolean("iodb.modify.toolbar", false);58 Config.getPref().putBoolean("iodb.modify.toolbar", false); 59 59 } 60 60 } -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetTools.java
r34209 r34466 7 7 import java.util.List; 8 8 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.data.coor.EastNorth; 11 10 import org.openstreetmap.josm.data.coor.LatLon; 12 11 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 13 12 import org.openstreetmap.josm.data.projection.Projection; 13 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 14 14 import org.openstreetmap.josm.gui.MainApplication; 15 15 import org.openstreetmap.josm.gui.MapView; … … 54 54 */ 55 55 public static LatLon getMapCenter() { 56 Projection proj = Main.getProjection();56 Projection proj = ProjectionRegistry.getProjection(); 57 57 return !MainApplication.isDisplayingMapView() 58 58 ? new LatLon(0, 0) : proj.eastNorth2latlon(MainApplication.getMap().mapView.getCenter()); … … 67 67 */ 68 68 public static LatLon getLayerOffset(AbstractTileSourceLayer layer, LatLon center) { 69 Projection proj = Main.getProjection();69 Projection proj = ProjectionRegistry.getProjection(); 70 70 EastNorth offsetCenter = MainApplication.getMap().mapView.getCenter(); 71 71 EastNorth centerOffset = offsetCenter.add(-layer.getDisplaySettings().getDx(), … … 91 91 */ 92 92 public static OffsetBookmark calculateOffset(ImageryOffset offset) { 93 Projection proj = Main.getProjection();93 Projection proj = ProjectionRegistry.getProjection(); 94 94 EastNorth center = proj.latlon2eastNorth(offset.getPosition()); 95 95 EastNorth offsetPos = proj.latlon2eastNorth(offset.getImageryPos()); -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetWatcher.java
r34209 r34466 11 11 import java.util.TreeMap; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.data.coor.LatLon; 15 14 import org.openstreetmap.josm.data.imagery.OffsetBookmark; 15 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 16 16 import org.openstreetmap.josm.gui.MainApplication; 17 17 import org.openstreetmap.josm.gui.MapView; … … 26 26 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 27 27 import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings; 28 import org.openstreetmap.josm.spi.preferences.Config; 28 29 import org.openstreetmap.josm.tools.Destroyable; 29 30 … … 49 50 */ 50 51 private ImageryOffsetWatcher() { 51 maxDistance = Main.pref.getDouble("iodb.offset.radius", 15);52 maxDistance = Config.getPref().getDouble("iodb.offset.radius", 15); 52 53 MapView.addZoomChangeListener(this); 53 54 MainApplication.getLayerManager().addLayerChangeListener(this); … … 224 225 private void storeLayerOffset(AbstractTileSourceLayer<?> layer) { 225 226 String id = ImageryOffsetTools.getImageryID(layer); 226 if (! Main.pref.getBoolean("iodb.remember.offsets", true) || id == null)227 return; 228 List<String> offsets = new LinkedList<>( Main.pref.getList("iodb.stored.offsets"));227 if (!Config.getPref().getBoolean("iodb.remember.offsets", true) || id == null) 228 return; 229 List<String> offsets = new LinkedList<>(Config.getPref().getList("iodb.stored.offsets")); 229 230 for (Iterator<String> iter = offsets.iterator(); iter.hasNext();) { 230 231 String[] offset = iter.next().split(":"); … … 235 236 offsets.add(id + ":" + center.lat() + ":" + center.lon() + ":" + 236 237 layer.getDisplaySettings().getDx() + ":" + layer.getDisplaySettings().getDy()); 237 Main.pref.putList("iodb.stored.offsets", offsets);238 Config.getPref().putList("iodb.stored.offsets", offsets); 238 239 } 239 240 … … 243 244 private void loadLayerOffset(AbstractTileSourceLayer<?> layer) { 244 245 String id = ImageryOffsetTools.getImageryID(layer); 245 if (! Main.pref.getBoolean("iodb.remember.offsets", true) || id == null)246 return; 247 List<String> offsets = Main.pref.getList("iodb.stored.offsets");246 if (!Config.getPref().getBoolean("iodb.remember.offsets", true) || id == null) 247 return; 248 List<String> offsets = Config.getPref().getList("iodb.stored.offsets"); 248 249 for (String offset : offsets) { 249 250 String[] parts = offset.split(":"); … … 260 261 if (lastPos.greatCircleDistance(ImageryOffsetTools.getMapCenter()) < Math.max(maxDistance, 3.0) * 1000) { 261 262 // apply offset 262 OffsetBookmark bookmark = new OffsetBookmark( Main.getProjection().toCode(),263 OffsetBookmark bookmark = new OffsetBookmark(ProjectionRegistry.getProjection().toCode(), 263 264 null, layer.getName(), "Restored", dparts[2], dparts[3]); 264 265 layer.getDisplaySettings().setOffsetBookmark(bookmark); … … 278 279 @Override 279 280 public void run() { 280 maxDistance = Main.pref.getDouble("iodb.offset.radius", 15);281 maxDistance = Config.getPref().getDouble("iodb.offset.radius", 15); 281 282 checkOffset(); 282 283 } -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java
r34095 r34466 35 35 import javax.swing.border.EmptyBorder; 36 36 37 import org.openstreetmap.josm.Main;38 37 import org.openstreetmap.josm.data.Bounds; 39 38 import org.openstreetmap.josm.data.UserIdentityManager; … … 43 42 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 44 43 import org.openstreetmap.josm.gui.layer.MapViewPaintable; 44 import org.openstreetmap.josm.spi.preferences.Config; 45 45 import org.openstreetmap.josm.tools.HttpClient; 46 46 import org.openstreetmap.josm.tools.ImageProvider; … … 57 57 protected static final String PREF_CALIBRATION = "iodb.show.calibration"; 58 58 protected static final String PREF_DEPRECATED = "iodb.show.deprecated"; 59 private static final int MAX_OFFSETS = Main.pref.getInt("iodb.max.offsets", 4);59 private static final int MAX_OFFSETS = Config.getPref().getInt("iodb.max.offsets", 4); 60 60 61 61 /** … … 75 75 */ 76 76 public OffsetDialog(List<ImageryOffsetBase> offsets) { 77 super(JOptionPane.getFrameForComponent(Main .parent), ImageryOffsetTools.DIALOG_TITLE,77 super(JOptionPane.getFrameForComponent(MainApplication.getMainFrame()), ImageryOffsetTools.DIALOG_TITLE, 78 78 MODAL ? ModalityType.DOCUMENT_MODAL : ModalityType.MODELESS); 79 79 setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); … … 93 93 updateButtonPanel(); 94 94 final JCheckBox calibrationBox = new JCheckBox(tr("Calibration geometries")); 95 calibrationBox.setSelected( Main.pref.getBoolean(PREF_CALIBRATION, true));95 calibrationBox.setSelected(Config.getPref().getBoolean(PREF_CALIBRATION, true)); 96 96 calibrationBox.addActionListener(new ActionListener() { 97 97 @Override 98 98 public void actionPerformed(ActionEvent e) { 99 Main.pref.putBoolean(PREF_CALIBRATION, calibrationBox.isSelected());99 Config.getPref().putBoolean(PREF_CALIBRATION, calibrationBox.isSelected()); 100 100 updateButtonPanel(); 101 101 } 102 102 }); 103 103 final JCheckBox deprecatedBox = new JCheckBox(tr("Deprecated offsets")); 104 deprecatedBox.setSelected( Main.pref.getBoolean(PREF_DEPRECATED, false));104 deprecatedBox.setSelected(Config.getPref().getBoolean(PREF_DEPRECATED, false)); 105 105 deprecatedBox.addActionListener(new ActionListener() { 106 106 @Override 107 107 public void actionPerformed(ActionEvent e) { 108 Main.pref.putBoolean(PREF_DEPRECATED, deprecatedBox.isSelected());108 Config.getPref().putBoolean(PREF_DEPRECATED, deprecatedBox.isSelected()); 109 109 updateButtonPanel(); 110 110 } … … 128 128 setContentPane(dialog); 129 129 pack(); 130 setLocationRelativeTo(Main .parent);130 setLocationRelativeTo(MainApplication.getMainFrame()); 131 131 } 132 132 … … 163 163 */ 164 164 private List<ImageryOffsetBase> filterOffsets() { 165 boolean showCalibration = Main.pref.getBoolean(PREF_CALIBRATION, true);166 boolean showDeprecated = Main.pref.getBoolean(PREF_DEPRECATED, false);165 boolean showCalibration = Config.getPref().getBoolean(PREF_CALIBRATION, true); 166 boolean showDeprecated = Config.getPref().getBoolean(PREF_DEPRECATED, false); 167 167 List<ImageryOffsetBase> filteredOffsets = new ArrayList<>(); 168 168 for (ImageryOffsetBase offset : offsets) { … … 246 246 boolean closeDialog = MODAL || selectedOffset == null 247 247 || selectedOffset instanceof CalibrationObject 248 || Main.pref.getBoolean("iodb.close.on.select", true);248 || Config.getPref().getBoolean("iodb.close.on.select", true); 249 249 if (closeDialog) { 250 250 MapView.removeZoomChangeListener(this); … … 275 275 ImageryOffsetWatcher.getInstance().markGood(); 276 276 MainApplication.getMap().repaint(); 277 if (! Main.pref.getBoolean("iodb.offset.message", false)) {278 JOptionPane.showMessageDialog(Main .parent,277 if (!Config.getPref().getBoolean("iodb.offset.message", false)) { 278 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 279 279 tr("The topmost imagery layer has been shifted to presumably match\n" 280 280 + "OSM data in the area. Please check that the offset is still valid\n" 281 281 + "by downloading GPS tracks and comparing them and OSM data to the imagery."), 282 282 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE); 283 Main.pref.putBoolean("iodb.offset.message", true);283 Config.getPref().putBoolean("iodb.offset.message", true); 284 284 } 285 285 } else if (selectedOffset instanceof CalibrationObject) { … … 287 287 MainApplication.getLayerManager().addLayer(clayer); 288 288 clayer.panToCenter(); 289 if (! Main.pref.getBoolean("iodb.calibration.message", false)) {290 JOptionPane.showMessageDialog(Main .parent,289 if (!Config.getPref().getBoolean("iodb.calibration.message", false)) { 290 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 291 291 tr("A layer has been added with a calibration geometry. Hide data layers,\n" 292 292 + "find the corresponding feature on the imagery layer and move it accordingly."), 293 293 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE); 294 Main.pref.putBoolean("iodb.calibration.message", true);294 Config.getPref().putBoolean("iodb.calibration.message", true); 295 295 } 296 296 } … … 332 332 @Override 333 333 public void actionPerformed(ActionEvent e) { 334 String base = Main.pref.get("url.openstreetmap-wiki", "https://wiki.openstreetmap.org/wiki/");334 String base = Config.getPref().get("url.openstreetmap-wiki", "https://wiki.openstreetmap.org/wiki/"); 335 335 String lang = LanguageInfo.getWikiLanguagePrefix(); 336 336 String page = "Imagery_Offset_Database"; -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialogButton.java
r34337 r34466 24 24 import javax.swing.SwingConstants; 25 25 26 import org.openstreetmap.josm.Main;27 26 import org.openstreetmap.josm.data.coor.EastNorth; 28 27 import org.openstreetmap.josm.data.coor.LatLon; 29 28 import org.openstreetmap.josm.data.projection.Projection; 29 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 30 30 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer; 31 31 import org.openstreetmap.josm.tools.ImageProvider; … … 140 140 */ 141 141 public static double[] getLengthAndDirection(ImageryOffset offset, double dx, double dy) { 142 Projection proj = Main.getProjection();142 Projection proj = ProjectionRegistry.getProjection(); 143 143 EastNorth pos = proj.latlon2eastNorth(offset.getPosition()); 144 144 LatLon correctedCenterLL = proj.eastNorth2latlon(pos.add(-dx, -dy)); -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetInfoAction.java
r33547 r34466 12 12 import javax.swing.JOptionPane; 13 13 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.gui.MainApplication; 16 15 import org.openstreetmap.josm.tools.ImageProvider; … … 47 46 Object info = offset == null ? null : getInformationObject(offset); 48 47 if (offset.isFlagged()) 49 JOptionPane.showMessageDialog(Main .parent, info, ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE);48 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), info, ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE); 50 49 else { 51 int result = JOptionPane.showOptionDialog(Main .parent, info, ImageryOffsetTools.DIALOG_TITLE,50 int result = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), info, ImageryOffsetTools.DIALOG_TITLE, 52 51 JOptionPane.DEFAULT_OPTION, JOptionPane.PLAIN_MESSAGE, null, 53 52 new String[] {"OK", tr("Report this offset")}, null); 54 53 if (result == 1) { 55 54 // ask for a reason 56 Object reason = JOptionPane.showInputDialog(Main .parent,55 Object reason = JOptionPane.showInputDialog(MainApplication.getMainFrame(), 57 56 tr("You are to notify moderators of this offset. Why?"), 58 57 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE); -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/SimpleOffsetQueryTask.java
r34337 r34466 16 16 import javax.swing.JOptionPane; 17 17 18 import org.openstreetmap.josm. Main;18 import org.openstreetmap.josm.gui.MainApplication; 19 19 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 20 import org.openstreetmap.josm.spi.preferences.Config; 20 21 21 22 /** … … 89 90 private void doQuery(String query) throws UploadException, IOException { 90 91 try { 91 String serverURL = Main.pref.get("iodb.server.url", "http://offsets.textual.ru/");92 String serverURL = Config.getPref().get("iodb.server.url", "http://offsets.textual.ru/"); 92 93 URL url = new URL(serverURL + query); 93 94 HttpURLConnection connection = (HttpURLConnection) url.openConnection(); … … 125 126 protected void finish() { 126 127 if (errorMessage != null) { 127 JOptionPane.showMessageDialog(Main .parent, errorMessage,128 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), errorMessage, 128 129 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.ERROR_MESSAGE); 129 130 } else if (listener != null) { -
applications/editors/josm/plugins/imagery_offset_db/src/iodb/StoreImageryOffsetAction.java
r34104 r34466 13 13 import javax.swing.JOptionPane; 14 14 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.actions.JosmAction; 17 16 import org.openstreetmap.josm.data.UserIdentityManager; … … 60 59 String userName = UserIdentityManager.getInstance().getUserName(); 61 60 if (userName == null || userName.length() == 0) { 62 JOptionPane.showMessageDialog(Main .parent,61 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 63 62 tr("To store imagery offsets you must be a registered OSM user."), 64 63 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.ERROR_MESSAGE); … … 77 76 (selection instanceof Node && !((Node) selection).isReferredByWays(1)))) { 78 77 String[] options = new String[] {tr("Store calibration geometry"), tr("Store imagery offset")}; 79 int result = JOptionPane.showOptionDialog(Main .parent,78 int result = JOptionPane.showOptionDialog(MainApplication.getMainFrame(), 80 79 tr("The selected object can be used as a calibration geometry. What do you intend to do?"), 81 80 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, … … 95 94 // register imagery offset 96 95 if (Math.abs(layer.getDisplaySettings().getDx()) < 1e-8 && Math.abs(layer.getDisplaySettings().getDy()) < 1e-8) { 97 if (JOptionPane.showConfirmDialog(Main .parent,96 if (JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), 98 97 tr("The topmost imagery layer has no offset. Are you sure you want to upload this?"), 99 98 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) … … 146 145 boolean ok = false; 147 146 while (!ok) { 148 Object result = JOptionPane.showInputDialog(Main .parent, message,147 Object result = JOptionPane.showInputDialog(MainApplication.getMainFrame(), message, 149 148 ImageryOffsetTools.DIALOG_TITLE, JOptionPane.PLAIN_MESSAGE, null, null, reason); 150 149 if (result == null || result.toString().length() == 0) {
Note:
See TracChangeset
for help on using the changeset viewer.