Beispiel #1
0
 /**
  * Finds a top level Figure. Use this call for hit detection that should not descend into the
  * figure's children.
  */
 public Figure findFigure(int x, int y) {
   FigureEnumeration k = figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     if (figure.containsPoint(x, y)) return figure;
   }
   return null;
 }
Beispiel #2
0
 /**
  * Finds a top level Figure, but supresses the passed in figure. Use this method to ignore a
  * figure that is temporarily inserted into the drawing.
  *
  * @param x the x coordinate
  * @param y the y coordinate
  * @param without the figure to be ignored during the find.
  */
 public Figure findFigureWithout(int x, int y, Figure without) {
   if (without == null) return findFigure(x, y);
   FigureEnumeration k = figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     if (figure.containsPoint(x, y) && !figure.includes(without)) return figure;
   }
   return null;
 }
 private Figure findConnectableFigure(int x, int y, Drawing drawing) {
   FigureEnumeration fe = drawing.figuresReverse();
   while (fe.hasNextFigure()) {
     Figure figure = fe.nextFigure();
     if (!figure.includes(getConnection()) && figure.canConnect() && figure.containsPoint(x, y)) {
       return figure;
     }
   }
   return null;
 }
 private Figure findConnectableFigure(int x, int y, Drawing drawing) {
   FigureEnumeration k = drawing.figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     if (!figure.includes(getConnection()) && figure.canConnect()) {
       if (figure.containsPoint(x, y)) {
         return figure;
       }
     }
   }
   return null;
 }