public Intersection getMinXIntersection(List<Line> lineList) {
        if (lineList.isEmpty()) {
            return null;
        }
        List<Line> temp = new ArrayList<>(lineList);
        Double minX = temp.get(0).getX1();
        if (temp.size() <= 1) {
            return null;
        }

        Line resultLine = temp.get(0), resultNextLine = temp.get(1);
        Intersection resultIntersection = new Intersection(resultLine, resultNextLine);

        for (int i = 0; i < temp.size(); i++) {
            Line line = lineList.get(i);
            for (int j = i + 1; j < temp.size(); j++) {
                try {

                    Line nextLine = lineList.get(j);
                    Intersection intersection = new Intersection(line, nextLine);

                    if (!intersection.isIntersection()) {
                        continue;
                    }
                    if (intersection.getX() < minX) {
                        minX = intersection.getX();
                        resultIntersection = intersection;
                    }


                } catch (IndexOutOfBoundsException e) {
                    e.printStackTrace();
                }
            }

        }


        return resultIntersection;
    }