@Override public void onMouseDown(final MouseDownEvent event) { VConsole.log("onMouseDown"); extractSelection(); removeSelectionBox(); if (currentKeyModifiers.contains(KeyCodes.KEY_CTRL)) { selectionBox.setSelectionBoxStartX(event.getX()); selectionBox.setSelectionBoxStartY(event.getY()); selectionBox.setSelectionBoxVisible(true); VConsole.log( "onMouseDown - selection started:" + selectionBox.getSelectionBoxStartX() + "," + selectionBox.getSelectionBoxStartY()); } else if (event.getSource() instanceof VNode) { onMove = false; } else if (event.getSource() instanceof DrawingArea) { onMove = true; startX = event.getX(); startY = event.getY(); VConsole.log("onMouseDown - moving"); } else { VConsole.error("onMouseDown - UNKNOWN STATE"); } }
private void removeSelectionBox() { if (selectionBox.isSelectionBoxVisible()) { canvas.remove(selectionBox); selectionBox.setSelectionBoxVisible(false); VConsole.log("selection box removed from canvas"); selectionBox.setSelectionBoxRightHandSide(true); } }
private void extractSelection() { final int x1 = selectionBox.getSelectionBoxStartX(); final int y1 = selectionBox.getSelectionBoxStartY(); if (selectionBox.isSelectionBoxVisible()) { final int x2 = x1 + selectionBox.getWidth(); final int y2 = y1 + selectionBox.getHeight(); VConsole.log("selectNodesAndEdgesInTheBox: " + x1 + "," + y1 + " " + x2 + "," + y2); selectNodesAndEdgesInTheBox(x1, y1, x2, y2); } }
private void paintGraph() { selectionBox.setSelectionBoxVisible(false); fps = 1f / ((System.currentTimeMillis() - paintStartTime) / 1000f); paintStartTime = System.currentTimeMillis(); if (showInfo) { if (info != null) { canvas.remove(info); } canvas.add(info = getInfo()); } }
@Override public void onMouseMove(final MouseMoveEvent event) { final int currentX = event.getX(); final int currentY = event.getY(); if (selectionBox.isSelectionBoxVisible()) { selectionBox.drawSelectionBox(canvas, currentX, currentY); } else if (graph.getMovedShape() != null) { final VNode moved = graph.getMovedShape(); moved.moveNode(currentX, currentY); } else if (onLink) { if (linkLine != null) { canvas.remove(linkLine); } linkLine = getLinkLine(currentX, currentY); canvas.add(linkLine); } else if (onMove && event.getSource().equals(canvas)) { graph.moveGraph(startX - currentX, startY - currentY); startX = currentX; startY = currentY; } }