how to use static layout in graphstream


I would like to generate static graph use GraphStream. Is there any suggestion solutions?

I read input data from DGS file (generated from other model). Because the number of nodes is not fix every time and I don't want to manually specify each position of each node. Currently I can use the autolayout function to place the nodes and the result is OK, but the problem is: each node can be moved if you click the node and drag it. Is there any way to generate the graph use autolayout, and the node is un-draggable at the same time?

Thanks in advance!


In order to prevent user interaction with the default viewer, you need to specify a new MouseManager, in the default View, that actually does nothing.

Since you cannot set a null MouseManager (it would spawn the default one), you need to create a new class that basically does nothing and give it to the View.

A dirty way of doing it:

graph.display() .getDefaultView() .setMouseManager(new MouseManager(){ @Override public void mouseClicked(MouseEvent e) {} @Override public void mousePressed(MouseEvent e) {} @Override public void mouseReleased(MouseEvent e) {} @Override public void mouseEntered(MouseEvent e) {} @Override public void mouseExited(MouseEvent e) {} @Override public void mouseDragged(MouseEvent e) {} @Override public void mouseMoved(MouseEvent e) {} @Override public void init(GraphicGraph graph, View view) {} @Override public void release() {} });


This is inspired by @Yoann answer, but its a better way of performing the job. If you just want to strict some of the mouse activity, you can do following:

ViewPanel viewPanel = graph.display().getDefaultView(); MouseManager manager = new DefaultMouseManager() { @Override public void mouseDragged(MouseEvent event) { } @Override protected void mouseButtonPress(MouseEvent event) { super.mouseButtonPress(event); System.out.println("Press"); } @Override public void mouseClicked(MouseEvent event) { super.mouseClicked(event); System.out.println("Clicked"); } @Override public void mousePressed(MouseEvent event) { super.mousePressed(event); // if you need object of Node pressed, following code will help you, curElement is already defined at DefaultMouseManager. curElement = view.findNodeOrSpriteAt(event.getX(), event.getY()); if (curElement != null) { Node node = graph.getNode(curElement.getId()); if(node != null) { System.out.println("Mouse pressed at node: " + node.getId()); } } } }; viewPanel.setMouseManager(manager);

Here, I have disabled mouseDragged, and writing my own code after performing default mouseButtonPress, mouseClicked and mousePressed event. You can even create your own Class which extends DefaultMouseManaer and override the function you want and set that object to mouse manager, this will be more clear way of programming.


  • android - “your device isn't compatible with this version”
  • Highcharts series update with animation
  • Android GoogleAPIClient - NoClassDefFoundError: com/google/android/gms/internal/zzsa
  • igraph/visNetwork with R: How to disable forward linking?
  • Does Google App Engine support C++? [closed]
  • How can I implement a JavaScript that submit this form according to the clicket button? [duplicate]
  • How to add text to textarea when user clicks a button
  • gradle processResources with different replacement and renaming rules
  • Running gauge tests from jar file
  • error: cast from 'Foo*' to 'unsigned int' loses precision
  • Manifest merger failed, minSdkVersion 1 cannot be smaller than version 4 declared in library
  • Jsoncpp FastWriter right trim
  • A Back/Home Button [Java]
  • Application backgrounding in Xamarin.Mac
  • Spotify Apps API: get other users' playlists
  • Django staticgenerator vs CACHE_BACKEND
  • How to print every 4th column up to nth column and from (n+1)th column to last using awk?
  • Laravel 5.7: Custom blade template for Maintenance Mode but not 503.blade.php
  • Gradle refresh removes source folders in build path
  • Check 'Manager can update membership list' in AD
  • create circular Auto Horizontal Scroll View?
  • android check if file exists with case sensitivity?
  • How to get “crispEdges” for SVG text?
  • Modifying native query cannot have named parameter bindings?
  • Adding native code to an existing Worklight hybrid app
  • Swift manually rotate view controller
  • how to specify different css for ie
  • java.io.FileNotFoundException: Could not open ServletContext resource [/WEB-INF/SpringDispatcher-ser
  • Floating parent div grows to hypothetical width of floating child div
  • VS2010 RDLC C#. How can I set a LocalReport object to a ReportViewer?
  • Android: Unable to detect vertical plane
  • reshape/remould data frame to create normalized bar chart and pie chart
  • Using redis as an LRU cache for postgres
  • read part of h5 dataset python
  • Debug `Unexpected end of JSON input Error` on content script
  • Apple Mach-O Linker error (“duplicate symbol”)
  • Angular FormGroup won't update it's value immediately after patchValue or setValue
  • convert json to excel in java
  • Create/delete users from text file using Bash script
  • How to check if object is null in Java?