コード例 #1
0
 @Override
 public void mouseClicked(MouseEvent evt) {
   if (evt.getClickCount() == 2) {
     multicaster.trackDoubleClick(
         new Point(evt.getX(), evt.getY()), evt.getModifiersEx(), getView());
   }
   evt.consume();
 }
コード例 #2
0
  @Override
  public boolean handleMouseClick(Point2D.Double p, MouseEvent evt, DrawingView view) {
    if (evt.getClickCount() == 2 /* && view.getHandleDetailLevel() == 0*/) {
      willChange();

      // Apply inverse of transform to point
      if (get(TRANSFORM) != null) {
        try {
          p = (Point2D.Double) get(TRANSFORM).inverseTransform(p, new Point2D.Double());
        } catch (NoninvertibleTransformException ex) {
          System.err.println(
              "Warning: SVGBezierFigure.handleMouseClick. Figure has noninvertible Transform.");
        }
      }

      final int index = splitSegment(p, (float) (5f / view.getScaleFactor()));
      if (index != -1) {
        final BezierPath.Node newNode = getNode(index);
        fireUndoableEditHappened(
            new AbstractUndoableEdit() {
              @Override
              public String getPresentationName() {
                ResourceBundleUtil labels =
                    ResourceBundleUtil.getBundle("org.jhotdraw.draw.Labels");
                return labels.getString("edit.bezierPath.splitSegment.text");
              }

              @Override
              public void redo() throws CannotRedoException {
                super.redo();
                willChange();
                addNode(index, newNode);
                changed();
              }

              @Override
              public void undo() throws CannotUndoException {
                super.undo();
                willChange();
                removeNode(index);
                changed();
              }
            });
        changed();
        evt.consume();
        return true;
      }
    }
    return false;
  }