Index: /trunk/src/org/openstreetmap/josm/Main.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/Main.java	(revision 4723)
+++ /trunk/src/org/openstreetmap/josm/Main.java	(revision 4724)
@@ -39,5 +39,4 @@
 import javax.swing.JTextArea;
 import javax.swing.KeyStroke;
-import javax.swing.RepaintManager;
 import javax.swing.UIManager;
 
@@ -887,9 +886,10 @@
                 while(it.hasNext()){
                     WeakReference<ProjectionChangeListener> wr = it.next();
-                    if (wr.get() == null) {
+                    ProjectionChangeListener listener = wr.get();
+                    if (listener == null) {
                         it.remove();
                         continue;
                     }
-                    wr.get().projectionChanged(oldValue, newValue);
+                    listener.projectionChanged(oldValue, newValue);
                 }
             }
Index: /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 4723)
+++ /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 4724)
@@ -208,6 +208,6 @@
 
     /*
-    * Holding bin for changeset tag information, to be applied when or if this is ever uploaded.
-    */
+     * Holding bin for changeset tag information, to be applied when or if this is ever uploaded.
+     */
     private Map<String, String> changeSetTags = new HashMap<String, String>();
 
@@ -586,5 +586,5 @@
             selectedPrimitives = new LinkedHashSet<OsmPrimitive>();
             changed = addSelected(selection, false)
-            || (!wasEmpty && selectedPrimitives.isEmpty());
+                    || (!wasEmpty && selectedPrimitives.isEmpty());
             if (changed) {
                 selectionSnapshot = null;
@@ -783,27 +783,4 @@
     }
 
