Changeset 31799 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2015-12-05T00:54:44+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 1 added
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/build.gradle
r31798 r31799 105 105 manifest { 106 106 attributes("Plugin-Mainversion": project.property('plugin.main.version'), 107 "Plugin-Version": "317 84",107 "Plugin-Version": "31799", 108 108 "Plugin-Class": project.property('plugin.class'), 109 109 "Plugin-Description": project.property('plugin.description'), -
applications/editors/josm/plugins/mapillary/gradle.properties
r31783 r31799 7 7 plugin.main.version=8433 8 8 plugin.requires=apache-commons;apache-http 9 plugin.version=1. 0.410 #plugin.early= …11 #plugin.stage= …9 plugin.version=1.1.0 10 #plugin.early=... 11 #plugin.stage=... -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
r31796 r31799 5 5 import java.util.Calendar; 6 6 import java.util.Date; 7 import java.util.Locale; 7 8 8 9 import org.openstreetmap.josm.Main; … … 17 18 */ 18 19 public abstract class MapillaryAbstractImage { 20 /** 21 * If two values for field ca differ by less than EPSILON both values are considered equal. 22 */ 23 private static final float EPSILON = 1e-5f; 19 24 20 25 /** The time the image was captured, in Epoch format. */ … … 87 92 */ 88 93 public String getDate() { 89 StringBuilder format = new StringBuilder( "");94 StringBuilder format = new StringBuilder(26); 90 95 if (Main.pref.getBoolean("iso.dates")) 91 96 format.append("yyyy-MM-dd"); … … 108 113 * @return A String containing the date the picture was taken using the given 109 114 * format. 115 * @throws NullPointerException if parameter format is <code>null</code> 110 116 */ 111 117 public String getDate(String format) { 112 118 Date date = new Date(getCapturedAt()); 113 119 114 SimpleDateFormat formatter = new SimpleDateFormat(format );120 SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.UK); 115 121 formatter.setTimeZone(Calendar.getInstance().getTimeZone()); 116 122 return formatter.format(date); … … 165 171 */ 166 172 public boolean isModified() { 167 return (this.getLatLon() != this.latLon || this.getCa() != this.ca);173 return !this.getLatLon().equals(this.latLon) || Math.abs(this.getCa() - this.ca) < EPSILON; 168 174 } 169 175 … … 197 203 */ 198 204 public MapillaryAbstractImage next() { 199 synchronized ( this.getClass()) {205 synchronized (MapillaryAbstractImage.class) { 200 206 if (this.getSequence() == null) 201 207 return null; … … 211 217 */ 212 218 public MapillaryAbstractImage previous() { 213 synchronized ( this.getClass()) {219 synchronized (MapillaryAbstractImage.class) { 214 220 if (this.getSequence() == null) 215 221 return null; -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
r31796 r31799 42 42 43 43 // Adds the basic set of listeners. 44 addListener(MapillaryPlugin. walkAction);45 addListener(MapillaryPlugin. zoomAction);46 addListener(MapillaryPlugin. uploadAction);44 addListener(MapillaryPlugin.getWalkAction()); 45 addListener(MapillaryPlugin.getZoomAction()); 46 addListener(MapillaryPlugin.getUploadAction()); 47 47 if (Main.main != null) 48 48 addListener(MapillaryMainDialog.getInstance()); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
r31787 r31799 95 95 96 96 @Override 97 public boolean equals(Object o bject) {98 if (o bject instanceof MapillaryImportedImage)99 return this.file.equals(((MapillaryImportedImage) o bject).file);97 public boolean equals(Object other) { 98 if (other != null && other.getClass() == this.getClass()) 99 return this.file.equals(((MapillaryImportedImage) other).file); 100 100 return false; 101 101 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
r31797 r31799 18 18 import java.awt.image.AffineTransformOp; 19 19 import java.awt.image.BufferedImage; 20 import java.util.ArrayList;21 import java.util.List;22 20 import java.util.concurrent.CopyOnWriteArrayList; 23 21 … … 78 76 79 77 /** If the download is in semiautomatic during this object lifetime. */ 80 public boolean TEMP_SEMIAUTOMATIC = false;78 public boolean tempSemiautomatic; 81 79 82 80 /** Unique instance of the class. */ … … 92 90 public AbstractMode mode; 93 91 94 private int highlightPointRadius = Main.pref.getInteger( 95 "mappaint.highlight.radius", 7); 96 private int highlightStep = Main.pref 97 .getInteger("mappaint.highlight.step", 4); 92 private final int highlightPointRadius = Main.pref.getInteger("mappaint.highlight.radius", 7); 93 private final int highlightStep = Main.pref.getInteger("mappaint.highlight.step", 4); 98 94 99 95 private volatile TexturePaint hatched; … … 123 119 } 124 120 // Does not execute when in headless mode 125 if (MapillaryPlugin. EXPORT_MENU!= null) {126 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. EXPORT_MENU, true);121 if (MapillaryPlugin.getExportMenu() != null) { 122 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getExportMenu(), true); 127 123 if (!MapillaryMainDialog.getInstance().isShowing()) 128 124 MapillaryMainDialog.getInstance().getButton().doClick(); … … 220 216 MapillaryMainDialog.getInstance().setImage(null); 221 217 MapillaryMainDialog.getInstance().updateImage(); 222 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. EXPORT_MENU, false);223 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. ZOOM_MENU, false);218 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getExportMenu(), false); 219 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getZoomMenu(), false); 224 220 Main.map.mapView.removeMouseListener(this.mode); 225 221 Main.map.mapView.removeMouseMotionListener(this.mode); … … 464 460 private MapillaryImage[] getClosestImagesFromDifferentSequences() { 465 461 if (!(this.data.getSelectedImage() instanceof MapillaryImage)) 466 return new MapillaryImage[ 2];462 return new MapillaryImage[]{null, null}; 467 463 MapillaryImage selected = (MapillaryImage) this.data.getSelectedImage(); 468 464 MapillaryImage[] ret = new MapillaryImage[2]; 469 double[] distances = { SEQUENCE_MAX_JUMP_DISTANCE, 470 SEQUENCE_MAX_JUMP_DISTANCE }; 465 double[] distances = { 466 SEQUENCE_MAX_JUMP_DISTANCE, 467 SEQUENCE_MAX_JUMP_DISTANCE 468 }; 471 469 LatLon selectedCoords = this.data.getSelectedImage().getLatLon(); 472 470 for (MapillaryAbstractImage imagePrev : this.data.getImages()) { … … 501 499 @Override 502 500 public Object getInfoComponent() { 503 StringBuilder sb = new StringBuilder();504 sb.append(tr("Mapillary layer"));505 sb.append("\n");506 sb.append(tr("Total images:"));507 sb.append(" ");508 sb.append(this.data.size());509 sb.append("\n");510 return sb.toString();501 return new StringBuilder(35) 502 .append(tr("Mapillary layer")) 503 .append('\n') 504 .append(tr("Total images:")) 505 .append(' ') 506 .append(this.data.size()) 507 .append('\n') 508 .toString(); 511 509 } 512 510 513 511 @Override 514 512 public String getToolTipText() { 515 return this.data.size() + " " + tr("images");513 return this.data.size() + (' ' + tr("images")); 516 514 } 517 515 … … 568 566 if (newLayer == this) { 569 567 MapillaryUtils.updateHelpText(); 570 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. JOIN_MENU, true);568 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getJoinMenu(), true); 571 569 } else 572 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. JOIN_MENU, false);570 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getJoinMenu(), false); 573 571 } 574 572 … … 589 587 * 590 588 */ 591 private class DelayedDownload extends Thread {589 private static class DelayedDownload extends Thread { 592 590 593 591 @Override -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31796 r31799 41 41 */ 42 42 public class MapillaryPlugin extends Plugin { 43 public static final String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"; 43 44 44 45 /** OS route separator */ … … 63 64 private final MapillaryExportAction exportAction; 64 65 /** Import action */ 65 p ublic staticMapillaryImportAction importAction;66 private final MapillaryImportAction importAction; 66 67 /** Zoom action */ 67 p ublicstatic MapillaryZoomAction zoomAction;68 private static MapillaryZoomAction zoomAction; 68 69 private final MapillaryDownloadViewAction downloadViewAction; 69 70 private final MapillaryImportIntoSequenceAction importIntoSequenceAction; 70 71 private final MapillaryJoinAction joinAction; 71 72 /** Walk action */ 72 p ublicstatic MapillaryWalkAction walkAction;73 private static MapillaryWalkAction walkAction; 73 74 /** Upload action */ 74 p ublicstatic MapillaryUploadAction uploadAction;75 private static MapillaryUploadAction uploadAction; 75 76 76 77 /** Menu button for the {@link MapillaryDownloadAction} action. */ 77 p ublic static JMenuItem DOWNLOAD_MENU;78 private JMenuItem downloadMenu; 78 79 /** Menu button for the {@link MapillaryExportAction} action. */ 79 p ublic static JMenuItem EXPORT_MENU;80 private static JMenuItem exportMenu; 80 81 /** Menu button for the {@link MapillaryImportAction} action. */ 81 p ublic static JMenuItem IMPORT_MENU;82 private JMenuItem importMenu; 82 83 /** Menu button for the {@link MapillaryZoomAction} action. */ 83 p ublic static JMenuItem ZOOM_MENU;84 private static JMenuItem zoomMenu; 84 85 /** Menu button for the {@link MapillaryDownloadViewAction} action. */ 85 p ublic static JMenuItem DOWNLOAD_VIEW_MENU;86 private static JMenuItem downloadViewMenu; 86 87 /** Menu button for the {@link MapillaryImportIntoSequenceAction} action. */ 87 p ublic static JMenuItem IMPORT_INTO_SEQUENCE_MENU;88 private JMenuItem importIntoSequenceMenu; 88 89 /** Menu button for the {@link MapillaryJoinAction} action. */ 89 p ublic static JMenuItem JOIN_MENU;90 private static JMenuItem joinMenu; 90 91 /** Menu button for the {@link MapillaryWalkAction} action. */ 91 p ublic static JMenuItem WALK_MENU;92 private static JMenuItem walkMenu; 92 93 /** Menu button for the {@link MapillaryUploadAction} action. */ 93 p ublic static JMenuItem UPLOAD_MENU;94 private static JMenuItem uploadMenu; 94 95 95 96 /** … … 102 103 super(info); 103 104 104 this.downloadAction = new MapillaryDownloadAction();105 downloadAction = new MapillaryDownloadAction(); 105 106 walkAction = new MapillaryWalkAction(); 106 this.exportAction = new MapillaryExportAction();107 exportAction = new MapillaryExportAction(); 107 108 importAction = new MapillaryImportAction(); 108 109 zoomAction = new MapillaryZoomAction(); 109 this.downloadViewAction = new MapillaryDownloadViewAction();110 this.importIntoSequenceAction = new MapillaryImportIntoSequenceAction();111 this.joinAction = new MapillaryJoinAction();110 downloadViewAction = new MapillaryDownloadViewAction(); 111 importIntoSequenceAction = new MapillaryImportIntoSequenceAction(); 112 joinAction = new MapillaryJoinAction(); 112 113 uploadAction = new MapillaryUploadAction(); 113 114 114 115 if (Main.main != null) { // important for headless mode 115 DOWNLOAD_MENU = MainMenu.add(Main.main.menu.imageryMenu, 116 this.downloadAction, false); 117 EXPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, this.exportAction, 118 false, 14); 119 IMPORT_INTO_SEQUENCE_MENU = MainMenu.add(Main.main.menu.fileMenu, 120 this.importIntoSequenceAction, false, 14); 121 IMPORT_MENU = MainMenu.add(Main.main.menu.fileMenu, importAction, false, 122 14); 123 UPLOAD_MENU = MainMenu.add(Main.main.menu.fileMenu, uploadAction, false, 124 14); 125 ZOOM_MENU = MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15); 126 DOWNLOAD_VIEW_MENU = MainMenu.add(Main.main.menu.fileMenu, 127 this.downloadViewAction, false, 14); 128 JOIN_MENU = MainMenu.add(Main.main.menu.dataMenu, this.joinAction, false); 129 WALK_MENU = MainMenu.add(Main.main.menu.moreToolsMenu, walkAction, false); 130 131 EXPORT_MENU.setEnabled(false); 132 DOWNLOAD_MENU.setEnabled(false); 133 IMPORT_MENU.setEnabled(false); 134 IMPORT_INTO_SEQUENCE_MENU.setEnabled(false); 135 ZOOM_MENU.setEnabled(false); 136 DOWNLOAD_VIEW_MENU.setEnabled(false); 137 JOIN_MENU.setEnabled(false); 138 WALK_MENU.setEnabled(false); 116 downloadMenu = MainMenu.add(Main.main.menu.imageryMenu, this.downloadAction, false); 117 exportMenu = MainMenu.add(Main.main.menu.fileMenu, exportAction, false, 14); 118 importIntoSequenceMenu = MainMenu.add(Main.main.menu.fileMenu, importIntoSequenceAction, false, 14); 119 importMenu = MainMenu.add(Main.main.menu.fileMenu, importAction, false, 14); 120 uploadMenu = MainMenu.add(Main.main.menu.fileMenu, uploadAction, false, 14); 121 zoomMenu = MainMenu.add(Main.main.menu.viewMenu, zoomAction, false, 15); 122 downloadViewMenu = MainMenu.add(Main.main.menu.fileMenu, this.downloadViewAction, false, 14); 123 joinMenu = MainMenu.add(Main.main.menu.dataMenu, this.joinAction, false); 124 walkMenu = MainMenu.add(Main.main.menu.moreToolsMenu, walkAction, false); 125 126 exportMenu.setEnabled(false); 127 downloadMenu.setEnabled(false); 128 importMenu.setEnabled(false); 129 importIntoSequenceMenu.setEnabled(false); 130 zoomMenu.setEnabled(false); 131 downloadViewMenu.setEnabled(false); 132 joinMenu.setEnabled(false); 133 walkMenu.setEnabled(false); 139 134 } 140 135 141 136 try { 142 CACHE = JCSCacheManager.getCache("mapillary", 10, 10000, 143 this.getPluginDir() + "/cache/"); 137 CACHE = JCSCacheManager.getCache("mapillary", 10, 10000, this.getPluginDir() + "/cache/"); 144 138 } catch (IOException e) { 145 139 Main.error(e); … … 148 142 if (Main.pref.get("mapillary.access-token") == null) 149 143 MapillaryUser.isTokenValid = false; 144 } 145 146 /** 147 * @return the menu-item associated with the {@link MapillaryDownloadViewAction} 148 */ 149 public static JMenuItem getDownloadViewMenu() { 150 return downloadViewMenu; 151 } 152 153 /** 154 * @return the menu-item associated with the {@link MapillaryExportAction} 155 */ 156 public static JMenuItem getExportMenu() { 157 return exportMenu; 158 } 159 160 /** 161 * @return the menu-item associated with the {@link MapillaryJoinAction} 162 */ 163 public static JMenuItem getJoinMenu() { 164 return joinMenu; 165 } 166 167 /** 168 * @return the {@link MapillaryUploadAction} for the plugin 169 */ 170 public static MapillaryDataListener getUploadAction() { 171 return uploadAction; 172 } 173 174 /** 175 * @return the menu-item associated with the {@link MapillaryUploadAction} 176 */ 177 public static JMenuItem getUploadMenu() { 178 return uploadMenu; 179 } 180 181 /** 182 * @return the {@link MapillaryWalkAction} for the plugin 183 */ 184 public static MapillaryWalkAction getWalkAction() { 185 return walkAction; 186 } 187 188 /** 189 * @return the menu-item associated with the {@link MapillaryWalkAction} 190 */ 191 public static JMenuItem getWalkMenu() { 192 return walkMenu; 193 } 194 195 /** 196 * @return the {@link MapillaryZoomAction} for the plugin 197 */ 198 public static MapillaryDataListener getZoomAction() { 199 return zoomAction; 200 } 201 202 /** 203 * @return the menu-item associated with the {@link MapillaryZoomAction} 204 */ 205 public static JMenuItem getZoomMenu() { 206 return zoomMenu; 150 207 } 151 208 … … 159 216 Main.map.addToggleDialog(MapillaryHistoryDialog.getInstance(), false); 160 217 Main.map.addToggleDialog(MapillaryFilterDialog.getInstance(), false); 161 setMenuEnabled( DOWNLOAD_MENU, true);218 setMenuEnabled(downloadMenu, true); 162 219 if (MapillaryDownloader.getMode() == MapillaryDownloader.MODES.Manual) 163 setMenuEnabled( DOWNLOAD_VIEW_MENU, true);164 setMenuEnabled( IMPORT_MENU, true);165 setMenuEnabled( IMPORT_INTO_SEQUENCE_MENU, true);220 setMenuEnabled(downloadViewMenu, true); 221 setMenuEnabled(importMenu, true); 222 setMenuEnabled(importIntoSequenceMenu, true); 166 223 } 167 224 if (oldFrame != null && newFrame == null) { // map frame destroyed … … 169 226 MapillaryHistoryDialog.destroyInstance(); 170 227 MapillaryFilterDialog.destroyInstance(); 171 setMenuEnabled( DOWNLOAD_MENU, false);172 setMenuEnabled( DOWNLOAD_VIEW_MENU, false);173 setMenuEnabled( IMPORT_MENU, false);174 setMenuEnabled( IMPORT_INTO_SEQUENCE_MENU, false);228 setMenuEnabled(downloadMenu, false); 229 setMenuEnabled(downloadViewMenu, false); 230 setMenuEnabled(importMenu, false); 231 setMenuEnabled(importIntoSequenceMenu, false); 175 232 } 176 233 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryTrafficSignLayer.java
r31787 r31799 3 3 4 4 import java.awt.Color; 5 import java.awt.Component; 5 6 import java.awt.Font; 6 7 import java.awt.FontFormatException; … … 13 14 import javax.swing.Action; 14 15 import javax.swing.Icon; 16 import javax.swing.JLabel; 15 17 16 18 import org.openstreetmap.josm.data.Bounds; … … 22 24 import org.openstreetmap.josm.plugins.mapillary.traffico.TrafficoSign; 23 25 import org.openstreetmap.josm.plugins.mapillary.traffico.TrafficoSignElement; 26 import org.openstreetmap.josm.tools.I18n; 24 27 25 28 public class MapillaryTrafficSignLayer extends AbstractModifiableLayer { 29 private static final String TRAFFICO_PATH = "data/fonts/traffico/traffico.ttf"; 26 30 private static MapillaryTrafficSignLayer instance; 31 private final Font traffico; 32 33 private MapillaryTrafficSignLayer() throws IOException { 34 super("Mapillary traffic signs"); 35 try { 36 traffico = Font.createFont(Font.TRUETYPE_FONT, new File("data/fonts/traffico/traffico.ttf")).deriveFont(50.0f); 37 } catch (FontFormatException e) { 38 throw new IOException(I18n.tr("Traffic sign font at ''{0}'' has wrong format.", TRAFFICO_PATH), e); 39 } catch (IOException e) { 40 throw new IOException(I18n.tr("Could not read font-file from ''{{0}}''.", TRAFFICO_PATH), e); 41 } 42 } 27 43 28 44 /** … … 30 46 * 31 47 * @return the only instance of the traffic sign layer 48 * @throws IOException if some error occured while reading the icon-font traffico or 49 * if the traffico font has the wrong format 32 50 */ 33 public static MapillaryTrafficSignLayer getInstance() { 34 return instance == null ? (instance = new MapillaryTrafficSignLayer()) 35 : instance; 36 } 37 38 /** 39 * @param name 40 */ 41 private MapillaryTrafficSignLayer() { 42 super("Mapillary traffic signs"); 51 public static MapillaryTrafficSignLayer getInstance() throws IOException { 52 if (instance == null) 53 instance = new MapillaryTrafficSignLayer(); 54 return instance; 43 55 } 44 56 … … 61 73 @Override 62 74 public void paint(Graphics2D g, MapView mv, Bounds box) { 63 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 64 RenderingHints.VALUE_ANTIALIAS_ON); 65 try { 66 g.setFont(Font.createFont(Font.TRUETYPE_FONT, 67 new File("data/fonts/traffico/traffico.ttf")).deriveFont(50.0f)); 68 } catch (FontFormatException e) { 69 e.printStackTrace(); 70 } catch (IOException e) { 71 e.printStackTrace(); 72 } 75 g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); 76 g.setFont(traffico); 73 77 74 78 Point[] points = new Point[3]; … … 91 95 // Start iterating the images 92 96 g.setColor(Color.MAGENTA); 93 for (MapillaryAbstractImage img : MapillaryLayer.getInstance() 94 .getData().getImages()) { 97 for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getData().getImages()) { 95 98 if (img instanceof MapillaryImage) { 96 g.fillOval(mv.getPoint(img.getLatLon()).x - 3, 97 mv.getPoint(img.getLatLon()).y - 3, 6, 6); 99 g.fillOval(mv.getPoint(img.getLatLon()).x - 3, mv.getPoint(img.getLatLon()).y - 3, 6, 6); 98 100 if (((MapillaryImage) img).getSigns().size() >= 1) { 99 101 Point imgLoc = mv.getPoint(img.getLatLon()); 100 for (TrafficoSignElement e : TrafficoSign.getSign("de", 101 ((MapillaryImage) img).getSigns().get(0))) { 102 for (TrafficoSignElement e : TrafficoSign.getSign("de", ((MapillaryImage) img).getSigns().get(0))) { 102 103 g.setColor(e.getColor()); 103 104 g.drawString("" + e.getGlyph(), imgLoc.x, imgLoc.y); … … 137 138 @Override 138 139 public void mergeFrom(Layer from) { 139 // Does nothing as this layer is not mergeable (see method 140 // isMergable(Layer)) 140 // Does nothing as this layer is not mergeable (see method isMergable(Layer)) 141 141 } 142 142 … … 163 163 public void visitBoundingBox(BoundingXYVisitor v) { 164 164 // TODO Auto-generated method stub 165 166 165 } 167 166 … … 172 171 */ 173 172 @Override 174 public Object getInfoComponent() { 175 // TODO Auto-generated method stub 176 return null; 173 public Component getInfoComponent() { 174 return new JLabel("Mapillary traffic sign layer"); 177 175 } 178 176 … … 184 182 @Override 185 183 public Action[] getMenuEntries() { 186 // TODO Auto-generated method stub 187 return null; 184 return new Action[]{}; 188 185 } 189 186 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
r31787 r31799 71 71 MapillaryAbstractImage newImage) { 72 72 if (oldImage == null && newImage != null) 73 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. UPLOAD_MENU, true);73 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getUploadMenu(), true); 74 74 else if (oldImage != null && newImage == null) 75 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. UPLOAD_MENU, false);75 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getUploadMenu(), false); 76 76 } 77 77 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryWalkAction.java
r31787 r31799 101 101 MapillaryAbstractImage newImage) { 102 102 if (newImage != null) 103 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. WALK_MENU, true);103 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getWalkMenu(), true); 104 104 else 105 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. WALK_MENU, false);105 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getWalkMenu(), false); 106 106 } 107 107 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryZoomAction.java
r31787 r31799 51 51 MapillaryAbstractImage newImage) { 52 52 if (oldImage == null && newImage != null) 53 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. ZOOM_MENU, true);53 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getZoomMenu(), true); 54 54 else if (oldImage != null && newImage == null) 55 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. ZOOM_MENU, false);55 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getZoomMenu(), false); 56 56 } 57 57 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/FinishedUploadDialog.java
r31787 r31799 7 7 import java.awt.event.ActionEvent; 8 8 import java.awt.event.ActionListener; 9 import java. net.MalformedURLException;9 import java.io.IOException; 10 10 import java.net.URL; 11 11 … … 49 49 try { 50 50 MapillaryUtils.browse(new URL("http://www.mapillary.com/map/upload/im")); 51 } catch ( MalformedURLException e1) {51 } catch (IOException e1) { 52 52 Main.error(e1); 53 53 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java
r31787 r31799 12 12 import java.awt.event.ActionListener; 13 13 import java.awt.event.MouseEvent; 14 import java.io.IOException; 14 15 import java.net.MalformedURLException; 15 16 import java.net.URL; … … 161 162 public void actionPerformed(ActionEvent arg0) { 162 163 try { 163 MapillaryUtils.browse(new URL("http://www.mapillary.com/map/e/" 164 + HyperlinkLabel.this.key)); 165 } catch (MalformedURLException e) { 164 MapillaryUtils.browse(new URL("http://www.mapillary.com/map/e/" + HyperlinkLabel.this.key)); 165 } catch (IOException e) { 166 166 Main.error(e); 167 167 } … … 211 211 if (this.url == null) 212 212 return; 213 MapillaryUtils.browse(this.url); 213 try { 214 MapillaryUtils.browse(this.url); 215 } catch (IOException e1) { 216 Main.error(e1); 217 } 214 218 } 215 219 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
r31797 r31799 439 439 putValue(SHORT_DESCRIPTION, tr("Stops the walk.")); 440 440 putValue(SMALL_ICON, ImageProvider.get("dialogs/mapillaryStop.png")); 441 MapillaryPlugin. walkAction.addListener(this);441 MapillaryPlugin.getWalkAction().addListener(this); 442 442 } 443 443 … … 457 457 458 458 private static final long serialVersionUID = -17943404752082788L; 459 private WalkThread thread;459 private transient WalkThread thread; 460 460 461 461 public PlayAction() { … … 463 463 putValue(SHORT_DESCRIPTION, tr("Continues with the paused walk.")); 464 464 putValue(SMALL_ICON, ImageProvider.get("dialogs/mapillaryPlay.png")); 465 MapillaryPlugin. walkAction.addListener(this);465 MapillaryPlugin.getWalkAction().addListener(this); 466 466 } 467 467 … … 489 489 putValue(SHORT_DESCRIPTION, tr("Pauses the walk.")); 490 490 putValue(SMALL_ICON, ImageProvider.get("dialogs/mapillaryPause.png")); 491 MapillaryPlugin. walkAction.addListener(this);491 MapillaryPlugin.getWalkAction().addListener(this); 492 492 } 493 493 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryPreferenceSetting.java
r31796 r31799 6 6 import java.awt.FlowLayout; 7 7 import java.awt.event.ActionEvent; 8 import java. net.MalformedURLException;8 import java.io.IOException; 9 9 import java.net.URL; 10 10 … … 99 99 .put("mapillary.reverse-buttons", this.reverseButtons.isSelected()); 100 100 101 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. DOWNLOAD_VIEW_MENU, false);101 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), false); 102 102 if (this.downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES.Automatic.toString())) 103 103 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Automatic.toString()); … … 106 106 if (this.downloadMode.getSelectedItem().equals(MapillaryDownloader.MODES.Manual.toString())) { 107 107 Main.pref.put("mapillary.download-mode", MapillaryDownloader.MODES.Manual.toString()); 108 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. DOWNLOAD_VIEW_MENU, true);108 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), true); 109 109 } 110 110 Main.pref.put("mapillary.display-hour", this.displayHour.isSelected()); … … 133 133 OAuthPortListener portListener = new OAuthPortListener(); 134 134 portListener.start(); 135 String url = "http://www.mapillary.com/connect?redirect_uri=http:%2F%2Flocalhost:8763%2F&client_id= T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz&response_type=token&scope=user:read%20public:upload%20public:write";135 String url = "http://www.mapillary.com/connect?redirect_uri=http:%2F%2Flocalhost:8763%2F&client_id="+MapillaryPlugin.CLIENT_ID+"&response_type=token&scope=user:read%20public:upload%20public:write"; 136 136 try { 137 137 MapillaryUtils.browse(new URL(url)); 138 } catch ( MalformedURLException e) {138 } catch (IOException e) { 139 139 Main.error(e); 140 140 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillaryDownloader.java
r31797 r31799 40 40 /** Base URL of the Mapillary API. */ 41 41 public static final String BASE_URL = "https://a.mapillary.com/v2/"; 42 /** Client ID for the app */43 public static final String CLIENT_ID = "T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";44 42 /** Executor that will run the petitions. */ 45 43 private static ThreadPoolExecutor EXECUTOR = new ThreadPoolExecutor(3, 5, … … 179 177 public static MapillaryDownloader.MODES getMode() { 180 178 if (Main.pref.get("mapillary.download-mode").equals(MODES.Automatic.toString()) 181 && (!MapillaryLayer.hasInstance() || !MapillaryLayer.getInstance(). TEMP_SEMIAUTOMATIC))179 && (!MapillaryLayer.hasInstance() || !MapillaryLayer.getInstance().tempSemiautomatic)) 182 180 return MODES.Automatic; 183 181 else if (Main.pref.get("mapillary.download-mode").equals(MODES.Semiautomatic.toString()) 184 || (MapillaryLayer.hasInstance() && MapillaryLayer.getInstance(). TEMP_SEMIAUTOMATIC))182 || (MapillaryLayer.hasInstance() && MapillaryLayer.getInstance().tempSemiautomatic)) 185 183 return MODES.Semiautomatic; 186 184 else if (Main.pref.get("mapillary.download-mode").equals(MODES.Manual.toString())) … … 201 199 }); 202 200 } else { 203 MapillaryLayer.getInstance(). TEMP_SEMIAUTOMATIC= true;204 MapillaryPlugin.setMenuEnabled(MapillaryPlugin. DOWNLOAD_VIEW_MENU, true);201 MapillaryLayer.getInstance().tempSemiautomatic = true; 202 MapillaryPlugin.setMenuEnabled(MapillaryPlugin.getDownloadViewMenu(), true); 205 203 JOptionPane 206 204 .showMessageDialog( -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySquareDownloadManagerThread.java
r31787 r31799 5 5 import java.net.URLEncoder; 6 6 import java.util.Locale; 7 import java.util.Map.Entry; 7 8 import java.util.concurrent.ArrayBlockingQueue; 8 import java.util.concurrent.Concurrent HashMap;9 import java.util.concurrent.ConcurrentMap; 9 10 import java.util.concurrent.ThreadPoolExecutor; 10 11 import java.util.concurrent.TimeUnit; … … 12 13 import org.openstreetmap.josm.Main; 13 14 import org.openstreetmap.josm.plugins.mapillary.MapillaryData; 15 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 14 16 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog; 15 17 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog; … … 49 51 * 50 52 */ 51 public MapillarySquareDownloadManagerThread( 52 ConcurrentHashMap<String, Double> queryStringParts) { 53 public MapillarySquareDownloadManagerThread(ConcurrentMap<String, Double> queryStringParts) { 53 54 this.imageQueryString = buildQueryString(queryStringParts); 54 55 this.sequenceQueryString = buildQueryString(queryStringParts); … … 60 61 61 62 // TODO: Maybe move into a separate utility class? 62 private static String buildQueryString(ConcurrentHashMap<String, Double> hash) { 63 StringBuilder ret = new StringBuilder("?client_id=" 64 + MapillaryDownloader.CLIENT_ID); 65 for (String key : hash.keySet()) 66 if (key != null) 63 private static String buildQueryString(ConcurrentMap<String, Double> hash) { 64 StringBuilder ret = new StringBuilder().append("?client_id=").append(MapillaryPlugin.CLIENT_ID); 65 for (Entry<String, Double> entry : hash.entrySet()) 66 if (entry.getKey() != null) 67 67 try { 68 ret.append( "&" + URLEncoder.encode(key, "UTF-8")).append(69 "="70 + URLEncoder.encode(71 String.format(Locale.UK, "%f", hash.get(key)), "UTF-8"));68 ret.append('&') 69 .append(URLEncoder.encode(entry.getKey(), "UTF-8")) 70 .append('=') 71 .append(URLEncoder.encode(String.format(Locale.UK, "%f", entry.getValue()), "UTF-8")); 72 72 } catch (UnsupportedEncodingException e) { 73 73 // This should not happen, as the encoding is hard-coded … … 106 106 while (!this.downloadExecutor.isShutdown()) { 107 107 this.downloadExecutor.execute(new MapillarySequenceDownloadThread( 108 this.downloadExecutor, this.sequenceQueryString + "&page=" + page 109 + "&limit=10")); 108 this.downloadExecutor, this.sequenceQueryString + "&page=" + page + "&limit=10")); 110 109 while (this.downloadExecutor.getQueue().remainingCapacity() == 0) 111 110 Thread.sleep(500); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/oauth/MapillaryUser.java
r31787 r31799 5 5 import java.net.URL; 6 6 import java.util.HashMap; 7 import java.util.Map; 7 8 8 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 9 11 10 12 /** … … 17 19 18 20 private static String username; 19 private static String images _policy;20 private static String images _hash;21 private static String imagesPolicy; 22 private static String imagesHash; 21 23 /** If the stored token is valid or not. */ 22 24 public static boolean isTokenValid = true; … … 35 37 .getWithHeader( 36 38 new URL( 37 "https://a.mapillary.com/v2/me?client_id= T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))39 "https://a.mapillary.com/v2/me?client_id="+MapillaryPlugin.CLIENT_ID)) 38 40 .getString("username"); 39 41 } catch (IOException e) { … … 48 50 * strings. 49 51 */ 50 public static HashMap<String, String> getSecrets() {52 public static Map<String, String> getSecrets() { 51 53 if (!isTokenValid) 52 54 return null; 53 HashMap<String, String> hash = new HashMap<>();55 Map<String, String> hash = new HashMap<>(); 54 56 try { 55 if (images _hash == null)56 images _hash = OAuthUtils57 if (imagesHash == null) 58 imagesHash = OAuthUtils 57 59 .getWithHeader( 58 60 new URL( 59 "https://a.mapillary.com/v2/me/uploads/secrets?client_id= T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))61 "https://a.mapillary.com/v2/me/uploads/secrets?client_id="+MapillaryPlugin.CLIENT_ID)) 60 62 .getString("images_hash"); 61 hash.put("images_hash", images _hash);62 if (images _policy == null)63 images _policy = OAuthUtils63 hash.put("images_hash", imagesHash); 64 if (imagesPolicy == null) 65 imagesPolicy = OAuthUtils 64 66 .getWithHeader( 65 67 new URL( 66 "https://a.mapillary.com/v2/me/uploads/secrets?client_id= T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz"))68 "https://a.mapillary.com/v2/me/uploads/secrets?client_id="+MapillaryPlugin.CLIENT_ID)) 67 69 .getString("images_policy"); 68 70 } catch (IOException e) { … … 70 72 reset(); 71 73 } 72 hash.put("images_policy", images _policy);74 hash.put("images_policy", imagesPolicy); 73 75 return hash; 74 76 } … … 79 81 public static void reset() { 80 82 username = null; 81 images _policy = null;82 images _hash = null;83 imagesPolicy = null; 84 imagesHash = null; 83 85 isTokenValid = false; 84 86 Main.pref.put("mapillary.access-token", null); -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/traffico/TrafficoSign.java
r31795 r31799 15 15 16 16 public final class TrafficoSign { 17 private static Map<String, Map<String, TrafficoSignElement[]>> signs = new HashMap<>(); 18 17 19 private TrafficoSign() { 18 20 // private constructor to avoid instantiation 19 21 } 20 21 private static Map<String, Map<String, TrafficoSignElement[]>> signs = new HashMap<>();22 22 23 23 public static TrafficoSignElement[] getSign(String country, String signName) { -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtils.java
r31797 r31799 41 41 * 42 42 */ 43 public class MapillaryUtils { 44 45 private static double MIN_ZOOM_SQUARE_SIDE = 0.002; 43 public final class MapillaryUtils { 44 45 private static final double MIN_ZOOM_SQUARE_SIDE = 0.002; 46 47 private MapillaryUtils() { 48 // Private constructor to avoid instantiation 49 } 46 50 47 51 /** 48 52 * Open the default browser in the given URL. 49 53 * 50 * @param url 51 * The URL that is going to be opened. 52 */ 53 public static void browse(URL url) { 54 * @param url The (not-null) URL that is going to be opened. 55 * @throws IOException when the URL could not be opened 56 */ 57 public static void browse(URL url) throws IOException { 58 if (url == null) { 59 throw new IllegalArgumentException(); 60 } 54 61 Desktop desktop = Desktop.getDesktop(); 55 62 if (desktop.isSupported(Desktop.Action.BROWSE)) { 56 63 try { 57 64 desktop.browse(url.toURI()); 58 } catch ( IOException |URISyntaxException e1) {59 Main.error(e1);65 } catch (URISyntaxException e1) { 66 throw new IOException(e1); 60 67 } 61 68 } else { 62 69 Runtime runtime = Runtime.getRuntime(); 63 try { 64 runtime.exec("xdg-open " + url); 65 } catch (IOException exc) { 66 exc.printStackTrace(); 67 } 70 runtime.exec("xdg-open " + url); 68 71 } 69 72 } -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/io/download/MapillarySequenceDownloadThreadTest.java
r31797 r31799 15 15 import org.openstreetmap.josm.plugins.mapillary.AbstractTest; 16 16 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer; 17 import org.openstreetmap.josm.plugins.mapillary.MapillaryPlugin; 17 18 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillaryDownloader; 18 19 import org.openstreetmap.josm.plugins.mapillary.io.download.MapillarySequenceDownloadThread; … … 47 48 "?max_lat=%.8f&max_lon=%.8f&min_lat=%.8f&min_lon=%.8f&limit=10&client_id=%s", 48 49 maxLatLon.lat(), maxLatLon.lon(), minLatLon.lat(), minLatLon.lon(), 49 Mapillary Downloader.CLIENT_ID);50 MapillaryPlugin.CLIENT_ID); 50 51 MapillaryLayer.getInstance().getData().bounds.add(new Bounds(minLatLon, 51 52 maxLatLon)); -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/utils/MapillaryUtilsTest.java
r31460 r31799 15 15 */ 16 16 public class MapillaryUtilsTest { 17 18 @Test 19 public void testUtilityClass() { 20 TestUtil.testUtilityClass(MapillaryUtils.class); 21 } 17 22 18 23 /**
Note:
See TracChangeset
for help on using the changeset viewer.