Here you can find the source of getRectangleListBounds(Vector vctRectangles)
Parameter | Description |
---|---|
vctRectangles | The list of rectangles. |
public static Rectangle getRectangleListBounds(Vector vctRectangles)
//package com.java2s; import java.awt.*; import java.util.*; public class Main { /**//from www. ja v a2 s. co m * Return a rectangle that encapsulates all rectangles in the Vector. * @param vctRectangles The list of rectangles. */ public static Rectangle getRectangleListBounds(Vector vctRectangles) { // Call the version that takes an Enumeration object. return getRectangleListBounds(vctRectangles.elements()); } /** * Return a rectangle that encapsulates all rectangles in the Enumeration. * @param enumRectangles The list of rectangles. */ public static Rectangle getRectangleListBounds(Enumeration enumRectangles) { double nMinLeft = 20000; double nMinTop = 20000; double nMaxWidth = -1; double nMaxHeight = -1; // Process for rectangle in the list. while (enumRectangles.hasMoreElements()) { Rectangle rBounds = (Rectangle) (enumRectangles.nextElement()); // Find new rectangle dimensions if (rBounds.getX() < nMinLeft) { nMinLeft = rBounds.getX(); } if (rBounds.getY() < nMinTop) { nMinTop = rBounds.getY(); } if (rBounds.getX() + rBounds.getWidth() > nMaxWidth) { nMaxWidth = rBounds.getX() + rBounds.getWidth(); } if (rBounds.getY() + rBounds.getHeight() > nMaxHeight) { nMaxHeight = rBounds.getY() + rBounds.getHeight(); } } return new Rectangle((int) nMinLeft, (int) nMinTop, (int) (nMaxWidth - nMinLeft), (int) (nMaxHeight - nMinTop)); } }