public Figure findFigure(Point2D.Double p) { Collection<Figure> c = quadTree.findContains(p); switch (c.size()) { case 0: return null; case 1: { Figure f = c.iterator().next(); return (f.contains(p)) ? f : null; } default: { for (Figure f : getFiguresFrontToBack()) { if (c.contains(f) && f.contains(p)) return f; } return null; } } }
public Figure findFigureExcept(Point2D.Double p, Collection ignore) { Collection<Figure> c = quadTree.findContains(p); switch (c.size()) { case 0: { return null; } case 1: { Figure f = c.iterator().next(); return (!ignore.contains(f) || !f.contains(p)) ? null : f; } default: { for (Figure f : getFiguresFrontToBack()) { if (!ignore.contains(f) && f.contains(p)) return f; } return null; } } }