Changeset 31812 in osm for applications/editors/josm/plugins
- Timestamp:
- 2015-12-11T22:41:08+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
r31799 r31812 17 17 * 18 18 */ 19 public abstractclass MapillaryAbstractImage {19 public class MapillaryAbstractImage { 20 20 /** 21 21 * If two values for field ca differ by less than EPSILON both values are considered equal. … … 58 58 * The direction of the picture (0 means north). 59 59 */ 60 p ublic MapillaryAbstractImage(double lat, double lon,double ca) {60 protected MapillaryAbstractImage(final double lat, final double lon, final double ca) { 61 61 this.latLon = new LatLon(lat, lon); 62 62 this.tempLatLon = this.latLon; … … 92 92 */ 93 93 public String getDate() { 94 StringBuilder format = new StringBuilder(26);95 if (Main.pref.getBoolean("iso.dates")) 94 final StringBuilder format = new StringBuilder(26); 95 if (Main.pref.getBoolean("iso.dates")) { 96 96 format.append("yyyy-MM-dd"); 97 else97 } else { 98 98 format.append("dd/MM/yyyy"); 99 } 99 100 if (Main.pref.getBoolean("mapillary.display-hour", true)) { 100 if (Main.pref.getBoolean("mapillary.format-24")) 101 if (Main.pref.getBoolean("mapillary.format-24")) { 101 102 format.append(" - HH:mm:ss (z)"); 102 else103 } else { 103 104 format.append(" - h:mm:ss a (z)"); 105 } 104 106 } 105 107 return getDate(format.toString()); … … 116 118 */ 117 119 public String getDate(String format) { 118 Date date = new Date(getCapturedAt());119 120 SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.UK);120 final Date date = new Date(getCapturedAt()); 121 122 final SimpleDateFormat formatter = new SimpleDateFormat(format, Locale.UK); 121 123 formatter.setTimeZone(Calendar.getInstance().getTimeZone()); 122 124 return formatter.format(date); … … 186 188 * Moves the image temporally to another position 187 189 * 188 * @param x 189 * The movement of the image in longitude units. 190 * @param y 191 * The movement of the image in latitude units. 192 */ 193 public void move(double x, double y) { 194 this.movingLatLon = new LatLon(this.tempLatLon.getY() + y, 195 this.tempLatLon.getX() + x); 190 * @param x The movement of the image in longitude units. 191 * @param y The movement of the image in latitude units. 192 */ 193 public void move(final double x, final double y) { 194 this.movingLatLon = new LatLon(this.tempLatLon.getY() + y, this.tempLatLon.getX() + x); 196 195 } 197 196 … … 227 226 * Sets the Epoch time when the picture was captured. 228 227 * 229 * @param capturedAt 230 * Epoch time when the image was captured. 231 */ 232 public void setCapturedAt(long capturedAt) { 228 * @param capturedAt Epoch time when the image was captured. 229 */ 230 public void setCapturedAt(final long capturedAt) { 233 231 this.capturedAt = capturedAt; 234 232 } … … 237 235 * Sets the MapillarySequence object which contains the MapillaryImage. 238 236 * 239 * @param sequence 240 * The MapillarySequence that contains the MapillaryImage. 241 */ 242 public void setSequence(MapillarySequence sequence) { 237 * @param sequence The MapillarySequence that contains the MapillaryImage. 238 */ 239 public void setSequence(final MapillarySequence sequence) { 243 240 this.sequence = sequence; 244 241 } … … 247 244 * Set's whether the image should be visible on the map or not. 248 245 * 249 * @param visible 250 * true if the image is set to be visible; false otherwise. 251 */ 252 public void setVisible(boolean visible) { 246 * @param visible true if the image is set to be visible; false otherwise. 247 */ 248 public void setVisible(final boolean visible) { 253 249 this.visible = visible; 254 250 } … … 266 262 * Turns the image direction. 267 263 * 268 * @param ca 269 * The angle the image is moving. 270 */ 271 public void turn(double ca) { 264 * @param ca The angle the image is moving. 265 */ 266 public void turn(final double ca) { 272 267 this.movingCa = this.tempCa + ca; 273 268 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
r31799 r31812 61 61 public static CacheAccess<String, BufferedImageCacheEntry> CACHE; 62 62 63 private final MapillaryDownloadAction downloadAction;64 private final MapillaryExportAction exportAction;63 private static final MapillaryDownloadAction downloadAction = new MapillaryDownloadAction(); 64 private static final MapillaryExportAction exportAction = new MapillaryExportAction(); 65 65 /** Import action */ 66 private final MapillaryImportAction importAction;66 private static final MapillaryImportAction importAction = new MapillaryImportAction(); 67 67 /** Zoom action */ 68 private static MapillaryZoomAction zoomAction;69 private final MapillaryDownloadViewAction downloadViewAction;70 private final MapillaryImportIntoSequenceAction importIntoSequenceAction;71 private final MapillaryJoinAction joinAction;68 private static final MapillaryZoomAction zoomAction = new MapillaryZoomAction(); 69 private static final MapillaryDownloadViewAction downloadViewAction = new MapillaryDownloadViewAction(); 70 private static final MapillaryImportIntoSequenceAction importIntoSequenceAction = new MapillaryImportIntoSequenceAction(); 71 private static final MapillaryJoinAction joinAction = new MapillaryJoinAction(); 72 72 /** Walk action */ 73 private static MapillaryWalkAction walkAction;73 private static final MapillaryWalkAction walkAction = new MapillaryWalkAction(); 74 74 /** Upload action */ 75 private static MapillaryUploadAction uploadAction;75 private static final MapillaryUploadAction uploadAction = new MapillaryUploadAction(); 76 76 77 77 /** Menu button for the {@link MapillaryDownloadAction} action. */ … … 103 103 super(info); 104 104 105 downloadAction = new MapillaryDownloadAction();106 walkAction = new MapillaryWalkAction();107 exportAction = new MapillaryExportAction();108 importAction = new MapillaryImportAction();109 zoomAction = new MapillaryZoomAction();110 downloadViewAction = new MapillaryDownloadViewAction();111 importIntoSequenceAction = new MapillaryImportIntoSequenceAction();112 joinAction = new MapillaryJoinAction();113 uploadAction = new MapillaryUploadAction();114 115 105 if (Main.main != null) { // important for headless mode 116 downloadMenu = MainMenu.add(Main.main.menu.imageryMenu, this.downloadAction, false);106 downloadMenu = MainMenu.add(Main.main.menu.imageryMenu, downloadAction, false); 117 107 exportMenu = MainMenu.add(Main.main.menu.fileMenu, exportAction, false, 14); 118 108 importIntoSequenceMenu = MainMenu.add(Main.main.menu.fileMenu, importIntoSequenceAction, false, 14); … … 120 110 uploadMenu = MainMenu.add(Main.main.menu.fileMenu, uploadAction, false, 14); 121 111 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);112 downloadViewMenu = MainMenu.add(Main.main.menu.fileMenu, downloadViewAction, false, 14); 113 joinMenu = MainMenu.add(Main.main.menu.dataMenu, joinAction, false); 124 114 walkMenu = MainMenu.add(Main.main.menu.moreToolsMenu, walkAction, false); 125 115 -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryUploadAction.java
r31799 r31812 55 55 if (pane.getValue() != null 56 56 && (int) pane.getValue() == JOptionPane.OK_OPTION 57 && dialog.delete != null) { 58 if (dialog.sequence.isSelected()) { 59 UploadUtils.uploadSequence(MapillaryLayer.getInstance().getData() 60 .getSelectedImage().getSequence(), dialog.delete.isSelected()); 61 } 57 && dialog.delete != null 58 && dialog.sequence.isSelected()) { 59 UploadUtils.uploadSequence( 60 MapillaryLayer.getInstance().getData().getSelectedImage().getSequence(), 61 dialog.delete.isSelected() 62 ); 62 63 } 63 64 } -
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryFilterDialog.java
r31797 r31812 40 40 * 41 41 */ 42 public class MapillaryFilterDialog extends ToggleDialog implements 43 MapillaryDataListener { 42 public class MapillaryFilterDialog extends ToggleDialog implements MapillaryDataListener { 44 43 45 44 private static final long serialVersionUID = -4192029663670922103L; 46 45 47 private static MapillaryFilterDialog INSTANCE; 48 49 private static final String[] TIME_LIST = { tr("All"), tr("Years"), 50 tr("Months"), tr("Days") }; 46 private static MapillaryFilterDialog instance; 47 48 private static final String[] TIME_LIST = { tr("All"), tr("Years"), tr("Months"), tr("Days") }; 51 49 52 50 private final JPanel panel; 53 51 54 52 /** Spinner to choose the range of dates. */ 55 p ublicSpinnerNumberModel spinner;53 private final SpinnerNumberModel spinner; 56 54 57 55 private final JCheckBox imported = new JCheckBox(tr("Imported images")); 58 private final JCheckBox downloaded = new JCheckBox( 59 new downloadCheckBoxAction()); 56 private final JCheckBox downloaded = new JCheckBox(new DownloadCheckBoxAction()); 60 57 private final JCheckBox onlySigns = new JCheckBox(new OnlySignsAction()); 61 58 private final JComboBox<String> time; … … 66 63 private final JButton signChooser = new JButton(new SignChooserAction()); 67 64 68 private final MapillaryFilterChooseSigns signFilter = MapillaryFilterChooseSigns 69 .getInstance(); 65 private final MapillaryFilterChooseSigns signFilter = MapillaryFilterChooseSigns.getInstance(); 70 66 71 67 /** The list of sign names */ 72 private final String[] SIGN_TAGS = { "prohibitory_speed_limit",68 private static final String[] SIGN_TAGS = { "prohibitory_speed_limit", 73 69 "priority_stop", "other_give_way", "mandatory_roundabout", 74 70 "other_no_entry", "prohibitory_no_traffic_both_ways", … … 78 74 "danger_pedestrian_crossing", "prohibitory_no_u_turn", 79 75 "prohibitory_noturn" }; 80 /** The the{@link JCheckBox} where the respective tag should be searched */76 /** The {@link JCheckBox} where the respective tag should be searched */ 81 77 private final JCheckBox[] SIGN_CHECKBOXES = { this.signFilter.maxSpeed, 82 78 this.signFilter.stop, this.signFilter.giveWay, … … 137 133 138 134 /** 139 * Returns the unique instance of the class. 140 * 141 * @return THe unique instance of the class. 142 */ 143 public static MapillaryFilterDialog getInstance() { 144 if (INSTANCE == null) 145 INSTANCE = new MapillaryFilterDialog(); 146 return INSTANCE; 135 * @return the unique instance of the class. 136 */ 137 public static synchronized MapillaryFilterDialog getInstance() { 138 if (instance == null) 139 instance = new MapillaryFilterDialog(); 140 return instance; 147 141 } 148 142 … … 153 147 154 148 @Override 155 public void selectedImageChanged(MapillaryAbstractImage oldImage, 156 MapillaryAbstractImage newImage) {149 public void selectedImageChanged(MapillaryAbstractImage oldImage, MapillaryAbstractImage newImage) { 150 // Do nothing when image selection changed 157 151 } 158 152 … … 179 173 boolean onlySigns = this.onlySigns.isSelected(); 180 174 181 for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getData() 182 .getImages()) { 175 for (MapillaryAbstractImage img : MapillaryLayer.getInstance().getData().getImages()) { 183 176 img.setVisible(true); 184 177 if (img instanceof MapillaryImportedImage) { … … 201 194 } 202 195 } 203 if (! this.user.getText().equals("")196 if (!"".equals(user.getText()) 204 197 && !this.user.getText().equals(((MapillaryImage) img).getUser())) { 205 198 img.setVisible(false); … … 209 202 // Calculates the amount of days since the image was taken 210 203 Long currentTime = currentTime(); 211 if (this.time.getSelectedItem().equals(TIME_LIST[1])) { 212 if (img.getCapturedAt() < currentTime 213 - ((Integer) this.spinner.getValue()).longValue() * 365 * 24 * 60 214 * 60 * 1000) { 204 long[] timeFactor = new long[]{ 205 31536000000L, // = 365 * 24 * 60 * 60 * 1000 = number of ms in a year 206 2592000000L, // = 30 * 24 * 60 * 60 * 1000 = number of ms in a month 207 86400000 // = 24 * 60 * 60 * 1000 = number of ms in a day 208 }; 209 for (int i = 1; i <= 3; i++) { 210 if (TIME_LIST[i].equals(time.getSelectedItem()) 211 && img.getCapturedAt() < currentTime - ((Integer) spinner.getValue()).longValue() * timeFactor[i - 1] 212 ) { 215 213 img.setVisible(false); 216 continue;217 }218 }219 if (this.time.getSelectedItem().equals(TIME_LIST[2])) {220 if (img.getCapturedAt() < currentTime221 - ((Integer) this.spinner.getValue()).longValue() * 30 * 24 * 60222 * 60 * 1000) {223 img.setVisible(false);224 continue;225 }226 }227 if (this.time.getSelectedItem().equals(TIME_LIST[3])) {228 if (img.getCapturedAt() < currentTime229 - ((Integer) this.spinner.getValue()).longValue() * 60 * 60 * 1000) {230 img.setVisible(false);231 continue;232 214 } 233 215 } … … 246 228 */ 247 229 private boolean checkSigns(MapillaryImage img) { 248 for (int i = 0; i < this.SIGN_TAGS.length; i++) {249 if (checkSign(img, this.SIGN_CHECKBOXES[i], this.SIGN_TAGS[i]))230 for (int i = 0; i < SIGN_TAGS.length; i++) { 231 if (checkSign(img, this.SIGN_CHECKBOXES[i], SIGN_TAGS[i])) 250 232 return true; 251 233 } … … 270 252 } 271 253 272 private class downloadCheckBoxAction extends AbstractAction {254 private class DownloadCheckBoxAction extends AbstractAction { 273 255 274 256 private static final long serialVersionUID = 4672634002899519496L; 275 257 276 public downloadCheckBoxAction() {258 public DownloadCheckBoxAction() { 277 259 putValue(NAME, tr("Downloaded images")); 278 260 } … … 280 262 @Override 281 263 public void actionPerformed(ActionEvent arg0) { 282 MapillaryFilterDialog.this.onlySigns 283 .setEnabled(MapillaryFilterDialog.this.downloaded.isSelected()); 264 onlySigns.setEnabled(downloaded.isSelected()); 284 265 } 285 266 } … … 325 306 @Override 326 307 public void actionPerformed(ActionEvent arg0) { 327 MapillaryFilterDialog.this.signChooser 328 .setEnabled(MapillaryFilterDialog.this.onlySigns.isSelected()); 308 signChooser.setEnabled(onlySigns.isSelected()); 329 309 } 330 310 } … … 360 340 * Destroys the unique instance of the class. 361 341 */ 362 public static void destroyInstance() {363 MapillaryFilterDialog.INSTANCE= null;342 public static synchronized void destroyInstance() { 343 instance = null; 364 344 } 365 345 }
Note:
See TracChangeset
for help on using the changeset viewer.