Here you can find the source of boundsOf(Collection extends Point> points)
Parameter | Description |
---|---|
points | the provided points |
public static Rectangle boundsOf(Collection<? extends Point> points)
//package com.java2s; // GNU Affero General Public License as published by the Free Software Foundation, either version import java.awt.Point; import java.awt.Rectangle; import java.util.Collection; public class Main { /**//from w w w . j av a2s. co m * Report the bounding box for all points * * @param points the provided points * @return the smallest rectangle that really contains all the points. */ public static Rectangle boundsOf(Collection<? extends Point> points) { if ((points == null) || points.isEmpty()) { return null; } Rectangle bounds = null; for (Point point : points) { if (bounds == null) { bounds = new Rectangle(point); } else { bounds.add(point); } } if (bounds != null) { // So that points located on right or bottom borders get really contained by the bounds bounds.width++; bounds.height++; } return bounds; } }