示例#1
0
  /** Handles mouse down events and starts the corresponding tracker. */
  public void mouseDown(MouseEvent e, int x, int y) {
    // on MS-Windows NT: AWT generates additional mouse down events
    // when the left button is down && right button is clicked.
    // To avoid dead locks we ignore such events
    if (fChild != null) {
      return;
    }

    view().freezeView();

    Handle handle = view().findHandle(e.getX(), e.getY());
    if (handle != null) {
      fChild = createHandleTracker(view(), handle);
    } else {
      Figure figure = drawing().findFigure(e.getX(), e.getY());
      if (figure != null) {
        fChild = createDragTracker(figure);
      } else {
        if (!e.isShiftDown()) {
          view().clearSelection();
        }
        fChild = createAreaTracker();
      }
    }
    fChild.mouseDown(e, x, y);
    fChild.activate();
  }
 /**
  * Sets the active Tool for this EditDomain. If a current Tool is active, it is deactivated. The
  * new Tool is told its EditDomain, and is activated.
  *
  * @param tool the Tool
  */
 public void setActiveTool(Tool tool) {
   if (activeTool != null) activeTool.deactivate();
   activeTool = tool;
   if (activeTool != null) {
     activeTool.setEditDomain(this);
     activeTool.activate();
   }
 }
示例#3
0
 private void setTool(Tool t, String name) {
   if (fTool != null) {
     fTool.deactivate();
   }
   fTool = t;
   if (fTool != null) {
     showStatus(name);
     fTool.activate();
   }
 }
 protected void setTracker(Tool newTracker) {
   if (tracker != null) {
     tracker.deactivate(getEditor());
     tracker.removeToolListener(this);
   }
   tracker = newTracker;
   if (tracker != null) {
     tracker.activate(getEditor());
     tracker.addToolListener(this);
   }
 }
  public void toolDone(ToolEvent event) {
    // Empty
    Tool newTracker = getSelectAreaTracker();

    if (newTracker != null) {
      if (tracker != null) {
        tracker.deactivate(getEditor());
        tracker.removeToolListener(this);
      }
      tracker = newTracker;
      tracker.activate(getEditor());
      tracker.addToolListener(this);
    }
    fireToolDone();
  }
示例#6
0
  @Override
  public void setActiveTool(final Tool activeTool) {
    if (this.activeTool == activeTool) return; // nothing to do
    assert this.activeTool != null;
    if (activeTool == null) {
      throw new IllegalArgumentException("Active tool cannot be null");
    }

    // deactivate old tool
    this.activeTool.deactivate();
    eventService.publish(new ToolDeactivatedEvent(this.activeTool));

    // activate new tool
    this.activeTool = activeTool;
    activeTool.activate();
    eventService.publish(new ToolActivatedEvent(activeTool));
  }
 @Override
 public void activate(DrawingEditor editor) {
   super.activate(editor);
   tracker.activate(editor);
 }