Search in sources :

Example 1 with Rectangle

use of org.gephi.visualization.selection.Rectangle in project gephi by gephi.

the class CompatibilityEngine method stopDrag.

@Override
public void stopDrag() {
    //Selection
    if (vizConfig.isSelectionEnable() && rectangleSelection) {
        Rectangle rectangle = (Rectangle) currentSelectionArea;
        rectangle.stop();
        scheduler.requireUpdateSelection();
    }
    dragSelected = null;
}
Also used : Rectangle(org.gephi.visualization.selection.Rectangle)

Example 2 with Rectangle

use of org.gephi.visualization.selection.Rectangle in project gephi by gephi.

the class CompatibilityEngine method mouseMove.

@Override
public void mouseMove() {
    //Selection
    if (vizConfig.isSelectionEnable() && rectangleSelection) {
        Rectangle rectangle = (Rectangle) currentSelectionArea;
        rectangle.setMousePosition(graphIO.getMousePosition(), graphIO.getMousePosition3d());
        if (rectangle.isStop()) {
            return;
        }
    }
    if (customSelection || currentSelectionArea.blockSelection()) {
        return;
    }
    if (!rectangleSelection && graphIO.isDragging()) {
        return;
    }
    boolean someSelection = false;
    for (Iterator<NodeModel> itr = octree.getSelectableNodeIterator(); itr.hasNext(); ) {
        NodeModel obj = itr.next();
        if (isUnderMouse(obj)) {
            if (!obj.isSelected()) {
                //New selected
                obj.setSelected(true);
            }
            someSelection = true;
        } else if (obj.isSelected()) {
            obj.setSelected(false);
        }
    }
    if (vizController.getVizModel().isLightenNonSelectedAuto()) {
        if (vizConfig.isLightenNonSelectedAnimation()) {
            if (!anySelected && someSelection) {
                //Start animation
                lightenAnimationDelta = 0.07f;
            } else if (anySelected && !someSelection) {
                //Stop animation
                lightenAnimationDelta = -0.07f;
            }
            vizConfig.setLightenNonSelected(someSelection || lightenAnimationDelta != 0);
        } else {
            vizConfig.setLightenNonSelected(someSelection);
        }
    }
    anySelected = someSelection;
}
Also used : NodeModel(org.gephi.visualization.model.node.NodeModel) Rectangle(org.gephi.visualization.selection.Rectangle)

Example 3 with Rectangle

use of org.gephi.visualization.selection.Rectangle 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)

Example 4 with Rectangle

use of org.gephi.visualization.selection.Rectangle in project gephi by gephi.

the class StandardGraphIO method mouseDragged.

