public Figure basicRemoveChild(int index) { Figure figure = children.get(index); children.remove(index); quadTree.remove(figure); figure.removeFigureListener(figureHandler); needsSorting = true; return figure; }
@Override public Figure findFigureInside(Point2D.Double p) { Collection<Figure> c = quadTree.findContains(p); for (Figure f : getFiguresFrontToBack()) { if (c.contains(f) && f.contains(p)) { return f.findFigureInside(p); } } return null; }
public java.util.List<Figure> findFiguresWithin(Rectangle2D.Double bounds) { LinkedList<Figure> contained = new LinkedList<Figure>(); for (Figure f : children) { Rectangle2D r = f.getBounds(); if (AttributeKeys.TRANSFORM.get(f) != null) { r = AttributeKeys.TRANSFORM.get(f).createTransformedShape(r).getBounds2D(); } if (f.isVisible() && bounds.contains(r)) { contained.add(f); } } return contained; }
public Figure findFigureBehind(Point2D.Double p, Figure figure) { boolean isBehind = false; for (Figure f : getFiguresFrontToBack()) { if (isBehind) { if (f.isVisible() && f.contains(p)) { return f; } } else { isBehind = figure == f; } } return null; }
public Figure findFigureBehind(Point2D.Double p, Collection<Figure> figures) { int inFrontOf = figures.size(); for (Figure f : getFiguresFrontToBack()) { if (inFrontOf == 0) { if (f.isVisible() && f.contains(p)) { return f; } } else { if (figures.contains(f)) { inFrontOf--; } } } return null; }
public void sendToBack(Figure figure) { if (children.remove(figure)) { children.add(0, figure); needsSorting = true; fireAreaInvalidated(figure.getDrawingArea()); } }
public void bringToFront(Figure figure) { if (children.remove(figure)) { children.add(figure); needsSorting = true; fireAreaInvalidated(figure.getDrawingArea()); } }
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; } } }
public void basicAdd(int index, Figure figure) { children.add(index, figure); quadTree.add(figure, figure.getDrawingArea()); figure.addFigureListener(figureHandler); needsSorting = true; }
public void draw(Graphics2D g, Collection<Figure> c) { for (Figure f : c) { f.draw(g); } }