Search in sources :

Example 1 with NodePressingEventListener

use of org.gephi.tools.spi.NodePressingEventListener in project gephi by gephi.

the class Painter method getListeners.

@Override
public ToolEventListener[] getListeners() {
    listeners = new ToolEventListener[1];
    listeners[0] = new NodePressingEventListener() {

        @Override
        public void pressingNodes(Node[] nodes) {
            color = painterPanel.getColor().getColorComponents(color);
            for (Node node : nodes) {
                float r = node.r();
                float g = node.g();
                float b = node.b();
                r = intensity * color[0] + (1 - intensity) * r;
                g = intensity * color[1] + (1 - intensity) * g;
                b = intensity * color[2] + (1 - intensity) * b;
                node.setR(r);
                node.setG(g);
                node.setB(b);
            }
        }

        @Override
        public void released() {
        }
    };
    return listeners;
}
Also used : Node(org.gephi.graph.api.Node) NodePressingEventListener(org.gephi.tools.spi.NodePressingEventListener)

Example 2 with NodePressingEventListener

use of org.gephi.tools.spi.NodePressingEventListener in project gephi by gephi.

the class Brush method getListeners.

@Override
public ToolEventListener[] getListeners() {
    listeners = new ToolEventListener[1];
    listeners[0] = new NodePressingEventListener() {

        @Override
        public void pressingNodes(Node[] nodes) {
            diffusionMethod = brushPanel.getDiffusionMethod();
            color = brushPanel.getColor().getColorComponents(color);
            intensity = brushPanel.getIntensity();
            brush(nodes);
        }

        @Override
        public void released() {
        }
    };
    return listeners;
}
Also used : Node(org.gephi.graph.api.Node) NodePressingEventListener(org.gephi.tools.spi.NodePressingEventListener)

Example 3 with NodePressingEventListener

use of org.gephi.tools.spi.NodePressingEventListener in project gephi by gephi.

the class DesktopToolController method select.

@Override
public void select(Tool tool) {
    unselect();
    if (tool == null) {
        return;
    }
    //Connect events
    ArrayList<ToolEventHandler> handlers = new ArrayList<>();
    for (ToolEventListener toolListener : tool.getListeners()) {
        if (toolListener instanceof NodeClickEventListener) {
            NodeClickEventHandler h = new NodeClickEventHandler(toolListener);
            h.select();
            handlers.add(h);
        } else if (toolListener instanceof NodePressingEventListener) {
            NodePressingEventHandler h = new NodePressingEventHandler(toolListener);
            h.select();
            handlers.add(h);
        } else if (toolListener instanceof MouseClickEventListener) {
            MouseClickEventHandler h = new MouseClickEventHandler(toolListener);
            h.select();
            handlers.add(h);
        } else if (toolListener instanceof NodePressAndDraggingEventListener) {
            NodePressAndDraggingEventHandler h = new NodePressAndDraggingEventHandler(toolListener);
            h.select();
            handlers.add(h);
        } else {
            throw new RuntimeException("The ToolEventListener " + toolListener.getClass().getSimpleName() + " cannot be recognized");
        }
    }
    currentHandlers = handlers.toArray(new ToolEventHandler[0]);
    switch(tool.getSelectionType()) {
        case NONE:
            VizController.getInstance().getSelectionManager().disableSelection();
            break;
        case SELECTION:
            VizController.getInstance().getSelectionManager().blockSelection(true);
            VizController.getInstance().getSelectionManager().setDraggingEnable(false);
            break;
        case SELECTION_AND_DRAGGING:
            VizController.getInstance().getSelectionManager().blockSelection(true);
            VizController.getInstance().getSelectionManager().setDraggingEnable(true);
            break;
    }
    currentTool = tool;
    currentTool.select();
}
Also used : MouseClickEventListener(org.gephi.tools.spi.MouseClickEventListener) ArrayList(java.util.ArrayList) NodePressingEventListener(org.gephi.tools.spi.NodePressingEventListener) NodePressAndDraggingEventListener(org.gephi.tools.spi.NodePressAndDraggingEventListener) ToolEventListener(org.gephi.tools.spi.ToolEventListener) NodeClickEventListener(org.gephi.tools.spi.NodeClickEventListener)

Aggregations

NodePressingEventListener (org.gephi.tools.spi.NodePressingEventListener)3 Node (org.gephi.graph.api.Node)2 ArrayList (java.util.ArrayList)1 MouseClickEventListener (org.gephi.tools.spi.MouseClickEventListener)1 NodeClickEventListener (org.gephi.tools.spi.NodeClickEventListener)1 NodePressAndDraggingEventListener (org.gephi.tools.spi.NodePressAndDraggingEventListener)1 ToolEventListener (org.gephi.tools.spi.ToolEventListener)1