public static void computeBoundingRect(ArrayList<Point> points) {
        
        double minX = points.get(0).getX();
        double maxX = minX;
        double minY = points.get(0).getY();
        double maxY = minY;
        
        for (Point p:points) {
            if (p.getX() < minX) minX = p.getX();
            else if (p.getX() > maxX) maxX = p.getX();
            if (p.getY() < minY) minY = p.getY();
            else if (p.getY() > maxY) maxY = p.getY();
        }
        
        MIN_X = minX; MAX_X = maxX;
        MIN_Y = minY; MAX_Y = maxY;
        
        double a, bx, by; // coords = a*pixels + b
        
        if ( MAX_X - MIN_X  >=  MAX_Y - MIN_Y ) {
            DISP_RATIO = GRID_W / ( MAX_X - MIN_X );
            
            a = 1/DISP_RATIO;
            bx = MIN_X - a*WIN_MARGIN;
            ORIG_X = (int) (-bx/a);
            
            int bottomY = WIN_MARGIN + (int) (GRID_H/2 + DISP_RATIO*(MAX_Y-MIN_Y)/2);
            by = MIN_Y + a*bottomY;
            ORIG_Y = (int) (by/a);
            
        } else {
            
            DISP_RATIO = GRID_H / ( MAX_Y - MIN_Y );
            System.out.println(DISP_RATIO);
            
            a = -1/DISP_RATIO;
            by = MAX_Y - a*WIN_MARGIN;
            ORIG_Y = (int) (-by/a);
            
            int rightX = WIN_MARGIN + (int) (GRID_W/2 + DISP_RATIO*(MAX_X-MIN_X)/2);
            bx = MAX_X + a*rightX;
            ORIG_X = (int) (bx/a);
            
        }
        
    }