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);
  }
Ejemplo n.º 2
0
 private Figure findConnectableFigure(Point2D.Double p, Drawing drawing) {
   for (Figure f : drawing.getFiguresFrontToBack()) {
     if (!f.includes(getOwner()) && f.canConnect() && f.contains(p)) {
       return f;
     }
   }
   return null;
 }
Ejemplo n.º 3
0
  private Connector findConnectionTarget(Point2D.Double p, Drawing drawing) {
    Figure targetFigure = findConnectableFigure(p, drawing);

    if (getSource() == null && targetFigure != null) {
      return findConnector(p, targetFigure, getOwner());
    } else if (targetFigure != null) {
      Connector target = findConnector(p, targetFigure, getOwner());
      if ((targetFigure != null)
          && targetFigure.canConnect()
          && targetFigure != savedTarget
          && !targetFigure.includes(getOwner())
          && (canConnect(getSource(), target)
              || getTarget() != null && getTarget().getOwner() == targetFigure)) {
        return target;
      }
    }
    return null;
  }