private Vertex findSingleVertex() { Vertex vertex = selection.getAnyVertex(); // if there is no selection we select an existing vertex if (vertex == null) { vertex = (Vertex) graph.getVertices().next(); } return vertex; }
/** * 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); } } }
private void selectDependency(KeyEvent evt) { Vertex vertex = selection.getAnyVertex(); if (vertex != null && vertex instanceof DependentTarget) { selection.selectOnly(vertex); List<Dependency> dependencies = ((DependentTarget) vertex).dependentsAsList(); Dependency currentDependency = dependencies.get(currentDependencyIndex); if (currentDependency != null) { selection.remove(currentDependency); } currentDependencyIndex += (evt.getKeyCode() == KeyEvent.VK_PAGE_UP ? 1 : -1); currentDependencyIndex %= dependencies.size(); if (currentDependencyIndex < 0) { // % is not a real modulo currentDependencyIndex = dependencies.size() - 1; } currentDependency = (Dependency) dependencies.get(currentDependencyIndex); if (currentDependency != null) { selection.add(currentDependency); } } }