Search in sources :

Example 1 with GraphContextMenu

use of org.gephi.visualization.apiimpl.GraphContextMenu in project gephi by gephi.

the class StandardGraphIO method mouseClicked.

/**
     * Mouse clicked event.
     */
@Override
public void mouseClicked(MouseEvent e) {
    switch(e.getButton()) {
        case MouseEvent.BUTTON1:
            if (vizController.getVizConfig().isSelectionEnable() && engine.isRectangleSelection()) {
                Rectangle r = (Rectangle) engine.getCurrentSelectionArea();
                boolean ctrl = (e.getModifiers() & InputEvent.CTRL_DOWN_MASK) != 0 || (e.getModifiers() & InputEvent.CTRL_MASK) != 0 || (e.getModifiers() & InputEvent.META_MASK) != 0;
                r.setCtrl(ctrl);
            }
            engine.getScheduler().requireMouseClick();
            vizEventManager.mouseLeftClick();
            break;
        case MouseEvent.BUTTON3:
            if (vizController.getVizConfig().isContextMenu()) {
                GraphContextMenu popupMenu = new GraphContextMenu();
                float globalScale = graphDrawable.getGlobalScale();
                int x = (int) (mousePosition[0] / globalScale);
                int y = (int) ((graphDrawable.viewport.get(3) - mousePosition[1]) / globalScale);
                popupMenu.getMenu().show(graphDrawable.getGraphComponent(), x, y);
            }
            vizEventManager.mouseRightClick();
            break;
        case MouseEvent.BUTTON2:
            vizEventManager.mouseMiddleClick();
            break;
        default:
    }
}
Also used : GraphContextMenu(org.gephi.visualization.apiimpl.GraphContextMenu) Rectangle(org.gephi.visualization.selection.Rectangle)

Aggregations

GraphContextMenu (org.gephi.visualization.apiimpl.GraphContextMenu)1 Rectangle (org.gephi.visualization.selection.Rectangle)1