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;
}
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;
}
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();
}
Aggregations