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 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(); }
private void arrowKeyUp(KeyUpEvent event) { if (!diagramPane.getPopupMenu().isShowing()) { int x = 0; int y = 0; if (event.isLeftArrow()) { x = Parameters.MOVEX; } else if (event.isRightArrow()) { x = -Parameters.MOVEX; } else if (event.isUpArrow()) { y = Parameters.MOVEY; } else if (event.isDownArrow()) { y = -Parameters.MOVEY; } diagramPane.translate(x, y); diagramPane.update(); } }