Changeset 22551 in osm
- Timestamp:
- 2010-08-03T08:23:15+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/photo_geotagging
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/photo_geotagging/build.xml
r22535 r22551 27 27 <property name="commit.message" value="update to josm latest; only recompile (setCancelButton)" /> 28 28 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 29 <property name="plugin.main.version" value="340 3" />29 <property name="plugin.main.version" value="3408" /> 30 30 31 31 … … 148 148 149 149 <!-- 150 ************************** Publishing the plugin *********************************** 150 ************************** Publishing the plugin *********************************** 151 151 --> 152 152 <!-- 153 ** extracts the JOSM release for the JOSM version in ../core and saves it in the 153 ** extracts the JOSM release for the JOSM version in ../core and saves it in the 154 154 ** property ${coreversion.info.entry.revision} 155 155 ** … … 200 200 201 201 <!-- 202 ** commits the plugin.jar 202 ** commits the plugin.jar 203 203 --> 204 204 <target name="commit-dist"> 205 205 <echo> 206 206 ***** Properties of published ${plugin.jar} ***** 207 Commit message : '${commit.message}' 207 Commit message : '${commit.message}' 208 208 Plugin-Mainversion: ${plugin.main.version} 209 209 JOSM build version: ${coreversion.info.entry.revision} 210 210 Plugin-Version : ${version.entry.commit.revision} 211 ***** / Properties of published ${plugin.jar} ***** 212 211 ***** / Properties of published ${plugin.jar} ***** 212 213 213 Now commiting ${plugin.jar} ... 214 214 </echo> -
applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingAction.java
r19873 r22551 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 6 import java.awt.Component; 6 7 import java.awt.Dimension; 7 8 import java.awt.GridBagLayout; 8 9 import java.awt.event.ActionEvent; 9 10 import java.awt.event.ActionListener; 10 11 import java.io.File; 11 12 import java.io.IOException; 12 import java.io.File; 13 13 import java.text.DecimalFormat; 14 14 import java.util.ArrayList; 15 15 import java.util.List; 16 16 17 import javax.swing.AbstractAction; 17 18 import javax.swing.BorderFactory; 18 19 import javax.swing.DefaultListModel; … … 21 22 import javax.swing.JLabel; 22 23 import javax.swing.JList; 24 import javax.swing.JMenuItem; 23 25 import javax.swing.JOptionPane; 24 26 import javax.swing.JPanel; … … 27 29 import javax.swing.UIManager; 28 30 29 import java.text.DecimalFormat;30 31 31 import org.openstreetmap.josm.Main; 32 32 import org.openstreetmap.josm.gui.ExtendedDialog; 33 33 import org.openstreetmap.josm.gui.PleaseWaitRunnable; 34 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 35 import org.openstreetmap.josm.gui.layer.Layer; 36 import org.openstreetmap.josm.gui.layer.Layer.LayerAction; 34 37 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer; 35 38 import org.openstreetmap.josm.gui.layer.geoimage.ImageEntry; 36 39 import org.openstreetmap.josm.tools.GBC; 40 import org.openstreetmap.josm.tools.ImageProvider; 37 41 38 42 /** 39 43 * The action to aks the user for confirmation and then do the tagging. 40 44 */ 41 class GeotaggingAction implements ActionListener{45 class GeotaggingAction extends AbstractAction implements LayerAction { 42 46 final static boolean debug = false; 43 47 final static String KEEP_BACKUP = "plugins.photo_geotagging.keep_backup"; … … 45 49 final static int MTIME_MODE_PREVIOUS_VALUE = 2; 46 50 47 final private GeoImageLayer layer; 48 public GeotaggingAction(GeoImageLayer layer) { 49 this.layer = layer; 51 public GeotaggingAction() { 52 super(tr("Write coordinates to image header"), ImageProvider.get("geotagging")); 50 53 } 51 54 52 55 public void actionPerformed(ActionEvent arg0) { 56 57 GeoImageLayer layer = getLayer(); 58 53 59 final List<ImageEntry> images = new ArrayList<ImageEntry>(); 54 60 for (ImageEntry e : layer.getImages()) { … … 125 131 } 126 132 127 class GeoTaggingRunnable extends PleaseWaitRunnable {133 static class GeoTaggingRunnable extends PleaseWaitRunnable { 128 134 final private List<ImageEntry> images; 129 135 final private boolean keep_backup; … … 164 170 testMTimeReadAndWrite(e.getFile()); 165 171 } 166 172 167 173 Long mTime = null; 168 174 if (mTimeMode == MTIME_MODE_PREVIOUS_VALUE) { … … 281 287 } 282 288 } 283 289 284 290 boolean testMTimeReadAndWriteDone = false; 285 291 286 292 private void testMTimeReadAndWrite(File file) throws IOException { 287 293 if (testMTimeReadAndWriteDone) // do this only once … … 308 314 } 309 315 } 316 317 private GeoImageLayer getLayer() { 318 return (GeoImageLayer)LayerListDialog.getInstance().getModel().getSelectedLayers().get(0); 319 } 320 321 /** 322 * Check if there is any suitable image. 323 */ 324 private boolean enabled(GeoImageLayer layer) { 325 for (ImageEntry e : layer.getImages()) { 326 if (e.getPos() != null && e.getGpsTime() != null) 327 return true; 328 } 329 return false; 330 } 331 332 public Component createMenuComponent() { 333 JMenuItem geotaggingItem = new JMenuItem(this); 334 geotaggingItem.setEnabled(enabled(getLayer())); 335 return geotaggingItem; 336 } 337 338 public boolean supportLayers(List<Layer> layers) { 339 return layers.size() == 1 && layers.get(0) instanceof GeoImageLayer; 340 } 310 341 } -
applications/editors/josm/plugins/photo_geotagging/src/org/openstreetmap/josm/plugins/photo_geotagging/GeotaggingPlugin.java
r19845 r22551 2 2 package org.openstreetmap.josm.plugins.photo_geotagging; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 6 import java.awt.Component;7 8 import javax.swing.JMenuItem;9 10 import org.openstreetmap.josm.gui.layer.Layer;11 4 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer; 12 import org.openstreetmap.josm.gui.layer.geoimage.ImageEntry;13 5 import org.openstreetmap.josm.plugins.Plugin; 14 6 import org.openstreetmap.josm.plugins.PluginInformation; 15 import org.openstreetmap.josm.tools.ImageProvider;16 7 17 8 /** … … 27 18 public GeotaggingPlugin(PluginInformation info) { 28 19 super(info); 29 GeoImageLayer.registerMenuAddition(new Geotagging MenuAddition());20 GeoImageLayer.registerMenuAddition(new GeotaggingAction()); 30 21 } 31 22 32 /**33 * Adds a menu entry to the right click menu of each geoimage layer.34 */35 class GeotaggingMenuAddition implements GeoImageLayer.LayerMenuAddition {36 public Component getComponent(Layer layer) {37 JMenuItem geotaggingItem = new JMenuItem(tr("Write coordinates to image header"), ImageProvider.get("geotagging"));;38 geotaggingItem.addActionListener(new GeotaggingAction((GeoImageLayer) layer));39 geotaggingItem.setEnabled(enabled((GeoImageLayer) layer));40 return geotaggingItem;41 }42 43 /**44 * Check if there is any suitable image.45 */46 private boolean enabled(GeoImageLayer layer) {47 for (ImageEntry e : layer.getImages()) {48 if (e.getPos() != null && e.getGpsTime() != null)49 return true;50 }51 return false;52 }53 }54 23 }
Note:
See TracChangeset
for help on using the changeset viewer.