Esempio n. 1
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;
 }
 /** Finds a connection end figure. */
 protected Connector findConnectionTarget(int x, int y, Drawing drawing) {
   Figure target = findConnectableFigure(x, y, drawing);
   if ((target != null)
       && target.canConnect()
       && !target.includes(owner())
       && getConnection().canConnect(owner(), target)) {
     return findConnector(x, y, target);
   }
   return null;
 }
Esempio n. 4
0
  /** Checks if the composite figure has the argument as one of its children. */
  public boolean includes(Figure figure) {
    if (super.includes(figure)) return true;

    FigureEnumeration k = figures();
    while (k.hasMoreElements()) {
      Figure f = k.nextFigure();
      if (f.includes(figure)) return true;
    }
    return false;
  }
Esempio n. 5
0
 /**
  * Finds a top level Figure that intersects the given rectangle. It supresses the passed in
  * figure. Use this method to ignore a figure that is temporarily inserted into the drawing.
  */
 public Figure findFigure(Rectangle r, Figure without) {
   if (without == null) return findFigure(r);
   FigureEnumeration k = figuresReverse();
   while (k.hasMoreElements()) {
     Figure figure = k.nextFigure();
     Rectangle fr = figure.displayBox();
     if (r.intersects(fr) && !figure.includes(without)) return figure;
   }
   return null;
 }
  /** Check existance of figure in the drawing */
  public boolean figureExists(Figure inf, FigureEnumeration fe) {
    while (fe.hasNextFigure()) {
      Figure figure = fe.nextFigure();

      if (figure.includes(inf)) {
        return true;
      }
    }

    return false;
  }
 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;
 }
  private Connector findConnectionTarget(int x, int y, Drawing drawing) {
    Figure target = findConnectableFigure(x, y, drawing);

    if ((target != null)
        && target.canConnect()
        && target != fOriginalTarget
        && !target.includes(owner())
        && getConnection().canConnect(source().owner(), target)) {
      return findConnector(x, y, target);
    }
    return null;
  }