package cn.com.victorysoft.business.util;

public class StringUtils extends org.apache.commons.lang3.StringUtils {

    public static double[][] parsePoints(String xData, String yData) {
        double[][] points = null;
        if (org.apache.commons.lang3.StringUtils.isNotEmpty(xData) && org.apache.commons.lang3.StringUtils.isNotEmpty(yData)) {
            String[] xArray = xData.split(",");
            String[] yArray = yData.split(",");
            if (xArray.length != yArray.length) return null;

            points = new double[xArray.length][];
            for (int i = 0; i < xArray.length; i++) {
                double x = Double.parseDouble(xArray[i]);
                double y = Double.parseDouble(yArray[i]);
                double[] point = new double[]{x, y};
                points[i] = point;
            }
        }
        return points;
    }
}
