private void mouseMove(GwtEvent<? extends EventHandler> event) {
    int[] coord = getCoordinates(event);
    int x = coord[0];
    int y = coord[1];

    if (isMouseDown) {
      // Do panning
      int dx = x - previousX;
      int dy = y - previousY;

      if (draggableNode != null) {
        WidgetStyle.setCursor(canvas, Cursor.POINTER);

        double scale = canvas.getScale();
        int scaleDeltaX = (int) (dx / scale);
        int scaleDeltaY = (int) (dy / scale);
        diagramPane.drag(draggableNode, scaleDeltaX, scaleDeltaY);
      } else {
        WidgetStyle.setCursor(canvas, Cursor.DEFAULT);
        diagramPane.translate(dx, dy);
        diagramPane.update();
      }

      previousX = x;
      previousY = y;
      isDragging = true;
    } else {
      diagramPane.hover(x, y);
    }
  }
  private void mouseUp(GwtEvent<? extends EventHandler> event) {
    if (!isMouseDown) return;

    int[] coord = getCoordinates(event);
    int x = coord[0];
    int y = coord[1];

    isMouseDown = false;

    if (isDragging) {
      isDragging = false;
      draggableNode = null;
      WidgetStyle.setCursor(canvas, Cursor.DEFAULT);
    } else { // Do click selection
      // TODO: selection cannot work under iPad. Need to check touchEnd event.
      diagramPane.select(event, x, y);
    }
  }