public void AddPoint(double x, double y, int index) {
        if (index > PointArray.length - 1) {
            index = PointArray.length;
        } else if (index < 0) {
            index = 0;
        }
        double temp[] = new double[PointArray.length + 2];
        for (int i = 0; i <= temp.length - 1; i++) {
            if (i > index + 1) {
                temp[i] = PointArray[i - 2];
            } else if (i < index) {
                temp[i] = PointArray[i];
            } else if (i == index) {
                temp[i] = x;
            } else {
                temp[i] = y;
            }
        }
        PointArray = temp;
    }