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 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryAbstractImage.java	(revision 31333)
@@ -23,6 +23,6 @@
     public static Lock lock = new ReentrantLock();
 
+    /** The time the image was captured, in Epoch format */
     private long capturedAt;
-
     /** Position of the picture */
     public final LatLon latLon;
@@ -78,5 +78,5 @@
      * Returns whether the image is visible on the map or not.
      * 
-     * @return
+     * @return True if the image is visible; false otherwise.
      */
     public boolean isVisible() {
@@ -91,5 +91,5 @@
      * Returns the last fixed coordinates of the object.
      * 
-     * @return
+     * @return A LatLon object containing.
      */
     public LatLon getTempLatLon() {
@@ -101,5 +101,7 @@
      * 
      * @param x
+     *            The movement of the image in longitude units.
      * @param y
+     *            The movement of the image in latitude units.
      */
     public void move(double x, double y) {
@@ -113,4 +115,5 @@
      * 
      * @param ca
+     *            The angle the image is moving.
      */
     public void turn(double ca) {
@@ -140,5 +143,5 @@
      * Returns the last fixed direction of the object.
      * 
-     * @return
+     * @return The last fixed direction of the object. 0 means north.
      */
     public double getTempCa() {
@@ -149,5 +152,5 @@
      * Returns the date the picture was taken in DMY format.
      * 
-     * @return
+     * @return A String object containing the date when the picture was taken.
      */
     public String getDate() {
@@ -192,6 +195,8 @@
      * 
      * @param date
+     *            The string containing the date.
      * @param format
-     * @return
+     *            The format of the date.
+     * @return The date in Epoch format.
      */
     public long getEpoch(String date, String format) {
@@ -210,5 +215,5 @@
      * Returns current time in Epoch format
      * 
-     * @return
+     * @return The current date in Epoch format.
      */
     private long currentTime() {
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java	(revision 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryData.java	(revision 31333)
@@ -93,9 +93,10 @@
 
     /**
-     * Sets the image under the mouse cursor.
-     * 
-     * @param image
-     */
-    public void setHoveredImage(MapillaryAbstractImage image) {
+     * Highlights the image under the cursor.
+     * 
+     * @param image
+     *            The image under the cursor.
+     */
+    public void setHighlightedImage(MapillaryAbstractImage image) {
         highlightedImage = image;
     }
@@ -104,5 +105,5 @@
      * Returns the image under the mouse cursor.
      * 
-     * @return
+     * @return The image under the mouse cursor.
      */
     public MapillaryAbstractImage getHoveredImage() {
@@ -210,7 +211,8 @@
 
     /**
-     * Selects a new image and then starts a new MapillaryImageDownloadThread
-     * thread in order to download its surrounding thumbnails. If the user does
-     * ctrl+click, this isn't triggered.
+     * Selects a new image and then starts a new
+     * {@link MapillaryImageDownloadThread} thread in order to download its
+     * surrounding thumbnails. If the user does ctrl+click, this isn't
+     * triggered.
      * 
      * @param image
@@ -222,11 +224,15 @@
 
     /**
-     * Selects a new image and then starts a new MapillaryImageDownloadThread
-     * thread in order to download its surrounding thumbnails. If the user does
-     * ctrl+click, this isn't triggered. You can choose whether to center the
-     * view on the new image or not.
-     * 
-     * @param image
+     * Selects a new image and then starts a new
+     * {@link MapillaryImageDownloadThread} thread in order to download its
+     * surrounding thumbnails. If the user does ctrl+click, this isn't
+     * triggered. You can choose whether to center the view on the new image or
+     * not.
+     * 
+     * @param image
+     *            The {@link MapillaryImage} which is going to be selected.
      * @param zoom
+     *            True if the view must be centered on the image; false
+     *            otherwise.
      */
     public void setSelectedImage(MapillaryAbstractImage image, boolean zoom) {
@@ -291,7 +297,9 @@
 
     /**
-     * Adds a set of MapillaryImage objects to the list of selected images.
+     * Adds a set of {@code MapillaryAbstractImage} objects to the list of
+     * selected images.
      * 
      * @param images
+     *            A List object containing the set of images to be added.
      */
     public void addMultiSelectedImage(List<MapillaryAbstractImage> images) {
@@ -307,8 +315,8 @@
 
     /**
-     * Returns a list containing all MapillaryImage objects selected with ctrl +
-     * click
-     * 
-     * @return
+     * Returns a List containing all {@code MapillaryAbstractImage} objects
+     * selected with ctrl + click
+     * 
+     * @return A List object containing all the images selected.
      */
     public List<MapillaryAbstractImage> getMultiSelectedImages() {
@@ -329,5 +337,5 @@
      * Returns the amount of images contained by this object.
      * 
-     * @return
+     * @return The amount of images in stored.
      */
     public int size() {
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryDataListener.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryDataListener.java	(revision 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryDataListener.java	(revision 31333)
@@ -3,4 +3,7 @@
 public interface MapillaryDataListener {
 
+    /**
+     * Fired when any image is added to the database.
+     */
     public void imagesAdded();
 
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 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImage.java	(revision 31333)
@@ -17,5 +17,4 @@
     private MapillarySequence sequence;
 
-    /** Epoch time when the image was taken. */
     /** The user that made the image */
     private String user;
@@ -63,4 +62,5 @@
      * 
      * @param sign
+     *            A String that identifies the type of sign.
      */
     public void addSign(String sign) {
@@ -68,8 +68,17 @@
     }
 
+    /**
+     * Returns a List containing the signs assigned to this image.
+     * 
+     * @return A List object containing the signs assigned to this image.
+     */
     public List<String> getSigns() {
         return signs;
     }
 
+    /**
+     * Sets the username of the person who took the image.
+     * @param user A String containing the username of the person who took the image.
+     */
     public void setUser(String user) {
         this.user = user;
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java	(revision 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryImportedImage.java	(revision 31333)
@@ -39,4 +39,8 @@
     }
 
+    /**
+     * Returns the File object where the picture is located.
+     * @return The File object where the picture is located.
+     */
     public File getFile() {
         return file;
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java	(revision 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryLayer.java	(revision 31333)
@@ -9,5 +9,5 @@
 import org.openstreetmap.josm.plugins.mapillary.downloads.MapillaryDownloader;
 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog;
-import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryToggleDialog;
+import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -110,6 +110,6 @@
         }
         MapillaryPlugin.setMenuEnabled(MapillaryPlugin.EXPORT_MENU, true);
-        if (!MapillaryToggleDialog.getInstance().isShowing())
-            MapillaryToggleDialog.getInstance().getButton().doClick();
+        if (!MapillaryMainDialog.getInstance().isShowing())
+            MapillaryMainDialog.getInstance().getButton().doClick();
         createHatchTexture();
         data.dataUpdated();
@@ -178,6 +178,6 @@
     @Override
     public void destroy() {
-        MapillaryToggleDialog.getInstance().setImage(null);
-        MapillaryToggleDialog.getInstance().updateImage();
+        MapillaryMainDialog.getInstance().setImage(null);
+        MapillaryMainDialog.getInstance().updateImage();
         data.getImages().clear();
         MapillaryLayer.INSTANCE = null;
@@ -278,6 +278,6 @@
         MapillaryLayer.BLUE = null;
         MapillaryLayer.RED = null;
-        MapillaryToggleDialog.getInstance().blueButton.setEnabled(false);
-        MapillaryToggleDialog.getInstance().redButton.setEnabled(false);
+        MapillaryMainDialog.getInstance().blueButton.setEnabled(false);
+        MapillaryMainDialog.getInstance().redButton.setEnabled(false);
 
         // Sets blue and red lines and enables/disables the buttons
@@ -291,5 +291,5 @@
                         mv.getPoint(closestImages[0].getLatLon()).y,
                         selected.x, selected.y);
-                MapillaryToggleDialog.getInstance().blueButton.setEnabled(true);
+                MapillaryMainDialog.getInstance().blueButton.setEnabled(true);
             }
             if (closestImages[1] != null) {
@@ -299,5 +299,5 @@
                         mv.getPoint(closestImages[1].getLatLon()).y,
                         selected.x, selected.y);
-                MapillaryToggleDialog.getInstance().redButton.setEnabled(true);
+                MapillaryMainDialog.getInstance().redButton.setEnabled(true);
             }
         }
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryMouseAdapter.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryMouseAdapter.java	(revision 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryMouseAdapter.java	(revision 31333)
@@ -13,5 +13,5 @@
 import org.openstreetmap.josm.plugins.mapillary.commands.CommandTurnImage;
 import org.openstreetmap.josm.plugins.mapillary.commands.MapillaryRecord;
-import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryToggleDialog;
+import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;
 
 /**
@@ -231,13 +231,13 @@
         if (MapillaryData.getInstance().getHoveredImage() != closestTemp
                 && closestTemp != null) {
-            MapillaryData.getInstance().setHoveredImage(closestTemp);
-            MapillaryToggleDialog.getInstance().setImage(closestTemp);
-            MapillaryToggleDialog.getInstance().updateImage();
+            MapillaryData.getInstance().setHighlightedImage(closestTemp);
+            MapillaryMainDialog.getInstance().setImage(closestTemp);
+            MapillaryMainDialog.getInstance().updateImage();
         } else if (MapillaryData.getInstance().getHoveredImage() != closestTemp
                 && closestTemp == null) {
-            MapillaryData.getInstance().setHoveredImage(null);
-            MapillaryToggleDialog.getInstance().setImage(
+            MapillaryData.getInstance().setHighlightedImage(null);
+            MapillaryMainDialog.getInstance().setImage(
                     MapillaryData.getInstance().getSelectedImage());
-            MapillaryToggleDialog.getInstance().updateImage();
+            MapillaryMainDialog.getInstance().updateImage();
         }
         MapillaryData.getInstance().dataUpdated();
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java	(revision 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/MapillaryPlugin.java	(revision 31333)
@@ -21,5 +21,5 @@
 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryHistoryDialog;
 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryPreferenceSetting;
-import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryToggleDialog;
+import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;
 import org.openstreetmap.josm.plugins.mapillary.actions.*;
 import org.openstreetmap.josm.tools.ImageProvider;
@@ -101,5 +101,5 @@
     public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
         if (oldFrame == null && newFrame != null) { // map frame added
-            Main.map.addToggleDialog(MapillaryToggleDialog.getInstance(), false);
+            Main.map.addToggleDialog(MapillaryMainDialog.getInstance(), false);
             Main.map.addToggleDialog(MapillaryHistoryDialog.getInstance(),
                     false);
@@ -111,5 +111,5 @@
         }
         if (oldFrame != null && newFrame == null) { // map frame destroyed
-            MapillaryToggleDialog.destroyInstance();
+            MapillaryMainDialog.destroyInstance();
             MapillaryHistoryDialog.destroyInstance();
             MapillaryFilterDialog.destroyInstance();
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 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySequenceDownloadThread.java	(revision 31333)
@@ -120,8 +120,7 @@
 
     private boolean isInside(MapillaryAbstractImage image) {
-        for (int i = 0; i < bounds.size(); i++) {
+        for (int i = 0; i < bounds.size(); i++)
             if (bounds.get(i).contains(image.getLatLon()))
                 return true;
-        }
         return false;
     }
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 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/downloads/MapillarySquareDownloadManagerThread.java	(revision 31333)
@@ -10,5 +10,5 @@
 import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
 import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryFilterDialog;
-import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryToggleDialog;
+import org.openstreetmap.josm.plugins.mapillary.gui.MapillaryMainDialog;
 
 /**
@@ -45,5 +45,5 @@
                         .setHelpText("Downloading image's information");
                 completeImages();
-                MapillaryToggleDialog.getInstance().updateTitle();
+                MapillaryMainDialog.getInstance().updateTitle();
                 Main.map.statusLine.setHelpText("Downloading signs");
                 downloadSigns();
@@ -59,5 +59,5 @@
         layer.data.dataUpdated();
         MapillaryFilterDialog.getInstance().refresh();
-        MapillaryToggleDialog.getInstance().updateImage();
+        MapillaryMainDialog.getInstance().updateImage();
     }
 
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 31332)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryImageDisplay.java	(revision 31333)
@@ -25,9 +25,9 @@
 /**
  * This object is a responsible JComponent which lets you zoom and drag. It is
- * included in a {@link MapillaryToggleDialog} object.
+ * included in a {@link MapillaryMainDialog} object.
  * 
  * @author Jorge
  * @see MapillaryImageDisplay
- * @see MapillaryToggleDialog
+ * @see MapillaryMainDialog
  */
 public class MapillaryImageDisplay extends JComponent {
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java	(revision 31333)
+++ applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryMainDialog.java	(revision 31333)
@@ -0,0 +1,410 @@
+package org.openstreetmap.josm.plugins.mapillary.gui;
+
+import static org.openstreetmap.josm.tools.I18n.tr;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.KeyEvent;
+import java.awt.image.BufferedImage;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.FlowLayout;
+import java.awt.GridLayout;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+
+import org.openstreetmap.josm.Main;
+import org.openstreetmap.josm.data.cache.CacheEntry;
+import org.openstreetmap.josm.data.cache.CacheEntryAttributes;
+import org.openstreetmap.josm.data.cache.ICachedLoaderListener;
+import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
+import org.openstreetmap.josm.gui.SideButton;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
+import org.openstreetmap.josm.plugins.mapillary.cache.MapillaryCache;
+import org.openstreetmap.josm.tools.Shortcut;
+
+import javax.imageio.ImageIO;
+import javax.swing.JComponent;
+import javax.swing.KeyStroke;
+import javax.swing.SwingUtilities;
+import javax.swing.AbstractAction;
+import javax.swing.JPanel;
+
+/**
+ * Toggle dialog that shows an image and some buttons.
+ * 
+ * @author nokutu
+ *
+ */
+public class MapillaryMainDialog extends ToggleDialog implements
+        ICachedLoaderListener, MapillaryDataListener {
+
+    public final static String BASE_TITLE = "Mapillary picture";
+
+    public static MapillaryMainDialog INSTANCE;
+
+    public volatile MapillaryAbstractImage image;
+
+    public final SideButton nextButton = new SideButton(new nextPictureAction());
+    public final SideButton previousButton = new SideButton(
+            new previousPictureAction());
+    public final SideButton redButton = new SideButton(new redAction());
+    public final SideButton blueButton = new SideButton(new blueAction());
+
+    private JPanel buttonsPanel;
+
+    public MapillaryImageDisplay mapillaryImageDisplay;
+
+    private MapillaryCache imageCache;
+    private MapillaryCache thumbnailCache;
+
+    public MapillaryMainDialog() {
+        super(tr(BASE_TITLE), "mapillary.png", tr("Open Mapillary window"),
+                Shortcut.registerShortcut(tr("Mapillary dialog"),
+                        tr("Open Mapillary main dialog"), KeyEvent.VK_M,
+                        Shortcut.NONE), 200, false,
+                MapillaryPreferenceSetting.class);
+        MapillaryData.getInstance().addListener(this);
+        addShortcuts();
+        mapillaryImageDisplay = new MapillaryImageDisplay();
+
+        blueButton.setForeground(Color.BLUE);
+        redButton.setForeground(Color.RED);
+
+        createLayout(
+                mapillaryImageDisplay,
+                Arrays.asList(new SideButton[] { blueButton, previousButton,
+                        nextButton, redButton }),
+                Main.pref.getBoolean("mapillary.reverse-buttons"));
+        disableAllButtons();
+
+    }
+
+    /**
+     * Adds the shortcuts to the buttons.
+     */
+    private void addShortcuts() {
+        nextButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+                KeyStroke.getKeyStroke("PAGE_DOWN"), "next");
+        nextButton.getActionMap().put("next", new nextPictureAction());
+        previousButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+                KeyStroke.getKeyStroke("PAGE_UP"), "previous");
+        previousButton.getActionMap().put("previous",
+                new previousPictureAction());
+        blueButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+                KeyStroke.getKeyStroke("control PAGE_UP"), "blue");
+        blueButton.getActionMap().put("blue", new blueAction());
+        redButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
+                KeyStroke.getKeyStroke("control PAGE_DOWN"), "red");
+        redButton.getActionMap().put("red", new redAction());
+    }
+
+    public static MapillaryMainDialog getInstance() {
+        if (INSTANCE == null)
+            INSTANCE = new MapillaryMainDialog();
+        return INSTANCE;
+    }
+
+    public static void destroyInstance() {
+        INSTANCE = null;
+    }
+
+    /**
+     * Downloads the image of the selected MapillaryImage and sets in the
+     * MapillaryImageDisplay object.
+     */
+    public synchronized void updateImage() {
+        if (!SwingUtilities.isEventDispatchThread()) {
+            SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                    updateImage();
+                }
+            });
+        } else {
+            if (MapillaryLayer.INSTANCE == null) {
+                return;
+            }
+            if (this.image == null) {
+                mapillaryImageDisplay.setImage(null);
+                setTitle(tr(BASE_TITLE));
+                disableAllButtons();
+                return;
+            }
+            if (image instanceof MapillaryImage) {
+                mapillaryImageDisplay.hyperlink.setVisible(true);
+                MapillaryImage mapillaryImage = (MapillaryImage) this.image;
+                updateTitle();
+                // Enables/disables next/previous buttons
+                this.nextButton.setEnabled(false);
+                this.previousButton.setEnabled(false);
+                if (((MapillaryImage) image).getSequence() != null) {
+                    MapillaryImage tempImage = (MapillaryImage) image;
+                    while (tempImage.next() != null) {
+                        tempImage = tempImage.next();
+                        if (tempImage.isVisible()) {
+                            this.nextButton.setEnabled(true);
+                            break;
+                        }
+                    }
+                }
+                if (((MapillaryImage) image).getSequence() != null) {
+                    MapillaryImage tempImage = (MapillaryImage) image;
+                    while (tempImage.previous() != null) {
+                        tempImage = tempImage.previous();
+                        if (tempImage.isVisible()) {
+                            this.previousButton.setEnabled(true);
+                            break;
+                        }
+                    }
+                }
+
+                mapillaryImageDisplay.hyperlink.setURL(mapillaryImage.getKey());
+                // Downloads the thumbnail.
+                this.mapillaryImageDisplay.setImage(null);
+                if (thumbnailCache != null)
+                    thumbnailCache.cancelOutstandingTasks();
+                thumbnailCache = new MapillaryCache(mapillaryImage.getKey(),
+                        MapillaryCache.Type.THUMBNAIL);
+                thumbnailCache.submit(this, false);
+
+                // Downloads the full resolution image.
+                if (imageCache != null)
+                    imageCache.cancelOutstandingTasks();
+                imageCache = new MapillaryCache(mapillaryImage.getKey(),
+                        MapillaryCache.Type.FULL_IMAGE);
+                imageCache.submit(this, false);
+            } else if (image instanceof MapillaryImportedImage) {
+                mapillaryImageDisplay.hyperlink.setVisible(false);
+                this.nextButton.setEnabled(false);
+                this.previousButton.setEnabled(false);
+                MapillaryImportedImage mapillaryImage = (MapillaryImportedImage) this.image;
+                try {
+                    mapillaryImageDisplay.setImage(mapillaryImage.getImage());
+                } catch (IOException e) {
+                    Main.error(e);
+                }
+                mapillaryImageDisplay.hyperlink.setURL(null);
+            }
+        }
+    }
+
+    private void disableAllButtons() {
+        nextButton.setEnabled(false);
+        previousButton.setEnabled(false);
+        blueButton.setEnabled(false);
+        redButton.setEnabled(false);
+        mapillaryImageDisplay.hyperlink.setVisible(false);
+    }
+
+    /**
+     * Sets a new MapillaryImage to be shown.
+     * 
+     * @param image
+     */
+    public synchronized void setImage(MapillaryAbstractImage image) {
+        this.image = image;
+    }
+
+    public synchronized void updateTitle() {
+        if (!SwingUtilities.isEventDispatchThread()) {
+            SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                    updateTitle();
+                }
+            });
+        } else {
+            if (this.image != null) {
+                MapillaryImage mapillaryImage = (MapillaryImage) this.image;
+                String title = tr(BASE_TITLE);
+                if (mapillaryImage.getUser() != null)
+                    title += " -- " + mapillaryImage.getUser();
+                if (mapillaryImage.getCapturedAt() != 0)
+                    title += " -- " + mapillaryImage.getDate();
+                setTitle(title);
+            }
+        }
+    }
+
+    /**
+     * Returns the MapillaryImage objects which is being shown.
+     * 
+     * @return
+     */
+    public synchronized MapillaryAbstractImage getImage() {
+        return this.image;
+    }
+
+    /**
+     * Action class form the next image button.
+     * 
+     * @author Jorge
+     *
+     */
+    class nextPictureAction extends AbstractAction {
+        public nextPictureAction() {
+            putValue(NAME, tr("Next picture"));
+            putValue(SHORT_DESCRIPTION,
+                    tr("Shows the next picture in the sequence"));
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            if (MapillaryMainDialog.getInstance().getImage() != null) {
+                MapillaryData.getInstance().selectNext();
+            }
+        }
+    }
+
+    /**
+     * Action class for the previous image button.
+     * 
+     * @author Jorge
+     *
+     */
+    class previousPictureAction extends AbstractAction {
+        public previousPictureAction() {
+            putValue(NAME, tr("Previous picture"));
+            putValue(SHORT_DESCRIPTION,
+                    tr("Shows the previous picture in the sequence"));
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            if (MapillaryMainDialog.getInstance().getImage() != null) {
+                MapillaryData.getInstance().selectPrevious();
+            }
+        }
+    }
+
+    /**
+     * Action class to jump to the image following the red line.
+     * 
+     * @author nokutu
+     *
+     */
+    class redAction extends AbstractAction {
+        public redAction() {
+            putValue(NAME, tr("Jump to red"));
+            putValue(
+                    SHORT_DESCRIPTION,
+                    tr("Jumps to the picture at the other side of the red line"));
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            if (MapillaryMainDialog.getInstance().getImage() != null) {
+                MapillaryData.getInstance().setSelectedImage(
+                        MapillaryLayer.RED, true);
+            }
+        }
+    }
+
+    /**
+     * Action class to jump to the image following the blue line.
+     * 
+     * @author nokutu
+     *
+     */
+    class blueAction extends AbstractAction {
+        public blueAction() {
+            putValue(NAME, tr("Jump to blue"));
+            putValue(
+                    SHORT_DESCRIPTION,
+                    tr("Jumps to the picture at the other side of the blue line"));
+        }
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            if (MapillaryMainDialog.getInstance().getImage() != null) {
+                MapillaryData.getInstance().setSelectedImage(
+                        MapillaryLayer.BLUE, true);
+            }
+        }
+    }
+
+    /**
+     * When the pictures are returned from the cache, they are set in the
+     * {@link MapillaryImageDisplay} object.
+     */
+    @Override
+    public void loadingFinished(final CacheEntry data,
+            final CacheEntryAttributes attributes, final LoadResult result) {
+        if (!SwingUtilities.isEventDispatchThread()) {
+            SwingUtilities.invokeLater(new Runnable() {
+                @Override
+                public void run() {
+                    loadingFinished(data, attributes, result);
+                }
+            });
+        } else if (data != null && result == LoadResult.SUCCESS) {
+            try {
+                BufferedImage img = ImageIO.read(new ByteArrayInputStream(data
+                        .getContent()));
+                if (img == null)
+                    return;
+                if (this.mapillaryImageDisplay.getImage() == null)
+                    mapillaryImageDisplay.setImage(img);
+                else if (img.getHeight() > this.mapillaryImageDisplay
+                        .getImage().getHeight()) {
+                    mapillaryImageDisplay.setImage(img);
+                }
+            } catch (IOException e) {
+                Main.error(e);
+            }
+        }
+    }
+
+    /**
+     * Creates the layout of the dialog.
+     * 
+     * @param data
+     *            The content of the dialog
+     * @param buttons
+     *            The buttons where you can click
+     * @param reverse
+     *            {@code true} if the buttons should go at the top;
+     *            {@code false} otherwise.
+     */
+    public void createLayout(Component data, List<SideButton> buttons,
+            boolean reverse) {
+        this.removeAll();
+        JPanel panel = new JPanel();
+        panel.setLayout(new BorderLayout());
+        panel.add(data, BorderLayout.CENTER);
+        if (reverse) {
+            buttonsPanel = new JPanel(new GridLayout(1, 1));
+            if (!buttons.isEmpty() && buttons.get(0) != null) {
+                final JPanel buttonRowPanel = new JPanel(Main.pref.getBoolean(
+                        "dialog.align.left", false) ? new FlowLayout(
+                        FlowLayout.LEFT) : new GridLayout(1, buttons.size()));
+                buttonsPanel.add(buttonRowPanel);
+                for (SideButton button : buttons)
+                    buttonRowPanel.add(button);
+            }
+            panel.add(buttonsPanel, BorderLayout.NORTH);
+            createLayout(panel, true, null);
+        } else
+            createLayout(panel, true, buttons);
+        this.add(titleBar, BorderLayout.NORTH);
+    }
+
+    @Override
+    public void selectedImageChanged(MapillaryAbstractImage oldImage,
+            MapillaryAbstractImage newImage) {
+        setImage(MapillaryData.getInstance().getSelectedImage());
+        updateImage();
+    }
+
+    @Override
+    public void imagesAdded() {
+    }
+}
Index: applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryToggleDialog.java
===================================================================
--- applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/gui/MapillaryToggleDialog.java	(revision 31332)
+++ 	(revision )
@@ -1,410 +1,0 @@
-package org.openstreetmap.josm.plugins.mapillary.gui;
-
-import static org.openstreetmap.josm.tools.I18n.tr;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.KeyEvent;
-import java.awt.image.BufferedImage;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.FlowLayout;
-import java.awt.GridLayout;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-import org.openstreetmap.josm.Main;
-import org.openstreetmap.josm.data.cache.CacheEntry;
-import org.openstreetmap.josm.data.cache.CacheEntryAttributes;
-import org.openstreetmap.josm.data.cache.ICachedLoaderListener;
-import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
-import org.openstreetmap.josm.gui.SideButton;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryDataListener;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryImportedImage;
-import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
-import org.openstreetmap.josm.plugins.mapillary.cache.MapillaryCache;
-import org.openstreetmap.josm.tools.Shortcut;
-
-import javax.imageio.ImageIO;
-import javax.swing.JComponent;
-import javax.swing.KeyStroke;
-import javax.swing.SwingUtilities;
-import javax.swing.AbstractAction;
-import javax.swing.JPanel;
-
-/**
- * Toggle dialog that shows an image and some buttons.
- * 
- * @author nokutu
- *
- */
-public class MapillaryToggleDialog extends ToggleDialog implements
-        ICachedLoaderListener, MapillaryDataListener {
-
-    public final static String BASE_TITLE = "Mapillary picture";
-
-    public static MapillaryToggleDialog INSTANCE;
-
-    public volatile MapillaryAbstractImage image;
-
-    public final SideButton nextButton = new SideButton(new nextPictureAction());
-    public final SideButton previousButton = new SideButton(
-            new previousPictureAction());
-    public final SideButton redButton = new SideButton(new redAction());
-    public final SideButton blueButton = new SideButton(new blueAction());
-
-    private JPanel buttonsPanel;
-
-    public MapillaryImageDisplay mapillaryImageDisplay;
-
-    private MapillaryCache imageCache;
-    private MapillaryCache thumbnailCache;
-
-    public MapillaryToggleDialog() {
-        super(tr(BASE_TITLE), "mapillary.png", tr("Open Mapillary window"),
-                Shortcut.registerShortcut(tr("Mapillary dialog"),
-                        tr("Open Mapillary main dialog"), KeyEvent.VK_M,
-                        Shortcut.NONE), 200, false,
-                MapillaryPreferenceSetting.class);
-        MapillaryData.getInstance().addListener(this);
-        addShortcuts();
-        mapillaryImageDisplay = new MapillaryImageDisplay();
-
-        blueButton.setForeground(Color.BLUE);
-        redButton.setForeground(Color.RED);
-
-        createLayout(
-                mapillaryImageDisplay,
-                Arrays.asList(new SideButton[] { blueButton, previousButton,
-                        nextButton, redButton }),
-                Main.pref.getBoolean("mapillary.reverse-buttons"));
-        disableAllButtons();
-
-    }
-
-    /**
-     * Adds the shortcuts to the buttons.
-     */
-    private void addShortcuts() {
-        nextButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
-                KeyStroke.getKeyStroke("PAGE_DOWN"), "next");
-        nextButton.getActionMap().put("next", new nextPictureAction());
-        previousButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
-                KeyStroke.getKeyStroke("PAGE_UP"), "previous");
-        previousButton.getActionMap().put("previous",
-                new previousPictureAction());
-        blueButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
-                KeyStroke.getKeyStroke("control PAGE_UP"), "blue");
-        blueButton.getActionMap().put("blue", new blueAction());
-        redButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(
-                KeyStroke.getKeyStroke("control PAGE_DOWN"), "red");
-        redButton.getActionMap().put("red", new redAction());
-    }
-
-    public static MapillaryToggleDialog getInstance() {
-        if (INSTANCE == null)
-            INSTANCE = new MapillaryToggleDialog();
-        return INSTANCE;
-    }
-
-    public static void destroyInstance() {
-        INSTANCE = null;
-    }
-
-    /**
-     * Downloads the image of the selected MapillaryImage and sets in the
-     * MapillaryImageDisplay object.
-     */
-    public synchronized void updateImage() {
-        if (!SwingUtilities.isEventDispatchThread()) {
-            SwingUtilities.invokeLater(new Runnable() {
-                @Override
-                public void run() {
-                    updateImage();
-                }
-            });
-        } else {
-            if (MapillaryLayer.INSTANCE == null) {
-                return;
-            }
-            if (this.image == null) {
-                mapillaryImageDisplay.setImage(null);
-                setTitle(tr(BASE_TITLE));
-                disableAllButtons();
-                return;
-            }
-            if (image instanceof MapillaryImage) {
-                mapillaryImageDisplay.hyperlink.setVisible(true);
-                MapillaryImage mapillaryImage = (MapillaryImage) this.image;
-                updateTitle();
-                // Enables/disables next/previous buttons
-                this.nextButton.setEnabled(false);
-                this.previousButton.setEnabled(false);
-                if (((MapillaryImage) image).getSequence() != null) {
-                    MapillaryImage tempImage = (MapillaryImage) image;
-                    while (tempImage.next() != null) {
-                        tempImage = tempImage.next();
-                        if (tempImage.isVisible()) {
-                            this.nextButton.setEnabled(true);
-                            break;
-                        }
-                    }
-                }
-                if (((MapillaryImage) image).getSequence() != null) {
-                    MapillaryImage tempImage = (MapillaryImage) image;
-                    while (tempImage.previous() != null) {
-                        tempImage = tempImage.previous();
-                        if (tempImage.isVisible()) {
-                            this.previousButton.setEnabled(true);
-                            break;
-                        }
-                    }
-                }
-
-                mapillaryImageDisplay.hyperlink.setURL(mapillaryImage.getKey());
-                // Downloads the thumbnail.
-                this.mapillaryImageDisplay.setImage(null);
-                if (thumbnailCache != null)
-                    thumbnailCache.cancelOutstandingTasks();
-                thumbnailCache = new MapillaryCache(mapillaryImage.getKey(),
-                        MapillaryCache.Type.THUMBNAIL);
-                thumbnailCache.submit(this, false);
-
-                // Downloads the full resolution image.
-                if (imageCache != null)
-                    imageCache.cancelOutstandingTasks();
-                imageCache = new MapillaryCache(mapillaryImage.getKey(),
-                        MapillaryCache.Type.FULL_IMAGE);
-                imageCache.submit(this, false);
-            } else if (image instanceof MapillaryImportedImage) {
-                mapillaryImageDisplay.hyperlink.setVisible(false);
-                this.nextButton.setEnabled(false);
-                this.previousButton.setEnabled(false);
-                MapillaryImportedImage mapillaryImage = (MapillaryImportedImage) this.image;
-                try {
-                    mapillaryImageDisplay.setImage(mapillaryImage.getImage());
-                } catch (IOException e) {
-                    Main.error(e);
-                }
-                mapillaryImageDisplay.hyperlink.setURL(null);
-            }
-        }
-    }
-
-    private void disableAllButtons() {
-        nextButton.setEnabled(false);
-        previousButton.setEnabled(false);
-        blueButton.setEnabled(false);
-        redButton.setEnabled(false);
-        mapillaryImageDisplay.hyperlink.setVisible(false);
-    }
-
-    /**
-     * Sets a new MapillaryImage to be shown.
-     * 
-     * @param image
-     */
-    public synchronized void setImage(MapillaryAbstractImage image) {
-        this.image = image;
-    }
-
-    public synchronized void updateTitle() {
-        if (!SwingUtilities.isEventDispatchThread()) {
-            SwingUtilities.invokeLater(new Runnable() {
-                @Override
-                public void run() {
-                    updateTitle();
-                }
-            });
-        } else {
-            if (this.image != null) {
-                MapillaryImage mapillaryImage = (MapillaryImage) this.image;
-                String title = tr(BASE_TITLE);
-                if (mapillaryImage.getUser() != null)
-                    title += " -- " + mapillaryImage.getUser();
-                if (mapillaryImage.getCapturedAt() != 0)
-                    title += " -- " + mapillaryImage.getDate();
-                setTitle(title);
-            }
-        }
-    }
-
-    /**
-     * Returns the MapillaryImage objects which is being shown.
-     * 
-     * @return
-     */
-    public synchronized MapillaryAbstractImage getImage() {
-        return this.image;
-    }
-
-    /**
-     * Action class form the next image button.
-     * 
-     * @author Jorge
-     *
-     */
-    class nextPictureAction extends AbstractAction {
-        public nextPictureAction() {
-            putValue(NAME, tr("Next picture"));
-            putValue(SHORT_DESCRIPTION,
-                    tr("Shows the next picture in the sequence"));
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent e) {
-            if (MapillaryToggleDialog.getInstance().getImage() != null) {
-                MapillaryData.getInstance().selectNext();
-            }
-        }
-    }
-
-    /**
-     * Action class for the previous image button.
-     * 
-     * @author Jorge
-     *
-     */
-    class previousPictureAction extends AbstractAction {
-        public previousPictureAction() {
-            putValue(NAME, tr("Previous picture"));
-            putValue(SHORT_DESCRIPTION,
-                    tr("Shows the previous picture in the sequence"));
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent e) {
-            if (MapillaryToggleDialog.getInstance().getImage() != null) {
-                MapillaryData.getInstance().selectPrevious();
-            }
-        }
-    }
-
-    /**
-     * Action class to jump to the image following the red line.
-     * 
-     * @author nokutu
-     *
-     */
-    class redAction extends AbstractAction {
-        public redAction() {
-            putValue(NAME, tr("Jump to red"));
-            putValue(
-                    SHORT_DESCRIPTION,
-                    tr("Jumps to the picture at the other side of the red line"));
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent e) {
-            if (MapillaryToggleDialog.getInstance().getImage() != null) {
-                MapillaryData.getInstance().setSelectedImage(
-                        MapillaryLayer.RED, true);
-            }
-        }
-    }
-
-    /**
-     * Action class to jump to the image following the blue line.
-     * 
-     * @author nokutu
-     *
-     */
-    class blueAction extends AbstractAction {
-        public blueAction() {
-            putValue(NAME, tr("Jump to blue"));
-            putValue(
-                    SHORT_DESCRIPTION,
-                    tr("Jumps to the picture at the other side of the blue line"));
-        }
-
-        @Override
-        public void actionPerformed(ActionEvent e) {
-            if (MapillaryToggleDialog.getInstance().getImage() != null) {
-                MapillaryData.getInstance().setSelectedImage(
-                        MapillaryLayer.BLUE, true);
-            }
-        }
-    }
-
-    /**
-     * When the pictures are returned from the cache, they are set in the
-     * {@link MapillaryImageDisplay} object.
-     */
-    @Override
-    public void loadingFinished(final CacheEntry data,
-            final CacheEntryAttributes attributes, final LoadResult result) {
-        if (!SwingUtilities.isEventDispatchThread()) {
-            SwingUtilities.invokeLater(new Runnable() {
-                @Override
-                public void run() {
-                    loadingFinished(data, attributes, result);
-                }
-            });
-        } else if (data != null && result == LoadResult.SUCCESS) {
-            try {
-                BufferedImage img = ImageIO.read(new ByteArrayInputStream(data
-                        .getContent()));
-                if (img == null)
-                    return;
-                if (this.mapillaryImageDisplay.getImage() == null)
-                    mapillaryImageDisplay.setImage(img);
-                else if (img.getHeight() > this.mapillaryImageDisplay
-                        .getImage().getHeight()) {
-                    mapillaryImageDisplay.setImage(img);
-                }
-            } catch (IOException e) {
-                Main.error(e);
-            }
-        }
-    }
-
-    /**
-     * Creates the layout of the dialog.
-     * 
-     * @param data
-     *            The content of the dialog
-     * @param buttons
-     *            The buttons where you can click
-     * @param reverse
-     *            {@code true} if the buttons should go at the top;
-     *            {@code false} otherwise.
-     */
-    public void createLayout(Component data, List<SideButton> buttons,
-            boolean reverse) {
-        this.removeAll();
-        JPanel panel = new JPanel();
-        panel.setLayout(new BorderLayout());
-        panel.add(data, BorderLayout.CENTER);
-        if (reverse) {
-            buttonsPanel = new JPanel(new GridLayout(1, 1));
-            if (!buttons.isEmpty() && buttons.get(0) != null) {
-                final JPanel buttonRowPanel = new JPanel(Main.pref.getBoolean(
-                        "dialog.align.left", false) ? new FlowLayout(
-                        FlowLayout.LEFT) : new GridLayout(1, buttons.size()));
-                buttonsPanel.add(buttonRowPanel);
-                for (SideButton button : buttons)
-                    buttonRowPanel.add(button);
-            }
-            panel.add(buttonsPanel, BorderLayout.NORTH);
-            createLayout(panel, true, null);
-        } else
-            createLayout(panel, true, buttons);
-        this.add(titleBar, BorderLayout.NORTH);
-    }
-
-    @Override
-    public void selectedImageChanged(MapillaryAbstractImage oldImage,
-            MapillaryAbstractImage newImage) {
-        setImage(MapillaryData.getInstance().getSelectedImage());
-        updateImage();
-    }
-
-    @Override
-    public void imagesAdded() {
-    }
-}
