コード例 #1
0
  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);
    }
  }
コード例 #2
0
  private void centreObject(GraphObject obj) {
    // Centre selected object
    // PathwayCanvas c = diagramPane.getCanvas();

    double scale = canvas.getScale();

    Point objPos = obj.getPosition();
    double objX = objPos.getX();
    double objY = objPos.getY();

    double x = (objX * -1.0 * scale) + (canvas.getCoordinateSpaceWidth() / 2);
    double y = (objY * -1.0 * scale) + (canvas.getCoordinateSpaceHeight() / 2);

    diagramPane.reset();
    diagramPane.scale(scale);
    diagramPane.translate(x, y, true);
    diagramPane.hideTooltip();
  }