Index: /trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java	(revision 5124)
+++ /trunk/src/org/openstreetmap/josm/actions/AlignInCircleAction.java	(revision 5125)
@@ -23,4 +23,5 @@
 import org.openstreetmap.josm.data.osm.OsmPrimitive;
 import org.openstreetmap.josm.data.osm.Way;
+import org.openstreetmap.josm.tools.Geometry;
 import org.openstreetmap.josm.tools.Shortcut;
 
@@ -184,34 +185,5 @@
         if (center == null) {
             // Compute the centroid of nodes
-
-            BigDecimal area = new BigDecimal(0);
-            BigDecimal north = new BigDecimal(0);
-            BigDecimal east = new BigDecimal(0);
-
-            // See http://en.wikipedia.org/w/index.php?title=Centroid&oldid=294224857#Centroid_of_polygon for the equation used here
-            for (int i = 0; i < nodes.size(); i++) {
-                EastNorth n0 = nodes.get(i).getEastNorth();
-                EastNorth n1 = nodes.get((i+1) % nodes.size()).getEastNorth();
-
-                BigDecimal x0 = new BigDecimal(n0.east());
-                BigDecimal y0 = new BigDecimal(n0.north());
-                BigDecimal x1 = new BigDecimal(n1.east());
-                BigDecimal y1 = new BigDecimal(n1.north());
-
-                BigDecimal k = x0.multiply(y1, MathContext.DECIMAL128).subtract(y0.multiply(x1, MathContext.DECIMAL128));
-
-                area = area.add(k, MathContext.DECIMAL128);
-                east = east.add(k.multiply(x0.add(x1, MathContext.DECIMAL128), MathContext.DECIMAL128));
-                north = north.add(k.multiply(y0.add(y1, MathContext.DECIMAL128), MathContext.DECIMAL128));
-
-            }
-
-            BigDecimal d = new BigDecimal(3, MathContext.DECIMAL128); // 1/2 * 6 = 3
-            area  = area.multiply(d, MathContext.DECIMAL128);
-            north = north.divide(area, MathContext.DECIMAL128);
-            east = east.divide(area, MathContext.DECIMAL128);
-
-            center = new EastNorth(east.doubleValue(), north.doubleValue());
-
+            center = Geometry.getCentroid(nodes);
         }
         // Node "center" now is central to all selected nodes.
Index: /trunk/src/org/openstreetmap/josm/tools/Geometry.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/tools/Geometry.java	(revision 5124)
+++ /trunk/src/org/openstreetmap/josm/tools/Geometry.java	(revision 5125)
@@ -3,4 +3,6 @@
 
 import java.awt.geom.Line2D;
+import java.math.BigDecimal;
+import java.math.MathContext;
 import java.util.ArrayList;
 import java.util.Comparator;
@@ -583,4 +585,36 @@
         return result;
     }
+    
+    public static EastNorth getCentroid(List<Node> nodes) {
+        // Compute the centroid of nodes
+
+        BigDecimal area = new BigDecimal(0);
+        BigDecimal north = new BigDecimal(0);
+        BigDecimal east = new BigDecimal(0);
+
+        // See http://en.wikipedia.org/w/index.php?title=Centroid&oldid=294224857#Centroid_of_polygon for the equation used here
+        for (int i = 0; i < nodes.size(); i++) {
+            EastNorth n0 = nodes.get(i).getEastNorth();
+            EastNorth n1 = nodes.get((i+1) % nodes.size()).getEastNorth();
+
+            BigDecimal x0 = new BigDecimal(n0.east());
+            BigDecimal y0 = new BigDecimal(n0.north());
+            BigDecimal x1 = new BigDecimal(n1.east());
+            BigDecimal y1 = new BigDecimal(n1.north());
+
+            BigDecimal k = x0.multiply(y1, MathContext.DECIMAL128).subtract(y0.multiply(x1, MathContext.DECIMAL128));
+
+            area = area.add(k, MathContext.DECIMAL128);
+            east = east.add(k.multiply(x0.add(x1, MathContext.DECIMAL128), MathContext.DECIMAL128));
+            north = north.add(k.multiply(y0.add(y1, MathContext.DECIMAL128), MathContext.DECIMAL128));
+        }
+
+        BigDecimal d = new BigDecimal(3, MathContext.DECIMAL128); // 1/2 * 6 = 3
+        area  = area.multiply(d, MathContext.DECIMAL128);
+        north = north.divide(area, MathContext.DECIMAL128);
+        east = east.divide(area, MathContext.DECIMAL128);
+
+        return new EastNorth(east.doubleValue(), north.doubleValue());
+    }
 
     /**
