protected DrawingView createDrawingView(Drawing newDrawing) {
   Dimension d = getDrawingViewSize();
   DrawingView newDrawingView = new StandardDrawingView(this, d.width, d.height);
   newDrawingView.setDrawing(newDrawing);
   fireViewCreatedEvent(newDrawingView);
   return newDrawingView;
 }
 /** Refreshes the drawing if there is some accumulated damage */
 public synchronized void checkDamage() {
   Iterator each = drawing().drawingChangeListeners();
   while (each.hasNext()) {
     Object l = each.next();
     if (l instanceof DrawingView) {
       ((DrawingView) l).repairDamage();
     }
   }
 }
Beispiel #3
0
  /** Handles a mouse click. */
  @Override
  public boolean handleMouseClick(Point2D.Double p, MouseEvent evt, DrawingView view) {
    if (evt.getClickCount() == 2 && view.getHandleDetailLevel() % 2 == 0) {
      willChange();
      final int index = splitSegment(p, 5f / view.getScaleFactor());
      if (index != -1) {
        final BezierPath.Node newNode = getNode(index);
        fireUndoableEditHappened(
            new AbstractUndoableEdit() {
              private static final long serialVersionUID = 1L;

              @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;
  }
 /**
  * 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;
 }