Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java	(revision 31352)
@@ -203,5 +203,5 @@
     SimpleDateFormat formatter = new SimpleDateFormat(format);
     try {
-      Date dateTime = (Date) formatter.parse(date);
+      Date dateTime = formatter.parse(date);
       return dateTime.getTime();
     } catch (ParseException e) {
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java	(revision 31352)
@@ -6,5 +6,5 @@
 /**
  * A MapillaryImage object represents each of the images stored in Mapillary.
- * 
+ *
  * @author nokutu
  * @see MapillarySequence
@@ -33,5 +33,5 @@
   /**
    * Main contructor of the class MapillaryImage
-   * 
+   *
    * @param key
    *          The unique identifier of the image.
@@ -51,5 +51,5 @@
   /**
    * Returns the unique identifier of the object.
-   * 
+   *
    * @return A String containing the unique identifier of the object.
    */
@@ -60,5 +60,5 @@
   /**
    * Adds a new sign to the set of signs.
-   * 
+   *
    * @param sign
    *          A String that identifies the type of sign.
@@ -70,5 +70,5 @@
   /**
    * Returns a List containing the signs assigned to this image.
-   * 
+   *
    * @return A List object containing the signs assigned to this image.
    */
@@ -79,5 +79,5 @@
   /**
    * Sets the username of the person who took the image.
-   * 
+   *
    * @param user
    *          A String containing the username of the person who took the image.
@@ -93,5 +93,5 @@
   /**
    * Sets the MapillarySequence object which contains the MapillaryImage.
-   * 
+   *
    * @param sequence
    *          The MapillarySequence that contains the MapillaryImage.
@@ -103,5 +103,5 @@
   /**
    * Returns the sequence which contains this image.
-   * 
+   *
    * @return The MapillarySequence object that contains this MapillaryImage.
    */
@@ -110,4 +110,5 @@
   }
 
+  @Override
   public String toString() {
     return "Image[key=" + this.key + ";lat=" + this.latLon.lat() + ";lon="
@@ -118,5 +119,5 @@
    * If the MapillaryImage belongs to a MapillarySequence, returns the next
    * MapillarySequence in it.
-   * 
+   *
    * @return The following MapillaryImage, or null if there is none.
    */
@@ -132,5 +133,5 @@
    * If the MapillaryImage belongs to a MapillarySequence, returns the previous
    * MapillarySequence in it.
-   * 
+   *
    * @return The previous MapillaryImage, or null if there is none.
    */
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/actions/MapillaryImportAction.java	(revision 31352)
@@ -45,8 +45,7 @@
   public MapillaryImportAction() {
     super(tr("Import pictures"), new ImageProvider("icon24.png"),
-        tr("Import local pictures"), Shortcut.registerShortcut(
-            "Import Mapillary", tr("Import pictures into Mapillary layer"),
-            KeyEvent.CHAR_UNDEFINED, Shortcut.NONE), false, "mapillaryImport",
-        false);
+        tr("Import local pictures"), Shortcut.registerShortcut("Import Mapillary",
+            tr("Import pictures into Mapillary layer"), KeyEvent.CHAR_UNDEFINED, Shortcut.NONE),
+        false, "mapillaryImport", false);
     this.setEnabled(false);
   }
