ConvexHull { static Shape shapeOf(List<Point2D> points) { Path2D path = new Path2D.Double(); if (!points.isEmpty()) { path.moveTo(points.get(0).getX(), points.get(0).getY()); for (Point2D point : points) path.lineTo(point.getX(), point.getY()); path.closePath(); } return path; } private  ConvexHull(final Shape hull); static ConvexHull ofShape(final Shape shape); static ConvexHull ofShapes(final List<Shape> shapes); static Point2D lineLineIntersect(final Line2D lineA, final Line2D lineB);  }
@Test public void testShapeOf() throws Exception { List<Point2D> points = Arrays.<Point2D> asList(new Point2D.Double(-5d, -5d), new Point2D.Double(-5d, 5d), new Point2D.Double(5d, 5d), new Point2D.Double(5d, -5d)); Rectangle2D bounds = ConvexHull.shapeOf(points).getBounds2D(); assertThat(bounds.getMinX(), closeTo(-5, 0.01)); assertThat(bounds.getMinY(), closeTo(-5, 0.01)); assertThat(bounds.getMaxX(), closeTo(5, 0.01)); assertThat(bounds.getMaxY(), closeTo(5, 0.01)); }
@Test public void emptyShapeDoesBreak() throws Exception { Shape shape = ConvexHull.shapeOf(Collections.<Point2D> emptyList()); }