GraphStream Users

Archives de la liste Aide


Re: Graph zooming and panning


Chronologique Discussions 
  • From: guilhelm savin <guilhelm.savin AT gmail.com>
  • To: "graphstream-users AT litislab.fr" <graphstream-users AT litislab.fr>, mahmoudmubarak AT gmail.com
  • Subject: Re: Graph zooming and panning
  • Date: Fri, 19 Feb 2016 09:30:43 +0100

Hi,

The movie was done using FileSinkImages and the setViewCenter() / setViewPercent() methods of Camera.
You ca find the sources here : http://graphstream-project.org/download/ The tracking part is under the LeHavre class.
Default behavior of the Camera is to cover the whole graph, automatically computing min and max coordinates. But this behavior is overriden by the call of the methods above.

You can only set the center of the view, so you have to do the panning by yourself. Such features are not yet included into GraphStream.

Hope it helps.
Guilhelm

2016-02-17 11:02 GMT+01:00 <mahmoudmubarak AT gmail.com>:

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).



--
Guilhelm Savin
PhD of Computer Science



Archives gérées par MHonArc 2.6.16.

Top of page