/* FIXME - The handle should draw itself in selected mode
 public void draw(Graphics2D g) {
 g.setColor(Color.RED);
 g.draw(
 masterHandle.getBounds()
 );
 }*/
 @Override
 public void activate(DrawingEditor editor) {
   super.activate(editor);
   getView().setCursor(masterHandle.getCursor());
   getView().setActiveHandle(masterHandle);
   clearHoverHandles();
 }
 @Override
 public void deactivate(DrawingEditor editor) {
   super.deactivate(editor);
   getView().setCursor(Cursor.getDefaultCursor());
   getView().setActiveHandle(null);
   clearHoverHandles();
   dragLocation = null;
 }
  @Override
  public void keyPressed(KeyEvent evt) {
    multicaster.keyPressed(evt);
    if (!evt.isConsumed()) {
      super.keyPressed(evt);

      // Forward key presses to the handler
      if (dragLocation != null) {
        multicaster.trackStep(anchor, dragLocation, evt.getModifiersEx(), getView());
      }
    }
  }
 public void deactivate(DrawingEditor editor) {
   super.deactivate(editor);
   tracker.deactivate(editor);
 }
 @Override
 public void activate(DrawingEditor editor) {
   super.activate(editor);
   tracker.activate(editor);
 }
  @Override
  public void mousePressed(MouseEvent evt) {
    if (getView() != null && getView().isEnabled()) {
      super.mousePressed(evt);
      DrawingView view = getView();
      Handle handle = view.findHandle(anchor);
      Tool newTracker = null;
      if (handle != null) {
        newTracker = getHandleTracker(handle);
      } else {
        Figure figure;
        Drawing drawing = view.getDrawing();
        Point2D.Double p = view.viewToDrawing(anchor);
        if (isSelectBehindEnabled()
            && (evt.getModifiersEx() & (InputEvent.ALT_DOWN_MASK | InputEvent.CTRL_DOWN_MASK))
                != 0) {
          // Select a figure behind the current selection
          figure = view.findFigure(anchor);
          while (figure != null && !figure.isSelectable()) {
            figure = drawing.findFigureBehind(p, figure);
          }
          HashSet<Figure> ignoredFigures = new HashSet<Figure>(view.getSelectedFigures());
          ignoredFigures.add(figure);
          Figure figureBehind =
              view.getDrawing().findFigureBehind(view.viewToDrawing(anchor), ignoredFigures);
          if (figureBehind != null) {
            figure = figureBehind;
          }
        } else {
          // Note: The search sequence used here, must be
          // consistent with the search sequence used by the
          // DefaultHandleTracker, the DefaultSelectAreaTracker and DelegationSelectionTool.

          // If possible, continue to work with the current selection
          figure = null;
          if (isSelectBehindEnabled()) {
            for (Figure f : view.getSelectedFigures()) {
              if (f.contains(p)) {
                figure = f;
                break;
              }
            }
          }
          // If the point is not contained in the current selection,
          // search for a figure in the drawing.
          if (figure == null) {
            figure = view.findFigure(anchor);
            while (figure != null && !figure.isSelectable()) {
              figure = drawing.findFigureBehind(p, figure);
            }
          }
        }

        if (figure != null && figure.isSelectable()) {
          newTracker = getDragTracker(figure);
        } else {
          if (!evt.isShiftDown()) {
            view.clearSelection();
            view.setHandleDetailLevel(0);
          }
          newTracker = getSelectAreaTracker();
        }
      }

      if (newTracker != null) {
        setTracker(newTracker);
      }
      tracker.mousePressed(evt);
    }
  }
 public void mouseExited(MouseEvent evt) {
   super.mouseExited(evt);
   tracker.mouseExited(evt);
 }
示例#8
0
 public void deactivate(DrawingView view) {
   super.deactivate();
   endEdit();
 }