Changeset 33757 in osm
- Timestamp:
- 2017-10-31T19:52:56+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java
r33745 r33757 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.photoadjust; 2 3 … … 43 44 private MouseMotionAdapter mouseMotionAdapter; 44 45 private IconToggleButton mmButton; 45 private PhotoAdjustWorker worker;46 private final PhotoAdjustWorker worker; 46 47 /** True if one existing GeoImageLayer is to be ignored. */ 47 48 private boolean ignoreOneGILayer = false; 48 49 50 /** 51 * Initialize photo adjust map mode. 52 * 53 * @param worker Worker that does the actual work. 54 */ 49 55 public PhotoAdjustMapMode(PhotoAdjustWorker worker) { 50 56 super(tr("Adjust photos"), "photoadjust.png", … … 79 85 if (hasLayersToAdjust()) { 80 86 return tr("Click+drag photo, shift+click to position photo, control+click to set direction."); 81 } 82 else { 87 } else { 83 88 return tr("Please load some photos."); 84 89 } … … 183 188 @Override 184 189 public void layerOrderChanged(LayerOrderChangeEvent e) { 190 // Nothing to do at layer order change. 185 191 } 186 192 … … 234 240 * @return list of visible GeoImageLayer's 235 241 */ 236 private List<GeoImageLayer> getVisibleGeoImageLayers() {242 private static List<GeoImageLayer> getVisibleGeoImageLayers() { 237 243 List<GeoImageLayer> all = new ArrayList<>(MainApplication.getLayerManager().getLayersOfType(GeoImageLayer.class)); 238 244 Iterator<GeoImageLayer> it = all.iterator(); -
applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustPlugin.java
r33745 r33757 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.photoadjust; 2 3 … … 23 24 public class PhotoAdjustPlugin extends Plugin implements ActiveLayerChangeListener { 24 25 25 private GeoImageLayer imageLayer = null;26 private MouseAdapter mouseAdapter = null;27 private MouseMotionAdapter mouseMotionAdapter = null;28 p ublic PhotoAdjustWorker worker = null;26 private GeoImageLayer imageLayer; 27 private MouseAdapter mouseAdapter; 28 private MouseMotionAdapter mouseMotionAdapter; 29 private final PhotoAdjustWorker worker = new PhotoAdjustWorker(); 29 30 30 31 /** … … 36 37 super(info); 37 38 GeoImageLayer.registerMenuAddition(new UntaggedGeoImageLayerAction()); 38 new PhotoPropertyEditor(); 39 worker = new PhotoAdjustWorker(); 39 PhotoPropertyEditor.init(); 40 40 initAdapters(); 41 41 } … … 90 90 Layer oldLayer = e.getPreviousActiveLayer(); 91 91 Layer newLayer = MainApplication.getLayerManager().getActiveLayer(); 92 if ( 93 92 if (oldLayer instanceof GeoImageLayer 93 && newLayer instanceof GeoImageLayer) { 94 94 imageLayer = (GeoImageLayer)newLayer; 95 } 96 else { 95 } else { 97 96 if (oldLayer instanceof GeoImageLayer) { 98 97 MainApplication.getMap().mapView.removeMouseListener(mouseAdapter); -
applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustWorker.java
r33745 r33757 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.photoadjust; 2 3 … … 17 18 public class PhotoAdjustWorker { 18 19 19 private ImageEntry dragPhoto = null;20 private GeoImageLayer dragLayer = null;20 private ImageEntry dragPhoto; 21 private GeoImageLayer dragLayer; 21 22 // Offset between center of the photo and point where it is 22 23 // clicked. This must be in pixels to maintain the same offset if 23 24 // the photo is moved very far. 24 private Point2D dragOffset = null;25 private Point2D dragOffset; 25 26 private boolean centerViewIsDisabled = false; 26 27 private boolean centerViewNeedsEnable = false; … … 76 77 77 78 if (evt.getButton() == MouseEvent.BUTTON1 78 && imageLayers != null && imageLayers.size() > 0) {79 && imageLayers != null && !imageLayers.isEmpty()) { 79 80 // Check if modifier key is pressed and change to 80 81 // image viewer photo if it is. … … 84 85 final GeoImageLayer viewerLayer = ImageViewerDialog.getCurrentLayer(); 85 86 final ImageEntry img = ImageViewerDialog.getCurrentImage(); 86 if ( 87 88 87 if (img != null && viewerLayer != null 88 && viewerLayer.isVisible() 89 && imageLayers.contains(viewerLayer)) { 89 90 // Change direction if control is pressed, position 90 91 // otherwise. Shift+control changes direction, similar to … … 107 108 changeDirection(img, viewerLayer, evt); 108 109 } 109 } 110 else { // shift pressed 110 } else { // shift pressed 111 111 movePhoto(img, viewerLayer, evt); 112 112 } … … 114 114 dragLayer = viewerLayer; 115 115 } 116 } 117 else { 116 } else { 118 117 // Start with the top layer. 119 118 for (GeoImageLayer layer: imageLayers) { … … 151 150 */ 152 151 public void doMouseDragged(MouseEvent evt) { 153 if ( 154 152 if (dragLayer != null && dragLayer.isVisible() 153 && dragPhoto != null) { 155 154 if ((evt.getModifiers() & InputEvent.CTRL_MASK) != 0) { 156 155 changeDirection(dragPhoto, dragLayer, evt); 157 } 158 else { 156 } else { 159 157 disableCenterView(); 160 158 movePhoto(dragPhoto, dragLayer, evt); … … 189 187 dragOffset.getX() + evt.getX(), 190 188 dragOffset.getY() + evt.getY()); 191 } 192 else { 189 } else { 193 190 newPos = MainApplication.getMap().mapView.getLatLon(evt.getX(), evt.getY()); 194 191 } -
applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoPropertyEditor.java
r33750 r33757 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.photoadjust; 2 3 3 //import static org.openstreetmap.josm.gui.help.HelpUtil.ht;4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 5 … … 42 42 public class PhotoPropertyEditor { 43 43 44 public PhotoPropertyEditor() { 44 /** 45 * Add photo property editor to edit menu. 46 */ 47 public static void init() { 45 48 MainMenu.add(MainApplication.getMenu().editMenu, new PropertyEditorAction()); 46 49 } … … 62 65 private static class PropertyEditorAction extends JosmAction { 63 66 public PropertyEditorAction() { 64 super(tr("Edit photo GPS data"), 65 (String)null, 67 super(tr("Edit photo GPS data"), // String name 68 (String)null, // String iconName 66 69 tr("Edit GPS data of selected photo."), // String tooltip 67 null, 68 true, 70 null, // Shortcut shortcut 71 true, // boolean registerInToolbar 69 72 "photoadjust/propertyeditor", // String toolbarId 70 true 73 true // boolean installAdapters 71 74 ); 72 //putValue("help", ht("/Action/..."));73 75 } 74 76 … … 114 116 * image shown, {@code false} otherwise. 115 117 */ 116 private boolean enabled() {118 private static boolean enabled() { 117 119 try { 118 120 //return ImageViewerDialog.getInstance().hasImage(); … … 147 149 public PropertyEditorDialog(String title, final ImageEntry image, 148 150 final GeoImageLayer layer) { 149 super(Main.parent, title, new String[] {tr("Ok"), tr("Cancel")});151 super(Main.parent, title, tr("Ok"), tr("Cancel")); 150 152 this.image = image; 151 153 this.layer = layer; 152 154 imgOrig = image.clone(); 153 setButtonIcons( new String[] {"ok", "cancel"});155 setButtonIcons("ok", "cancel"); 154 156 final JPanel content = new JPanel(new GridBagLayout()); 155 157 //content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); … … 183 185 Action editCoordAction = new AbstractAction(tr("Edit")) { 184 186 @Override public void actionPerformed(ActionEvent evt) { 185 final LatLonDialog llDialog 187 final LatLonDialog llDialog 186 188 = new LatLonDialog(Main.parent, 187 189 tr("Edit Image Coordinates"), null); … … 317 319 * @return Image position as text. 318 320 */ 319 private String posToText(LatLon pos) {321 private static String posToText(LatLon pos) { 320 322 // See josm.gui.dialogs.LatLonDialog.setCoordinates(). 321 String posStr =323 return 322 324 pos == null ? "" : 323 325 CoordinateFormatManager.getDefaultFormat().latToString(pos) + 324 326 ' ' + 325 327 CoordinateFormatManager.getDefaultFormat().lonToString(pos); 326 return posStr;327 328 } 328 329 … … 389 390 * converted to double. 390 391 */ 391 private Double getDoubleValue(JosmTextField txtFld) {392 private static Double getDoubleValue(JosmTextField txtFld) { 392 393 final String text = txtFld.getText(); 393 394 if (text == null || text.isEmpty()) { … … 424 425 // doesn't work to compare imgTmp.getPos() with getLatLon() 425 426 // because the dialog will round the initial position. 426 if ( 427 || !posToText(imgOrig.getPos()).equals(posToText(imgTmp.getPos()))428 ) {427 if (imgOrig.getPos() == null 428 || !posToText(imgOrig.getPos()).equals( 429 posToText(imgTmp.getPos()))) { 429 430 imgTmp.flagNewGpsData(); 430 431 } … … 492 493 latLon = null; 493 494 } 494 if ( 495 && !coordsText.isEmpty()) {495 if ((latLon == null && coordsText != null 496 && !coordsText.isEmpty())) { 496 497 setErrorFeedback(coords); 497 498 setOkEnabled(false); … … 522 523 final String text = txtFld.getText(); 523 524 Double value = null; 524 if (text == null || text.isEmpty()) { 525 isError = false; 526 } else { 525 if (text != null && !text.isEmpty()) { 527 526 try { 528 value = Double. parseDouble(text);527 value = Double.valueOf(text); 529 528 if (min != null && value < min) { 530 529 isError = true; -
applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/UntaggedGeoImageLayerAction.java
r33745 r33757 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.photoadjust; 2 3
Note:
See TracChangeset
for help on using the changeset viewer.