new MouseClickEventListener() {
@Override
public void mouseClick(int[] positionViewport, float[] position3d) {
//Get current graph
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
Graph graph = gc.getModel().getGraph();
GraphFactory factory = gc.getModel().factory();
//Add node
Node node = factory.newNode();
node.getNodeData().setX(position3d[0]);
node.getNodeData().setY(position3d[1]);
node.getNodeData().setSize(10f);
graph.addNode(node);
}
},
new NodeClickEventListener() {
@Override
public void clickNodes(Node[] nodes) {
//Get mouse position
float[] position3d = VizController.getInstance().getGraphIO().getMousePosition3d();
//Get current graph
GraphController gc = Lookup.getDefault().lookup(GraphController.class);
Graph graph = gc.getModel().getGraph();
GraphFactory factory = gc.getModel().factory();
//Add node
Node node = factory.newNode();
node.getNodeData().setX(position3d[0]);
node.getNodeData().setY(position3d[1]);