/**
   * Connects the figure to the new target. If there is no new target the connection reverts to its
   * original one.
   */
  public void invokeEnd(int x, int y, int anchorX, int anchorY, DrawingView view) {
    Connector target = findConnectionTarget(x, y, view.drawing());
    if (target == null) {
      target = fOriginalTarget;
    }

    setPoint(x, y);
    connect(target);
    getConnection().updateConnection();

    Connector oldConnector =
        ((ChangeConnectionHandle.UndoActivity) getUndoActivity()).getOldConnector();
    // there has been no change so there is nothing to undo
    if ((oldConnector == null)
        || (target() == null)
        || (oldConnector.owner() == target().owner())) {
      setUndoActivity(null);
    } else {
      getUndoActivity().setAffectedFigures(new SingleFigureEnumerator(getConnection()));
    }

    if (getTargetFigure() != null) {
      getTargetFigure().connectorVisibility(false);
      setTargetFigure(null);
    }
  }
  /** Finds a new target of the connection. */
  public void invokeStep(int x, int y, int anchorX, int anchorY, DrawingView view) {
    Point p = new Point(x, y);
    Figure f = findConnectableFigure(x, y, view.drawing());
    // track the figure containing the mouse
    if (f != getTargetFigure()) {
      if (getTargetFigure() != null) {
        getTargetFigure().connectorVisibility(false);
      }
      setTargetFigure(f);
      if (getTargetFigure() != null) {
        getTargetFigure().connectorVisibility(true);
      }
    }

    Connector target = findConnectionTarget(p.x, p.y, view.drawing());
    if (target != null) {
      p = Geom.center(target.displayBox());
    }
    setPoint(p.x, p.y);
  }
Ejemplo n.º 3
0
 /**
  * @param x the x position where the interaction started
  * @param y the y position where the interaction started
  * @param view the handles container
  */
 public void invokeStart(int x, int y, DrawingView view) {
   invokeStart(x, y, view.drawing());
 }
Ejemplo n.º 4
0
 /**
  * Tracks the end of the interaction.
  *
  * @param x the current x position
  * @param y the current y position
  * @param anchorX the x position where the interaction started
  * @param anchorY the y position where the interaction started
  */
 public void invokeEnd(int x, int y, int anchorX, int anchorY, DrawingView view) {
   invokeEnd(x - anchorX, y - anchorY, view.drawing());
 }
Ejemplo n.º 5
0
 /**
  * Creates the drawing view used in this application. You need to override this method to use a
  * DrawingView subclass in your application. By default a standard DrawingView is returned.
  */
 protected DrawingView createDrawingView() {
   DrawingView createdDrawingView = createDrawingView(createDrawing());
   createdDrawingView.drawing().setTitle(getDefaultDrawingTitle());
   return createdDrawingView;
 }