GraphStream Users

Archives de la liste Aide

Re: Graph zooming and panning

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


The movie was done using FileSinkImages and the setViewCenter() / setViewPercent() methods of Camera.
You ca find the sources here : 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.

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

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");
  Graph graph = new SingleGraph("CLA");
  graph.addAttribute("ui.stylesheet", "url('file:///path/to/myfile')");
  Viewer CLAgraphViewer = new Viewer(graph,
  View view = CLAgraphViewer.addDefaultView(true);

  ProxyPipe viewerPipe = CLAgraphViewer.newViewerPipe();

  while ((line = br.readLine()) != null) {
    String[] tokens = line.split("[ ]+");

    Node a = graph.addNode(tokens[0]);
    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);

    setNodeStyle(tokens[0], graph);
    setNodeStyle(tokens[1], graph);
    setEdgeStyle(tokens, graph);


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

Guilhelm Savin
PhD of Computer Science

Archives gérées par MHonArc 2.6.16.

Top of page