public double calcMoment(String whichMoment){
            Stack<Point> blob_copy = new Stack<Point>();
            blob_copy.addAll(blob);

            double moment = 0;


            // NOTE: This code will only work with Java SE 7. Strings in
            // switch statements were not supported in JDK<=6, apparently.
            while (!blob_copy.empty()){
                Point point = blob_copy.pop();
                switch (whichMoment) {
                    case "M1":  moment += point.weight(); break;
                    case "Mx":  moment += point.x() * point.weight(); break;
                    case "My":  moment += point.y() * point.weight(); break;
                    case "Mxx": moment += Math.pow(point.x(), 2) * point.weight(); break;
                    case "Myy": moment += Math.pow(point.y(), 2) * point.weight(); break;
                    case "Mxy": moment += point.x() * point.y() * point.weight(); break;
                }
            }

            return moment;
        }