src/main/java/de/javagl/geom/Rectangles.java
/**
     * Compute the union of the given rectangles, and store it in the given
     * result rectangle.<br>
     * <br>
     * If the given result rectangle is <code>null</code>, then a new 
     * rectangle will be created and returned.
     * 
     * @param rectangles The rectangles
     * @param result The rectangle that will store the result
     * @return The result. If the given sequence of rectangles is
     * empty, then a rectangle at (0,0) with size (0,0) will be returned.
     */
Compute the union of the given rectangles, and store it in the given
result rectangle.

If the given result rectangle is null, then a new
rectangle will be created and returned.

@param rectangles The rectangles
@param result The rectangle that will store the result
@return The result. If the given sequence of rectangles is
empty, then a rectangle at (0,0) with size (0,0) will be returned.
Compute the union of the given rectangles and store it in the given result rectangle . If the given result rectangle is null then a new rectangle will be created and returned . @param rectangles The rectangles @param result The rectangle that will store the result @return The result . If the given sequence of rectangles is empty then a rectangle at ( 0 0 ) with size ( 0 0 ) will be returned .
public static Rectangle2D union(
        Iterable<? extends Rectangle2D> rectangles, Rectangle2D result)
    {
        if (result == null)
        {
            result = new Rectangle2D.Double();
        }
        boolean first = true;
        for (Rectangle2D r : rectangles)
        {
            if (first)
            {
                result.setRect(r);
                first = false;
            }
            else
            {
                Rectangle2D.union(result, r, result);
            }
        }
        return result;
    }
public static Rectangle2D union ( Iterable < ? extends Rectangle2D > rectangles , Rectangle2D result ) { if ( result == null ) { result = new Rectangle2D . Double ( ) ; } boolean first = true ; for ( Rectangle2D r : rectangles ) { if ( first ) { result . setRect ( r ) ; first = false ; } else { Rectangle2D . union ( result , r , result ) ; } } return result ; }
Compute the union of the given rectangles, and store it in the given
 result rectangle.<br>
 <br>
 If the given result rectangle is <code>null</code>, then a new
 rectangle will be created and returned.
Compute the union of the given rectangles and store it in the given result rectangle . <br > <br > If the given result rectangle is <code > null< / code > then a new rectangle will be created and returned .