Open jxiw opened 4 years ago
Still do not work. Here are my code.
public class Visualization implements ViewerListener{
public void init() {
// Initialize viewer
System.setProperty("org.graphstream.ui.renderer",
"org.graphstream.ui.j2dviewer.J2DGraphRenderer");
graph = new SingleGraph("Graph");
viewer = graph.display(false);
viewer.setCloseFramePolicy(Viewer.CloseFramePolicy.CLOSE_VIEWER);
viewer.disableAutoLayout();
view = viewer.getDefaultView();
view.setLayout(null);
pipeIn = viewer.newViewerPipe();
pipeIn.addViewerListener(this);
pipeIn.addSink(graph);
pipeIn.pump();
// Setup layout
layout = new TreeLayout(graph);
spriteManager = new SpriteManager(graph);
graph.setAttribute("ui.stylesheet", stylesheet);
graph.setAttribute("ui.antialias");
graph.setAttribute("ui.quality");
// Root node
addNode("root").addAttribute("ui.label", "Tree");
}
@Override
public void viewClosed(String s) {
}
@Override
public void buttonPushed(String s) {
System.out.println(s);
}
@Override
public void buttonReleased(String s) {
System.out.println(s);
}
void update() {
pipeIn.pump();
Node node = graph.addNode(id);
layout.nodeAdded(id);
Edge edge = graph.addEdge(edgeId, fromId, toId, directed);
layout.edgeAdded(edgeId, fromId, toId, directed);
}
}
@OVSS where call update()
I would like to retrieve nodes in the graph. But those nodes are not created at the beginning. Here are some codes.
initialize
add new nodes
mouse click
The issue is that the element is always null.
Is there anyone know why I can not retrieve those nodes.
Thanks.