private String justifyLine(ArrayList<String> line, int indent) {
        if (line.size() == 1) {
            return line.get(0);
        }
        String result = "";
        int l = charsIn(line);
        if (line.size() - 1 + l == _textWidth || !_justify) {
            return lineToString(line);
        }
        double b = _textWidth - indent - l;
        if (b >= 3 * (line.size())) {
            for (int i = 0; i < line.size(); i += 1) {
                if (i != 0) {
                    result = result + "   " + line.get(i);
                } else {
                    result = result + line.get(i);
                }
            }
        } else {
            int currNumSpaces = 0;
            int prevNumSpaces;
            int insertBlanks;
            for (double i = 0; i < line.size(); i += 1) {
                prevNumSpaces = currNumSpaces;
                currNumSpaces = (int) (0.5 + b * i
                        / (double) (line.size() - 1));
                insertBlanks = currNumSpaces - prevNumSpaces;
                result = result + addSpaces(Math.min(3, insertBlanks))
                        + line.get((int) i);
            }
        }
        return result;
    }