Java Geometry Algorithm bound(Point... points)

Here you can find the source of bound(Point... points)

Description

bound

License

Apache License

Declaration

public static Rectangle bound(Point... points) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.awt.*;

public class Main {
    public static Rectangle bound(Point... points) {
        int smallestX = Integer.MAX_VALUE;
        int smallestY = Integer.MAX_VALUE;
        int largestX = Integer.MIN_VALUE;
        int largestY = Integer.MIN_VALUE;
        for (Point point : points) {
            if (point == null) {
                continue;
            }/*  w w w . j  a v  a  2s . c  o m*/
            if (point.x > largestX)
                largestX = point.x;
            if (point.y > largestY)
                largestY = point.y;
            if (point.x < smallestX)
                smallestX = point.x;
            if (point.y < smallestY)
                smallestY = point.y;
        }
        return new Rectangle(smallestX, smallestY, largestX - smallestX, largestY - smallestY);
    }
}

Related

  1. areLocationsClose(Point2D point1, Point2D point2)
  2. assertEDT(String point)
  3. botCorners(Point2D.Double p)
  4. botRect(Point2D.Double botLocation)
  5. botSides( Point2D.Double botLocation)
  6. boundingBox(Vector points)
  7. boundsOf(Collection points)
  8. cap(java.awt.geom.Point2D.Double p1, java.awt.geom.Point2D.Double p2, double radius)
  9. centroid(Vector points)