Changeset 24672 in osm for applications/editors/josm
- Timestamp:
- 2010-12-09T23:04:59+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryAdjustAction.java
r24670 r24672 38 38 public ImageryAdjustAction(ImageryLayer layer) { 39 39 super(tr("New offset"), "adjustimg", 40 tr("Adjust the position of th e selectedimagery layer"), Main.map,40 tr("Adjust the position of this imagery layer"), Main.map, 41 41 cursor); 42 42 this.layer = layer; … … 86 86 double dx = layer.getDx()+eastNorth.east()-prevEastNorth.east(); 87 87 double dy = layer.getDy()+eastNorth.north()-prevEastNorth.north(); 88 layer.setOffset(dx, dy); 88 89 if (offsetDialog != null) { 89 offsetDialog.easting.setValue(dx); 90 offsetDialog.northing.setValue(dy); 90 offsetDialog.updateOffset(); 91 91 } 92 Main.map.repaint(); 92 93 prevEastNorth = eastNorth; 93 94 } … … 108 109 109 110 class ImageryOffsetDialog extends ExtendedDialog implements PropertyChangeListener { 110 public final JFormattedTextField easting = new JFormattedTextField(new DecimalFormat("0.0000 E0"));111 public final JFormattedTextField northing = new JFormattedTextField(new DecimalFormat("0.0000 E0"));111 public final JFormattedTextField easting = new JFormattedTextField(new DecimalFormat("0.00000E0")); 112 public final JFormattedTextField northing = new JFormattedTextField(new DecimalFormat("0.00000E0")); 112 113 JTextField tBookmarkName = new JTextField(); 114 private boolean ignoreListener; 113 115 public ImageryOffsetDialog() { 114 116 super(Main.parent, … … 116 118 new String[] { tr("OK"),tr("Cancel") }, 117 119 false); 118 setButtonIcons(new String[] { " mapmode/adjustimg", "cancel" });120 setButtonIcons(new String[] { "ok", "cancel" }); 119 121 contentInsets = new Insets(15, 15, 5, 15); 120 122 JPanel pnl = new JPanel(); … … 138 140 @Override 139 141 public void propertyChange(PropertyChangeEvent evt) { 142 if (ignoreListener) return; 140 143 layer.setOffset(((Number)easting.getValue()).doubleValue(), ((Number)northing.getValue()).doubleValue()); 141 144 Main.map.repaint(); 145 } 146 147 public void updateOffset() { 148 ignoreListener = true; 149 easting.setValue(layer.getDx()); 150 northing.setValue(layer.getDy()); 151 ignoreListener = false; 142 152 } 143 153 … … 156 166 OffsetBookmark.saveBookmarks(); 157 167 } 168 ImageryPlugin.instance.refreshOffsetMenu(); 158 169 Main.map.selectSelectTool(false); 159 170 } -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryLayer.java
r24670 r24672 4 4 5 5 import java.awt.Component; 6 import java.awt.Container; 6 7 import java.awt.Toolkit; 7 8 import java.awt.event.ActionEvent; … … 110 111 111 112 @Override 112 public void actionPerformed(ActionEvent arg0) {113 public void actionPerformed(ActionEvent ev) { 113 114 setOffset(b.dx, b.dy); 114 115 Main.map.repaint(); 116 if (!(ev.getSource() instanceof Component)) return; 117 Component source = (Component)ev.getSource(); 118 if (!(source.getParent() instanceof Container)) return; 119 Container m = source.getParent(); 120 for (Component c : m.getComponents()) { 121 if (c instanceof JCheckBoxMenuItem && c != source) { 122 ((JCheckBoxMenuItem)c).setSelected(false); 123 } 124 } 115 125 } 116 126 } -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPlugin.java
r24670 r24672 4 4 import static org.openstreetmap.josm.tools.I18n.marktr; 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 import static org.openstreetmap.josm.tools.I18n.trc; 7 8 import java.awt.Component; 7 9 import java.awt.event.ActionEvent; 8 10 import java.awt.event.KeyEvent; … … 10 12 import java.lang.reflect.InvocationTargetException; 11 13 import java.lang.reflect.Method; 14 import java.util.List; 12 15 13 16 import javax.swing.JMenu; … … 20 23 import org.openstreetmap.josm.gui.MainMenu; 21 24 import org.openstreetmap.josm.gui.MapFrame; 25 import org.openstreetmap.josm.gui.MapView; 26 import org.openstreetmap.josm.gui.MapView.LayerChangeListener; 22 27 import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser; 28 import org.openstreetmap.josm.gui.layer.Layer; 23 29 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 24 30 import org.openstreetmap.josm.plugins.Plugin; … … 32 38 import org.openstreetmap.josm.plugins.imagery.wms.io.WMSLayerExporter; 33 39 import org.openstreetmap.josm.plugins.imagery.wms.io.WMSLayerImporter; 34 35 public class ImageryPlugin extends Plugin { 40 import org.openstreetmap.josm.tools.ImageProvider; 41 42 public class ImageryPlugin extends Plugin implements LayerChangeListener { 36 43 37 44 JMenu imageryJMenu; 45 JMenu offsetJMenu = new JMenu(trc("layer","Offset")); 38 46 39 47 public static ImageryPlugin instance; … … 209 217 initRemoteControl(); 210 218 SlippyMapBBoxChooser.addTileSourceProvider(new TMSTileSourceProvider()); 219 220 offsetJMenu.setIcon(ImageProvider.get("imagery_menu")); 221 refreshOffsetMenu(); 222 MapView.addLayerChangeListener(this); 211 223 } 212 224 … … 232 244 imageryJMenu.add(new JMenuItem(new Map_Rectifier_WMSmenuAction())); 233 245 246 imageryJMenu.addSeparator(); 247 imageryJMenu.add(offsetJMenu); 234 248 imageryJMenu.addSeparator(); 235 249 imageryJMenu.add(new JMenuItem(new … … 243 257 } 244 258 259 public void refreshOffsetMenu() { 260 offsetJMenu.removeAll(); 261 if (Main.map == null || Main.map.mapView == null) { 262 offsetJMenu.setEnabled(false); 263 return; 264 } 265 List<ImageryLayer> layers = Main.map.mapView.getLayersOfType(ImageryLayer.class); 266 if (layers.isEmpty()) { 267 offsetJMenu.setEnabled(false); 268 return; 269 } 270 offsetJMenu.setEnabled(true); 271 if (layers.size() == 1) { 272 for (Component c : layers.get(0).getOffsetMenu()) { 273 offsetJMenu.add(c); 274 } 275 return; 276 } 277 for (ImageryLayer layer : layers) { 278 JMenu subMenu = new JMenu(layer.getName()); 279 subMenu.setIcon(layer.getIcon()); 280 for (Component c : layer.getOffsetMenu()) { 281 subMenu.add(c); 282 } 283 offsetJMenu.add(subMenu); 284 } 285 } 286 245 287 private void setEnabledAll(boolean isEnabled) { 246 288 for(int i=0; i < imageryJMenu.getItemCount(); i++) { … … 259 301 setEnabledAll(false); 260 302 } 303 refreshOffsetMenu(); 261 304 } 262 305 … … 271 314 return new File(Main.pref.getPluginsDirectory(), "imagery").getPath(); 272 315 } 316 317 @Override 318 public void activeLayerChange(Layer oldLayer, Layer newLayer) { 319 } 320 321 @Override 322 public void layerAdded(Layer newLayer) { 323 if (newLayer instanceof ImageryLayer) { 324 refreshOffsetMenu(); 325 } 326 } 327 328 @Override 329 public void layerRemoved(Layer oldLayer) { 330 if (oldLayer instanceof ImageryLayer) { 331 refreshOffsetMenu(); 332 } 333 } 273 334 } -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/ImageryPreferenceEditor.java
r24620 r24672 228 228 plugin.info.save(); 229 229 plugin.refreshMenu(); 230 plugin.refreshOffsetMenu(); 230 231 OffsetBookmark.saveBookmarks(); 231 232 -
applications/editors/josm/plugins/imagery/src/org/openstreetmap/josm/plugins/imagery/tms/TMSTileSourceProvider.java
r24650 r24672 20 20 // Urls that already exist in the slippymap chooser 21 21 existingSlippyMapUrls.add("http://tile.openstreetmap.org/"); 22 existingSlippyMapUrls.add("http://tah.openstreetmap.org/Tiles/ ");22 existingSlippyMapUrls.add("http://tah.openstreetmap.org/Tiles/tile/"); 23 23 existingSlippyMapUrls.add("http://tile.opencyclemap.org/cycle/"); 24 24 }
Note:
See TracChangeset
for help on using the changeset viewer.