@Override public void itemPressed(VisualItem item, MouseEvent e) { // on right-mouse press, start dragging the document if (SwingUtilities.isRightMouseButton(e)) { // debug System.out.println("debug: " + this.getClass().getName() + ": item pressed w/ right mouse"); // drag, set the focus to the current node Visualization vis = item.getVisualization(); vis.getFocusGroup(Visualization.FOCUS_ITEMS).setTuple(item); item.setFixed(true); dragged = false; Display d = controller.getDocumentGrid(); down = d.getAbsoluteCoordinate(e.getPoint(), down); } }
@Override public void itemDragged(VisualItem item, MouseEvent e) { if (!SwingUtilities.isRightMouseButton(e)) { return; } if (item.getGroup().equals(m_group)) { dragged = true; // Display d = (Display) e.getComponent(); Display d = controller.getDocumentGrid(); d.getAbsoluteCoordinate(e.getPoint(), temp); double dx = temp.getX() - down.getX(); double dy = temp.getY() - down.getY(); double x = item.getX(); double y = item.getY(); double w = item.getDouble(WIDTH); double h = item.getDouble(HEIGHT); item.setStartX(x); item.setStartY(y); item.setX(x + dx); item.setY(y + dy); item.setEndX(x + dx); item.setEndY(y + dy); item.setBounds(x + dx, y + dy, w, h); if (repaint) { item.getVisualization().repaint(); } down.setLocation(temp); if (action != null) { d.getVisualization().run(action); } } }