Index: trunk/src/org/openstreetmap/josm/gui/MapView.java
===================================================================
--- trunk/src/org/openstreetmap/josm/gui/MapView.java	(revision 5405)
+++ trunk/src/org/openstreetmap/josm/gui/MapView.java	(revision 5406)
@@ -29,4 +29,6 @@
 
 import javax.swing.AbstractButton;
+import javax.swing.ActionMap;
+import javax.swing.InputMap;
 import javax.swing.JOptionPane;
 import javax.swing.JPanel;
@@ -56,12 +58,12 @@
 
 /**
- * This is a component used in the MapFrame for browsing the map. It use is to
- * provide the MapMode's enough capabilities to operate.
+ * This is a component used in the {@link MapFrame} for browsing the map. It use is to
+ * provide the MapMode's enough capabilities to operate.<br/><br/>
  *
- * MapView hold meta-data about the data set currently displayed, as scale level,
+ * {@code MapView} holds meta-data about the data set currently displayed, as scale level,
  * center point viewed, what scrolling mode or editing mode is selected or with
- * what projection the map is viewed etc..
+ * what projection the map is viewed etc..<br/><br/>
  *
- * MapView is able to administrate several layers.
+ * {@code MapView} is able to administrate several layers.
  *
  * @author imi
@@ -70,10 +72,26 @@
 
     /**
-     * Interface to notify listeners of the change of the active layer.
+     * Interface to notify listeners of a layer change.
      * @author imi
      */
     public interface LayerChangeListener {
+        
+        /**
+         * Notifies this listener that the active layer has changed.
+         * @param oldLayer The previous active layer
+         * @param newLayer The new activer layer
+         */
         void activeLayerChange(Layer oldLayer, Layer newLayer);
+        
+        /**
+         * Notifies this listener that a layer has been added.
+         * @param newLayer The new added layer
+         */
         void layerAdded(Layer newLayer);
+        
+        /**
+         * Notifies this listener that a layer has been removed.
+         * @param oldLayer The old removed layer
+         */
         void layerRemoved(Layer oldLayer);
     }
@@ -131,4 +149,9 @@
     }
 
+    /**
+     * Adds an edit layer change listener
+     *
+     * @param listener the listener. Ignored if null or already registered.
+     */
     public static void addEditLayerChangeListener(EditLayerChangeListener listener) {
         if (listener != null) {
@@ -193,4 +216,8 @@
     private Rectangle lastClipBounds = new Rectangle();
 
+    /**
+     * Constructs a new {@code MapView}.
+     * @param contentPane The content pane used to register shortcuts in its {@link InputMap} and {@link ActionMap}
+     */
     public MapView(final JPanel contentPane) {
         Main.pref.addPreferenceChangeListener(this);
@@ -269,4 +296,5 @@
      * Add a layer to the current MapView. The layer will be added at topmost
      * position.
+     * @param layer The layer to add
      */
     public void addLayer(Layer layer) {
@@ -357,4 +385,5 @@
      * Remove the layer from the mapview. If the layer was in the list before,
      * an LayerChange event is fired.
+     * @param layer The layer to remove
      */
     public void removeLayer(Layer layer) {
@@ -468,5 +497,5 @@
      * Draw the component.
      */
-    @Override public synchronized void paint(Graphics g) {
+    @Override public void paint(Graphics g) {
         if (BugReportExceptionHandler.exceptionHandlingInProgress())
             return;
@@ -486,5 +515,10 @@
         }
 
-        boolean canUseBuffer = !paintPreferencesChanged && nonChangedLayers.size() <= nonChangedLayersCount &&
+        boolean canUseBuffer;
+        
+        synchronized (this) {
+            canUseBuffer = !paintPreferencesChanged;
+        }
+        canUseBuffer = canUseBuffer && nonChangedLayers.size() <= nonChangedLayersCount &&
         lastViewID == getViewID() && lastClipBounds.contains(g.getClipBounds());
         if (canUseBuffer) {
@@ -841,6 +875,9 @@
     }
 
-    public synchronized void preferenceChanged(PreferenceChangeEvent e) {
-        paintPreferencesChanged = true;
+    @Override
+    public void preferenceChanged(PreferenceChangeEvent e) {
+        synchronized (this) {
+            paintPreferencesChanged = true;
+        }
     }
 