@@ -55,23 +54,17 @@
   public void actionPerformed(ActionEvent e) {
     chooser = new JFileChooser();
-    chooser.setCurrentDirectory(new java.io.File(System
-        .getProperty("user.home")));
+    chooser.setCurrentDirectory(new java.io.File(System.getProperty("user.home")));
     chooser.setDialogTitle(tr("Select pictures"));
     chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
     chooser.setAcceptAllFileFilterUsed(false);
-    chooser.addChoosableFileFilter(new FileNameExtensionFilter("images", "jpg",
-        "jpeg", "png"));
+    chooser.addChoosableFileFilter(new FileNameExtensionFilter("images", "jpg", "jpeg", "png"));
     chooser.setMultiSelectionEnabled(true);
     if (chooser.showOpenDialog(Main.parent) == JFileChooser.APPROVE_OPTION) {
       for (int i = 0; i < chooser.getSelectedFiles().length; i++) {
         File file = chooser.getSelectedFiles()[i];
-        if (file.isDirectory()) {
-
-        } else {
+        if (!file.isDirectory()) {
           MapillaryLayer.getInstance();
-          if (file.getPath().substring(file.getPath().length() - 4)
-              .equals(".jpg")
-              || file.getPath().substring(file.getPath().length() - 5)
-                  .equals(".jpeg")) {
+          if (file.getPath().substring(file.getPath().length() - 4).equals(".jpg")
+              || file.getPath().substring(file.getPath().length() - 5).equals(".jpeg")) {
             try {
               readJPG(file);
@@ -81,6 +74,5 @@
               Main.error(ex);
             }
-          } else if (file.getPath().substring(file.getPath().length() - 4)
-              .equals(".png")) {
+          } else if (file.getPath().substring(file.getPath().length() - 4).equals(".png")) {
             readPNG(file);
           }
@@ -102,14 +94,9 @@
     if (metadata instanceof JpegImageMetadata) {
       final JpegImageMetadata jpegMetadata = (JpegImageMetadata) metadata;
-      final TiffField lat_ref = jpegMetadata
-          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF);
-      final TiffField lat = jpegMetadata
-          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE);
-      final TiffField lon_ref = jpegMetadata
-          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF);
-      final TiffField lon = jpegMetadata
-          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE);
-      final TiffField ca = jpegMetadata
-          .findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION);
+      final TiffField lat_ref = jpegMetadata.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF);
+      final TiffField lat = jpegMetadata.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LATITUDE);
+      final TiffField lon_ref = jpegMetadata.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF);
+      final TiffField lon = jpegMetadata.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_LONGITUDE);
+      final TiffField ca = jpegMetadata.findEXIFValueWithExactMatch(GpsTagConstants.GPS_TAG_GPS_IMG_DIRECTION);
       final TiffField datetimeOriginal = jpegMetadata
           .findEXIFValueWithExactMatch(ExifTagConstants.EXIF_TAG_DATE_TIME_ORIGINAL);
@@ -121,23 +108,15 @@
       double lonValue = 0;
       double caValue = 0;
-      if (lat != null && lat.getValue() instanceof RationalNumber[])
-        latValue = DegMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref
-            .getValue().toString());
-      if (lon != null && lon.getValue() instanceof RationalNumber[])
-        lonValue = DegMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref
-            .getValue().toString());
+      if (lat.getValue() instanceof RationalNumber[])
+        latValue = degMinSecToDouble((RationalNumber[]) lat.getValue(), lat_ref.getValue().toString());
+      if (lon.getValue() instanceof RationalNumber[])
+        lonValue = degMinSecToDouble((RationalNumber[]) lon.getValue(), lon_ref.getValue().toString());
       if (ca != null && ca.getValue() instanceof RationalNumber)
         caValue = ((RationalNumber) ca.getValue()).doubleValue();
-      if (lat_ref.getValue().toString().equals("S"))
-        latValue = -latValue;
-      if (lon_ref.getValue().toString().equals("W"))
-        lonValue = -lonValue;
       if (datetimeOriginal != null)
-        MapillaryData.getInstance().add(
-            new MapillaryImportedImage(latValue, lonValue, caValue, file,
-                datetimeOriginal.getStringValue()));
+        MapillaryData.getInstance()
+            .add(new MapillaryImportedImage(latValue, lonValue, caValue, file, datetimeOriginal.getStringValue()));
       else
-        MapillaryData.getInstance().add(
-            new MapillaryImportedImage(latValue, lonValue, caValue, file));
+        MapillaryData.getInstance().add(new MapillaryImportedImage(latValue, lonValue, caValue, file));
     }
   }
@@ -156,8 +135,6 @@
     else
       horDev = -HORIZONTAL_DISTANCE * ((noTagsPics + 1) / 2);
-    LatLon pos = Main.map.mapView.getProjection().eastNorth2latlon(
-        Main.map.mapView.getCenter());
-    MapillaryData.getInstance().add(
-        new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0, file));
+    LatLon pos = Main.map.mapView.getProjection().eastNorth2latlon(Main.map.mapView.getCenter());
+    MapillaryData.getInstance().add(new MapillaryImportedImage(pos.lat(), pos.lon() + horDev, 0, file));
     noTagsPics++;
   }
@@ -167,10 +144,42 @@
   }
 
