Hi all,
I like your API. It's very friendly and has powerful features that can be very
useful for graphical projects. Thank you for developing that library.
Just I've missed how to do zooming and panning to make sort of animation for my
graph (with no mouse or key events), as I want to produce a video in the next
step. So, for the first step I have wrote this piece of code:
public class CLA {
public static void main(String args[]) throws InterruptedException,
FileNotFoundException, IOException {
.
.
.
System.setProperty("sun.java2d.opengl", "true");
System.setProperty("org.graphstream.ui.renderer",
"org.graphstream.ui.j2dviewer.J2DGraphRenderer");
Graph graph = new SingleGraph("CLA");
graph.addAttribute("ui.quality");
graph.addAttribute("ui.antialias");
graph.addAttribute("ui.stylesheet", "url('file:///path/to/myfile')");
Viewer CLAgraphViewer = new Viewer(graph,
Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD);
View view = CLAgraphViewer.addDefaultView(true);
CLAgraphViewer.enableAutoLayout();
ProxyPipe viewerPipe = CLAgraphViewer.newViewerPipe();
viewerPipe.addAttributeSink(graph);
while ((line = br.readLine()) != null) {
String[] tokens = line.split("[ ]+");
Node a = graph.addNode(tokens[0]);
Thread.sleep(100);
viewerPipe.pump();
double[] aPosition = Toolkit.nodePosition(a);
Node b = graph.addNode(tokens[1]);
newNode.addAttribute("xy", aPosition[0]+1, aPosition[1]+1);
double[] bPosition = Toolkit.nodePosition(b);
view.getCamera().setViewCenter((aPosition[0] + bPosition[0])/2,
(aPosition[1] + bPosition[1])/2,
(aPosition[2] + bPosition[2])/2);
view.getCamera().setViewPercent(0.5);
Thread.sleep(1000);
setNodeStyle(tokens[0], graph);
setNodeStyle(tokens[1], graph);
setEdgeStyle(tokens, graph);
Thread.sleep(1000);
view.getCamera().resetView();
}
.
.
.
}
The problem is that when I use view.getCamera().setViewCenter, no panning
happens and so when doing setViewPercent or resetView. So, how can I do panning
and zooming like enableAutolayout did? I need to do sort of animation to focus
on any insertion like in GraphStream demo video - tracking exmaple section
(https://www.youtube.com/watch?v=XX5rRF6uxow#t=115).
Archives gérées par MHonArc 2.6.16.