Package com.cburch.draw.model

Examples of com.cburch.draw.model.Handle


      ArrayList<CanvasObject> removed;
      removed = new ArrayList<CanvasObject>(shapes.size());
      for (CanvasObject shape : shapes) {
        if (selected.remove(shape)) {
          suppressed.remove(shape);
          Handle h = selectedHandle;
          if (h != null && h.getObject() == shape) setHandleSelected(null);
          removed.add(shape);
        }
      }
      if (!removed.isEmpty()) {
        fireChanged(SelectionEvent.ACTION_REMOVED, removed);
View Full Code Here


    removed = new ArrayList<CanvasObject>(shapes.size());
    for (CanvasObject shape : shapes) {
      if (selected.contains(shape)) {
        selected.remove(shape);
        suppressed.remove(shape);
        Handle h = selectedHandle;
        if (h != null && h.getObject() == shape) setHandleSelected(null);
        removed.add(shape);
      } else {
        selected.add(shape);
        added.add(shape);
      }
View Full Code Here

  public Handle getSelectedHandle() {
    return selectedHandle;
  }
 
  public void setHandleSelected(Handle handle) {
    Handle cur = selectedHandle;
    boolean same = cur == null ? handle == null : cur.equals(handle);
    if (!same) {
      selectedHandle = handle;
      curHandleGesture = null;
      Collection<CanvasObject> objs;
      if (handle == null) {
View Full Code Here

  public void setHandleGesture(HandleGesture gesture) {
    HandleGesture g = curHandleGesture;
    if (g != null) suppressed.remove(g.getHandle().getObject());
   
    Handle h = gesture.getHandle();
    suppressed.put(h.getObject(), MOVING_HANDLE);
    curHandleGesture = gesture;
  }
View Full Code Here

    case CanvasModelEvent.ACTION_REMOVED:
      Collection<? extends CanvasObject> affected = event.getAffected();
      if (affected != null) {
        selected.removeAll(affected);
        suppressed.keySet().removeAll(affected);
        Handle h = selectedHandle;
        if (h != null && affected.contains(h.getObject())) {
          setHandleSelected(null);
        }
      }
      break;
    case CanvasModelEvent.ACTION_HANDLE_DELETED:
View Full Code Here

    newHandle = model.moveHandle(gesture);
  }
 
  @Override
  void undoSub(CanvasModel model) {
    Handle oldHandle = gesture.getHandle();
    int dx = oldHandle.getX() - newHandle.getX();
    int dy = oldHandle.getY() - newHandle.getY();
    HandleGesture reverse = new HandleGesture(newHandle, dx, dy, 0);
    model.moveHandle(reverse);
  }
View Full Code Here

  }
 
  @Override
  public void cancelMousePress(Canvas canvas) {
    List<CanvasObject> before = beforePressSelection;
    Handle handle = beforePressHandle;
    beforePressSelection = null;
    beforePressHandle = null;
    if (before != null) {
      curAction = IDLE;
      Selection sel = canvas.getSelection();
View Full Code Here

   
    if (!dragEffective) {
      Location loc = dragEnd;
      CanvasObject o = getObjectAt(model, loc.getX(), loc.getY(), false);
      if (o != null) {
        Handle han = o.canDeleteHandle(loc);
        if (han != null) {
          selection.setHandleSelected(han);
        } else {
          han = o.canInsertHandle(loc);
          if (han != null) {
            selection.setHandleSelected(han);
          }
        }
      }
    }
   
    Location start = dragStart;
    int x1 = e.getX();
    int y1 = e.getY();
    switch (action) {
    case MOVE_ALL:
      Location moveDelta = selection.getMovingDelta();
      if (dragEffective && !moveDelta.equals(Location.create(0, 0))) {
        canvas.doAction(new ModelTranslateAction(model, selected,
            moveDelta.getX(), moveDelta.getY()));
      }
      break;
    case MOVE_HANDLE:
      HandleGesture gesture = curGesture;
      curGesture = null;
      if (dragEffective && gesture != null) {
        ModelMoveHandleAction act;
        act = new ModelMoveHandleAction(model, gesture);
        canvas.doAction(act);
        Handle result = act.getNewHandle();
        if (result != null) {
          Handle h = result.getObject().canDeleteHandle(result.getLocation());
          selection.setHandleSelected(h);
        }
      }
      break;
    case RECT_SELECT:
View Full Code Here

    switch (curAction) {
    case MOVE_HANDLE:
      HandleGesture gesture = curGesture;
      if (ctrl) {
        Handle h = gesture.getHandle();
        dx = canvas.snapX(h.getX() + dx) - h.getX();
        dy = canvas.snapY(h.getY() + dy) - h.getY();
      }
      curGesture = new HandleGesture(gesture.getHandle(), dx, dy, mods);
      canvas.getSelection().setHandleGesture(curGesture);
      break;
    case MOVE_ALL:
View Full Code Here

          y = (int) Math.round(zoom * y);
          gCopy.clearRect(x - offs, y - offs, size, size);
          gCopy.drawRect(x - offs, y - offs, size, size);
        }
      }
      Handle selHandle = selection.getSelectedHandle();
      if (selHandle != null) {
        int x = selHandle.getX();
        int y = selHandle.getY();
        if (action == MOVE_ALL && dragEffective) {
          Location delta = selection.getMovingDelta();
          x += delta.getX();
          y += delta.getY();
        }
View Full Code Here

TOP

Related Classes of com.cburch.draw.model.Handle

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.