-  private double DegMinSecToDouble(RationalNumber[] degMinSec, String ref) {
-    RationalNumber deg = degMinSec[0];
-    RationalNumber min = degMinSec[1];
-    RationalNumber sec = degMinSec[2];
-    return deg.doubleValue() + min.doubleValue() / 60 + sec.doubleValue()
-        / 3600;
+  /**
+   * Calculates the decimal degree-value from a degree value given in degrees-minutes-seconds-format
+   *
+   * @param degMinSec an array of length 3, the values in there are (in this order) degrees, minutes and seconds
+   * @param ref the latitude or longitude reference determining if the given value is:
+   *        <ul>
+   *        <li>north ({@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH}) or
+   *        south ({@link GpsTagConstants#GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH}) of the equator</li>
+   *        <li>east ({@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST}) or
+   *        west ({@link GpsTagConstants#GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST}) of the equator</li>
+   *        </ul>
+   * @return the decimal degree-value for the given input, negative when west of 0-meridian or south of equator,
+   *         positive otherwise
+   * @throws IllegalArgumentException if {@code degMinSec} doesn't have length 3 or if {@code ref} is not one of the
+   *         values mentioned above
+   */
+  private static double degMinSecToDouble(RationalNumber[] degMinSec, String ref) {
+    if (degMinSec == null || degMinSec.length != 3) { throw new IllegalArgumentException(); }
+    switch (ref) {
+    case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH:
+    case GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH:
+    case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST:
+    case GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST:
+      break;
+    default:
+      throw new IllegalArgumentException();
+    }
+
+    double result = degMinSec[0].doubleValue(); // degrees
+    result += degMinSec[1].doubleValue() / 60; // minutes
+    result += degMinSec[2].doubleValue() / 3600; // seconds
+
+    if (ref == GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH
+        || ref == GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST) {
+      result *= -1;
+    }
+
+    return result;
   }
 }
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandMoveImage.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandMoveImage.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandMoveImage.java	(revision 31352)
@@ -11,5 +11,5 @@
 /**
  * Command created when an image's position is changed.
- * 
+ *
  * @author nokutu
  *
@@ -46,4 +46,5 @@
   }
 
+  @Override
   public String toString() {
     return trn("Moved {0} image", "Moved {0} images", images.size(),
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandTurnImage.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandTurnImage.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/commands/CommandTurnImage.java	(revision 31352)
@@ -11,5 +11,5 @@
 /**
  * Command created when an image's direction is changed.
- * 
+ *
  * @author nokutu
  *
@@ -43,4 +43,5 @@
   }
 
+  @Override
   public String toString() {
     return trn("Turned {0} image", "Turned {0} images", this.images.size(),
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryExportManager.java	(revision 31352)
@@ -26,5 +26,5 @@
  * {@link ArrayBlockingQueue}. Then it is picked by the first one and written on
  * the selected folder. Each image will be named by its key.
- * 
+ *
  * @author nokutu
  *
@@ -55,5 +55,5 @@
   /**
    * Constructor used to rewrite imported images.
-   * 
+   *
    * @param images
    * @throws IOException
@@ -106,5 +106,5 @@
         try {
           queue.put(((MapillaryImportedImage) image).getImage());
-          queueImages.put((MapillaryImportedImage) image);
+          queueImages.put(image);
         } catch (InterruptedException e) {
           Main.error(e);
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloaderThread.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloaderThread.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillaryImageInfoDownloaderThread.java	(revision 31352)
@@ -36,4 +36,5 @@
   }
 
+  @Override
   public void run() {
     try {
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java	(revision 31352)
@@ -46,4 +46,5 @@
   }
 
+  @Override
   public void run() {
     try {
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java	(revision 31352)
@@ -16,7 +16,7 @@
  * the Mapillary API has a parameter called page which is needed when the amount
  * of requested images is quite big.
- * 
+ *
  * @author nokutu
- * 
+ *
  * @see MapillaryDownloader
  */
@@ -29,6 +29,6 @@
   public boolean imagesAdded = false;
 
