Ejemplo n.º 1
0
  /** Returns a FigureEnumeration of connectionfigures attached to this figure */
  public FigureEnumeration getConnectionFigures(Figure inFigure) {
    // If no figure or figure is non connectable, just return null
    if (inFigure == null || !inFigure.canConnect()) {
      return null;
    }

    // if (inFigure instanceof ConnectionFigure)
    //  return null;

    List result = CollectionsFactory.current().createList(5);
    FigureEnumeration figures = drawing().figures();

    // Find all connection figures
    while (figures.hasNextFigure()) {
      Figure f = figures.nextFigure();

      if ((f instanceof ConnectionFigure) && !(isFigureSelected(f))) {
        ConnectionFigure cf = (ConnectionFigure) f;

        if (cf.startFigure().includes(inFigure) || cf.endFigure().includes(inFigure)) {
          result.add(f);
        }
      }
    }

    return new FigureEnumerator(result);
  }
 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;
 }
 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;
  }