コード例 #1
0
 /** Implementation note: Sorting can not be done for orphaned children. */
 public java.util.List<Figure> sort(Collection<Figure> c) {
   ensureSorted();
   ArrayList<Figure> sorted = new ArrayList<Figure>(c.size());
   for (Figure f : children) {
     if (c.contains(f)) {
       sorted.add(f);
     }
   }
   return sorted;
 }
コード例 #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 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;
       }
   }
 }
コード例 #4
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;
 }
コード例 #5
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;
       }
   }
 }