-  public MapillarySquareDownloadManagerThread(String urlImages,
-      String urlSequences, String urlSigns, MapillaryLayer layer) {
+  public MapillarySquareDownloadManagerThread(String urlImages, String urlSequences, String urlSigns,
+      MapillaryLayer layer) {
     this.urlImages = urlImages;
     this.urlSequences = urlSequences;
@@ -37,4 +37,5 @@
   }
 
+  @Override
   public void run() {
     Main.map.statusLine.setHelpText("Downloading images from Mapillary");
@@ -52,6 +53,5 @@
     }
     if (layer.data.getImages().size() > 0)
-      Main.map.statusLine.setHelpText(tr("Total images: ")
-          + layer.data.getImages().size());
+      Main.map.statusLine.setHelpText(tr("Total images: ") + layer.data.getImages().size());
     else
       Main.map.statusLine.setHelpText(tr("No images found"));
@@ -62,10 +62,8 @@
 
   private void downloadSequences() throws InterruptedException {
-    ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS,
-        new ArrayBlockingQueue<Runnable>(5));
+    ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
     int page = 0;
     while (!ex.isShutdown()) {
-      ex.execute(new MapillarySequenceDownloadThread(ex, urlSequences
-          + "&page=" + page + "&limit=10", layer, this));
+      ex.execute(new MapillarySequenceDownloadThread(ex, urlSequences + "&page=" + page + "&limit=10", layer, this));
       while (ex.getQueue().remainingCapacity() == 0)
         Thread.sleep(500);
@@ -77,10 +75,8 @@
 
   private void completeImages() throws InterruptedException {
-    ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS,
-        new ArrayBlockingQueue<Runnable>(5));
+    ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
     int page = 0;
     while (!ex.isShutdown()) {
-      ex.execute(new MapillaryImageInfoDownloaderThread(ex, urlImages
-          + "&page=" + page + "&limit=20", layer));
+      ex.execute(new MapillaryImageInfoDownloaderThread(ex, urlImages + "&page=" + page + "&limit=20", layer));
       while (ex.getQueue().remainingCapacity() == 0)
         Thread.sleep(100);
@@ -91,10 +87,8 @@
 
   private void downloadSigns() throws InterruptedException {
-    ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS,
-        new ArrayBlockingQueue<Runnable>(5));
+    ThreadPoolExecutor ex = new ThreadPoolExecutor(3, 5, 25, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(5));
     int page = 0;
     while (!ex.isShutdown()) {
-      ex.execute(new MapillarySignDownloaderThread(ex, urlSigns + "&page="
-          + page + "&limit=20", layer));
+      ex.execute(new MapillarySignDownloaderThread(ex, urlSigns + "&page=" + page + "&limit=20", layer));
       while (ex.getQueue().remainingCapacity() == 0)
         Thread.sleep(100);
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/HyperlinkLabel.java	(revision 31352)
@@ -38,4 +38,5 @@
    * Sets the text of the label.
    */
+  @Override
   public void setText(String text) {
     super
@@ -46,5 +47,5 @@
   /**
    * Sets a new URL, just pass the key of the image or null if there is none.
-   * 
+   *
    * @param key
    */
@@ -71,4 +72,5 @@
    * Processes mouse events and responds to clicks.
    */
+  @Override
   protected void processMouseEvent(MouseEvent evt) {
     super.processMouseEvent(evt);
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java	(revision 31352)
@@ -26,5 +26,5 @@
  * This object is a responsible JComponent which lets you zoom and drag. It is
  * included in a {@link MapillaryMainDialog} object.
- * 
+ *
  * @author Jorge
  * @see MapillaryImageDisplay
@@ -341,5 +341,5 @@
   /**
    * Sets a new picture to be displayed.
-   * 
+   *
    * @param image
    */
@@ -357,5 +357,5 @@
   /**
    * Returns the picture that is being displayerd
-   * 
+   *
    * @return
    */
@@ -367,4 +367,5 @@
    * Paints the visible part of the picture.
    */
+  @Override
   public void paintComponent(Graphics g) {
     Image image;
Index: /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryOAuthUI.java
===================================================================
--- /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryOAuthUI.java	(revision 31351)
+++ /applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryOAuthUI.java	(revision 31352)
@@ -14,5 +14,5 @@
 /**
  * JPanel used to get the OAuth tokens from Mapillary.
- * 
+ *
  * @author nokutu
  *
@@ -37,4 +37,5 @@
     System.out.print(">>");
     Verifier verifier = new Verifier(in.nextLine());
+    in.close();
     System.out.println();
   }
