public void add(Rectangle2D.Double rect) { areas.add(rect); // sortedX1.add(rect); // sortedX2.add(rect); // sortedY1.add(rect); // sortedY2.add(rect); if (max == null) { max = rect; } else { max = (Rectangle2D.Double) max.createUnion(rect); } }
public void add(Rectangle2D.Double rect) { areas.add(rect); // sortedX1.add(rect); // sortedX2.add(rect); // sortedY1.add(rect); // sortedY2.add(rect); if (max == null) { max = rect; } else { max = (Rectangle2D.Double) max.createUnion(rect); } }
public static void main(String[] args) { double cx, cy, r, p1x, p1y, p2x, p2y; // first input cx, cy, r, p1x, p1y, p2x, and p2y // construct a zero-width/height rectangle at p1 Rectangle2D.Double p1 = new Rectangle2D.Double(p1x, p1y, 0, 0); // construct another one at p1 Rectangle2D.Double p2 = new Rectangle2D.Double(p2x, p2y, 0, 0); // construct the union of the two Rectangle2D.Double rect = p1.createUnion(p2); // expand the rectangle rect.setBounds(rect.x - r, rect.y - r, rect.w + 2 * r, rect.h + 2 * r); // test for containment if (rect.contains(cx, cy) { a = "Circle is inside of Rectangle"; } else { a = "Circle is outside of Rectangle"; } System.out.println(a); }