/** * Post the context menu of one selected element of the current selection. If any dependencies are * selected, show the menu for one of those. Otherwise show the menu for a randomly chosen target. */ private void postMenu() { // first check whether we have selected edges Dependency dependency = (Dependency) selection.getAnyEdge(); if (dependency != null) { Point p = ((GraphPainterStdImpl) GraphPainterStdImpl.getInstance()) .getDependencyPainter(dependency) .getPopupMenuPosition(dependency); postMenu(dependency, p.x, p.y); } else { // if not, choose a target Vertex vertex = selection.getAnyVertex(); if (vertex != null) { selection.selectOnly(vertex); int x = vertex.getX() + vertex.getWidth() - 20; int y = vertex.getY() + 20; postMenu(vertex, x, y); } } }