-    /**
-     *
-     * @param primitiveId
-     * @param createNew
-     * @return
-     * @deprecated This method can created inconsistent dataset when called for node with id < 0 and createNew=true. That will add
-     * complete node without coordinates to dataset which is not allowed.
-     */
-    @Deprecated
-    public OsmPrimitive getPrimitiveById(PrimitiveId primitiveId, boolean createNew) {
-        OsmPrimitive result = primitivesMap.get(primitiveId);
-
-        if (result == null && createNew) {
-            switch (primitiveId.getType()) {
-            case NODE: result = new Node(primitiveId.getUniqueId(), true); break;
-            case WAY: result = new Way(primitiveId.getUniqueId(), true); break;
-            case RELATION: result = new Relation(primitiveId.getUniqueId(), true); break;
-            }
-            addPrimitive(result);
-        }
-
-        return result;
-    }
 
     /**
@@ -1175,5 +1152,5 @@
         return ret;
     }
-    
+
     /**
      * Moves all primitives and datasources from DataSet "from" to this DataSet
Index: /trunk/src/org/openstreetmap/josm/data/osm/NodeData.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/NodeData.java	(revision 4723)
+++ /trunk/src/org/openstreetmap/josm/data/osm/NodeData.java	(revision 4724)
@@ -23,5 +23,5 @@
 
     private boolean isLatLonKnown() {
-        return lat != Double.NaN && lon != Double.NaN;
+        return !Double.isNaN(lat) && !Double.isNaN(lon);
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java	(revision 4723)
+++ /trunk/src/org/openstreetmap/josm/data/osm/PrimitiveData.java	(revision 4724)
@@ -3,4 +3,5 @@
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -27,9 +28,9 @@
         this.id = id;
     }
-    
+
     public void setVersion(int version) {
         this.version = version;
     }
-    
+
     /**
      * override to make it public
@@ -45,5 +46,5 @@
     public String toString() {
         StringBuilder builder = new StringBuilder();
-        builder.append(id).append(keys).append(getFlagsAsString());
+        builder.append(id).append(Arrays.toString(keys)).append(getFlagsAsString());
         return builder.toString();
     }
Index: /trunk/src/org/openstreetmap/josm/data/osm/history/History.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/history/History.java	(revision 4723)
+++ /trunk/src/org/openstreetmap/josm/data/osm/history/History.java	(revision 4724)
@@ -71,5 +71,5 @@
                     }
                 }
-        );
+                );
         return new History(id, type, copy);
     }
@@ -84,5 +84,5 @@
                     }
                 }
-        );
+                );
         return new History(id, type,copy);
     }
@@ -96,5 +96,5 @@
                     }
                 }
-        );
+                );
     }
 
@@ -107,5 +107,5 @@
                     }
                 }
-        );
+                );
     }
 
@@ -122,5 +122,5 @@
                     }
                 }
-        );
+                );
     }
 
@@ -133,5 +133,5 @@
                     }
                 }
-        );
+                );
     }
 
@@ -140,15 +140,4 @@
     }
 
-    public History forUser(final String user) {
-        return filter(
-                this,
-                new FilterPredicate() {
-                    public boolean matches(HistoryOsmPrimitive primitive) {
-                        return primitive.getUser().equals(user);
-                    }
-                }
-        );
-    }
-
     public History forUserId(final long uid) {
         return filter(
@@ -159,5 +148,5 @@
                     }
                 }
-        );
+                );
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java	(revision 4723)
+++ /trunk/src/org/openstreetmap/josm/data/osm/visitor/paint/MapPainter.java	(revision 4724)
@@ -252,5 +252,5 @@
      * represent a line that is shifted by a certain offset perpendicular
      * to the way direction.
-     * 
+     *
      * There is no intention, to handle consecutive duplicate Nodes in a
      * perfect way, but it is should not throw an exception.
@@ -328,6 +328,6 @@
                 int m = dx_next*(y_current0 - y_prev0) - dy_next*(x_current0 - x_prev0);
 
-                int cx_ = x_prev0 + Math.round(m * dx_prev / det);
-                int cy_ = y_prev0 + Math.round(m * dy_prev / det);
+                int cx_ = x_prev0 + Math.round((float)m * dx_prev / det);
+                int cy_ = y_prev0 + Math.round((float)m * dy_prev / det);
                 ++idx;
                 prev = current;
@@ -809,5 +809,5 @@
 
         Shape area = path.createTransformedShape(nc.getAffineTransform());
-        
+
         if (!isOutlineOnly) {
             if (fillImage == null) {
@@ -816,6 +816,6 @@
             } else {
                 TexturePaint texture = new TexturePaint(fillImage,
-//                        new Rectangle(polygon.xpoints[0], polygon.ypoints[0], fillImage.getWidth(), fillImage.getHeight()));
-                      new Rectangle(0, 0, fillImage.getWidth(), fillImage.getHeight()));
+                        //                        new Rectangle(polygon.xpoints[0], polygon.ypoints[0], fillImage.getWidth(), fillImage.getHeight()));
+                        new Rectangle(0, 0, fillImage.getWidth(), fillImage.getHeight()));
                 g.setPaint(texture);
                 if (fillImageAlpha != 1f) {
@@ -858,6 +858,6 @@
 
             if ((pb.width >= nb.getWidth() && pb.height >= nb.getHeight()) && // quick check
-                  area.contains(centeredNBounds) // slow but nice
-            ) {
+                    area.contains(centeredNBounds) // slow but nice
+                    ) {
                 g.setColor(text.color);
                 Font defaultFont = g.getFont();
Index: /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java	(revision 4723)
+++ /trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/LoadAndZoomHandler.java	(revision 4724)
@@ -45,5 +45,5 @@
     {
         return tr("Remote Control has been asked to load data from the API.") +
-        "<br>" + tr("Request details: {0}", request);
+                "<br>" + tr("Request details: {0}", request);
     }
 
@@ -81,6 +81,7 @@
                     Area toDownload = null;
                     DataSet ds = Main.main.getCurrentDataSet();
-                    if (ds != null)
+                    if (ds != null) {
                         present = ds.getDataSourceArea();
+                    }
                     if (present != null && !present.isEmpty()) {
                         toDownload = new Area(new Rectangle2D.Double(minlon,minlat,maxlon-minlon,maxlat-minlat));
@@ -168,6 +169,7 @@
                     }
                     ds.setSelected(newSel);
-                    if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault))
+                    if (Main.pref.getBoolean(changeViewportPermissionKey, changeViewportPermissionDefault)) {
                         new AutoScaleAction("selection").actionPerformed(null);
+                    }
                 }
             });
@@ -189,5 +191,5 @@
                         tags = URLDecoder.decode(args.get("addtags"), "UTF-8").split("\\|");
                     } catch (UnsupportedEncodingException e) {
-                        new RuntimeException();
+                        throw new RuntimeException();
                     }
                     String[][] keyValue = new String[tags.length][2];
Index: /trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java	(revision 4723)
+++ /trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java	(revision 4724)
@@ -171,5 +171,5 @@
             List<OsmPrimitive> lhsList = lhs.getPrimitives(root);
             for (OsmPrimitive o: rhs.getPrimitives(root)) {
-                if (lhsList.contains(o) && condition == null && condition.match(o)) {
+                if (lhsList.contains(o) && (condition == null || condition.match(o))) {
                     result.add(o);
                 }