@Override
public void mouseDragged(MouseEvent e) {
    float globalScale = graphDrawable.getGlobalScale();
    float x = e.getX();
    float y = graphDrawable.viewport.get(3) - e.getY() - 1;
    if (rightButtonMoving[0] != -1) {
        //The right button is pressed
        float proche = graphDrawable.cameraTarget[2] - graphDrawable.cameraLocation[2];
        proche = proche / 300;
        graphDrawable.cameraTarget[0] += (x - rightButtonMoving[0]) * proche;
        graphDrawable.cameraTarget[1] += (y - rightButtonMoving[1]) * proche;
        graphDrawable.cameraLocation[0] += (x - rightButtonMoving[0]) * proche;
        graphDrawable.cameraLocation[1] += (y - rightButtonMoving[1]) * proche;
        rightButtonMoving[0] = x;
        rightButtonMoving[1] = y;
        engine.getScheduler().requireUpdateVisible();
    }
    if (leftButtonMoving[0] != -1) {
        //Remet à jour aussi la mousePosition pendant le drag, notamment pour coller quand drag released
        mousePosition[0] = (int) x;
        mousePosition[1] = (int) y;
        double[] marker = graphDrawable.draggingMarker;
        //Set to centric coordinates
        mousePosition3d[0] = (float) ((x - graphDrawable.viewport.get(2) / 2.0) / -marker[0]) + graphDrawable.cameraTarget[0] / globalScale;
        mousePosition3d[1] = (float) ((y - graphDrawable.viewport.get(3) / 2.0) / -marker[1]) + graphDrawable.cameraTarget[1] / globalScale;
        mouseDrag3d[0] = mousePosition3d[0];
        mouseDrag3d[1] = mousePosition3d[1];
        if (vizController.getVizConfig().isSelectionEnable() && engine.isRectangleSelection()) {
            if (!dragging) {
                //Start drag
                dragging = true;
                Rectangle rectangle = (Rectangle) engine.getCurrentSelectionArea();
                rectangle.start(mousePosition, mousePosition3d);
            }
            engine.getScheduler().requireUpdateSelection();
        } else if (vizController.getVizConfig().isDraggingEnable()) {
            if (!dragging) {
                //Start drag
                dragging = true;
                engine.getScheduler().requireStartDrag();
            }
            engine.getScheduler().requireDrag();
        } else if (vizController.getVizConfig().isMouseSelectionUpdateWhileDragging()) {
            engine.getScheduler().requireDrag();
        } else {
            if (!dragging) {
                //Start drag
                dragging = true;
                startDrag2d[0] = x;
                startDrag2d[1] = y;
                vizEventManager.startDrag();
            }
            mouseDrag[0] = x - startDrag2d[0];
            mouseDrag[1] = y - startDrag2d[1];
            vizEventManager.drag();
        }
        leftButtonMoving[0] = x;
        leftButtonMoving[1] = y;
    }
}
Also used : Rectangle(org.gephi.visualization.selection.Rectangle)

Example 5 with Rectangle

use of org.gephi.visualization.selection.Rectangle in project gephi by gephi.

the class CompatibilityEngine method mouseClick.

@Override
public void mouseClick() {
    if (vizConfig.isSelectionEnable() && rectangleSelection && !customSelection) {
        Rectangle rectangle = (Rectangle) currentSelectionArea;
        //rectangle.setBlocking(false);
        resetEdgesSelection();
        //Select with click
        boolean someSelection = false;
        for (Iterator<NodeModel> itr = octree.getSelectableNodeIterator(); itr.hasNext(); ) {
            NodeModel obj = (NodeModel) itr.next();
            if (isUnderMouse(obj)) {
                if (!obj.isSelected()) {
                    //New selected
                    obj.setSelected(true);
                }
                someSelection = true;
            } else if (obj.isSelected()) {
                someSelection = true;
            }
        }
        if (!(rectangle.isCtrl() && someSelection)) {
            for (NodeModel nm : getSelectedNodes()) {
                nm.setSelected(false);
            }
            someSelection = false;
        }
        rectangle.setBlocking(someSelection);
        if (vizController.getVizModel().isLightenNonSelectedAuto()) {
            if (vizConfig.isLightenNonSelectedAnimation()) {
                if (!anySelected && someSelection) {
                    //Start animation
                    lightenAnimationDelta = 0.07f;
                } else if (anySelected && !someSelection) {
                    //Stop animation
                    lightenAnimationDelta = -0.07f;
                }
                vizConfig.setLightenNonSelected(someSelection || lightenAnimationDelta != 0);
            } else {
                vizConfig.setLightenNonSelected(someSelection);
            }
        }
        anySelected = someSelection;
        scheduler.requireUpdateSelection();
    }
}
Also used : NodeModel(org.gephi.visualization.model.node.NodeModel) Rectangle(org.gephi.visualization.selection.Rectangle)

Aggregations

Rectangle (org.gephi.visualization.selection.Rectangle)5 NodeModel (org.gephi.visualization.model.node.NodeModel)2 GraphContextMenu (org.gephi.visualization.apiimpl.GraphContextMenu)1