コード例 #1
0
 public Figure basicRemoveChild(int index) {
   Figure figure = children.get(index);
   children.remove(index);
   quadTree.remove(figure);
   figure.removeFigureListener(figureHandler);
   needsSorting = true;
   return figure;
 }
コード例 #2
0
 @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;
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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;
 }
コード例 #5
0
 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;
 }
コード例 #6
0
 public void sendToBack(Figure figure) {
   if (children.remove(figure)) {
     children.add(0, figure);
     needsSorting = true;
     fireAreaInvalidated(figure.getDrawingArea());
   }
 }
コード例 #7
0
 public void bringToFront(Figure figure) {
   if (children.remove(figure)) {
     children.add(figure);
     needsSorting = true;
     fireAreaInvalidated(figure.getDrawingArea());
   }
 }
コード例 #8
0
 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;
       }
   }
 }
コード例 #9
0
 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;
       }
   }
 }
コード例 #10
0
 public void basicAdd(int index, Figure figure) {
   children.add(index, figure);
   quadTree.add(figure, figure.getDrawingArea());
   figure.addFigureListener(figureHandler);
   needsSorting = true;
 }
コード例 #11
0
 public void draw(Graphics2D g, Collection<Figure> c) {
   for (Figure f : c) {
     f.draw(g);
   }
 }