How to get started with Prefuse and Netbeans

I was looking for a java based visualization toolkit for quite a while. Either they are very static (image rendered and delivered without any interaction) or cost too much money or badly documented or plain buggy and incomplete. I found a toolkit called prefuse (link) on sourceforge which is an amazing piece of work done by Jeffrey Heer (link) of Berkeley University Stanford. Thanks for this and to the people in the forum (link) to continue the effort to answer questions.

Though it’s last release if dating 2007.10 it is feature complete and not really need to carry the beta tag, but never mind. The project migrated to flare (link) based on Flash and AS, but unfortunately that is not always the first choice, even more powerful in terms of graphics. But I wonder what would be missing. It is open source, so with community effort things can be implemented or even added.
It is released under BSD and can be used freely for commercial and non-commercial applications.

I am a true Netbean nerd, aka NB user and spent some time to get started with prefuse.

Today I wan to share with you the steps (i did) to get a running with prefuse and Netbeans running Windows.
(Please note, it might not be the perfect or smartest approach. I dont claim its the right way or complete, but I got it to work this way. )
I am sure this is very basic information for the prefuse experts, but other beginners might need to go through the same steps.

1. Donwload the file prefuse-beta-20071021.zip (link).

2. Unzip the file to folder.

3. Check for a properly set JAVA_HOME path, like

E:\Documents and Settings\SAM>echo %JAVA_HOME%
E:\Program Files\Java\jdk1.6.0_10

4. Open the file build.bat with text editor of your choice and change the follwoing line
%JAVA_HOME%\bin\java.exe -Dant.home=…
to
java.exe -Dant.home=…
(I removed the JAVA_HOME because java already is in the system PATH)

5. Open a DOS-Box (Windows, aka run.. CMD) and navigate to the folder with the build.bat file.

6. Execute ‘build.bat all’. You should get something like this:

Build

prefuse and Netbeans: Build the jarfiles

7. Start Netbeans and create a new project (New, Choose project, Java, Java Application). Lets call it PrefuseDemo.

8. Open the project properties (right click on the project name in the project explorer) and select properties. Go to the libraries sectio and add prefuse.jar and demo.jar (required for the sample code). You find these files in the folder ‘build’ created by our build.bat.

9. Now you change the packagename (with the initial created Main.Java if selected) to prefusedemo.

10. In the build folder you also find a src folder with various sample java code. For this tutorial I took GraphView.java.

11. Create a new javaclass in the prefuse package with the name GraphView.

12. Copy the complete sourcecode from GraphView.java into it and replace the basic skeleton.

13. Fix the package name to package prefusedemo;

14. You can delete the Main.java if NB created it for you.

15. Build the project.

16. Right click onGraphView.java and select Run File. Finished ! You should see this:

t200901300014

prefuse and Netbeans: Run the demo


Remarks:
1. The other files (demos that come with the prefuse package) you can create the same way and add them into your demo application.
2. I tried to import the whole prefuse source folder into Netbeans via Import, but it didnt work.

Conclusion:
Now we got started, lets move on to understand the prefuse concept and adapt some of the samples to our own applications or create new ones from the scratch ! Stay tuned for more prefuse !

Advertisements

13 thoughts on “How to get started with Prefuse and Netbeans

  1. Great Tutorial!!! Thanks… I was having a hard time trying to run this in NetBeans 6.5 but it was a breeze following your steps. Do you know if I can visualize multiple XML documents (the tree structure that is) at one time?

  2. Interesting question. Guess possible to load a new GML file with same structure on the fly. Otherwise you would need to create a second graph instance. Even more interesting, have a tree view on the left and a radial view on the right. Select a node in the tree change what you see in the other view.

  3. I used the Eclipse Project Importer plugin to import prefase-beta project into Netbeans 6.5 using the “Import Project ignoring Project Dependencies” function. After this was complete I was able to Build the whole project. No need to create a Netbeans project or classes to run any of the demos, just right click “demos/preface.demos/GraphView.java” and Run file. voila!!

    Netbeans 6.5 does not has the Eclipse Project Importer plugin by default. Just go to Tools/Plugins and install Eclipse Project Importer plugin.

  4. I followed your steps but end up with the following error:

    java.lang.NoClassDefFoundError: prefusedemo/GraphView
    Caused by: java.lang.ClassNotFoundException: prefusedemo.GraphView
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    Could not find the main class: prefusedemo.GraphView. Program will exit.
    Exception in thread “main”
    Exception in thread “main” Java Result: 1

    Any clue how to fix it? Thanks in advance.

    • I get this message when i try to run the entire project (by clicking the gui green triangle button).

      You need to run file (right click on the GraphView.java in your project explorer and select Run File – or simply press shift+F6)

  5. Your tutorial is just perfect.
    Thanks for this. It helped me a lot integrating Prefuse to my Project.
    I will visit your site for sure again. Very informative and descriptive Presentation.
    Keep up the good work, dude.

  6. Congratulations !!! The text helped me to install and test prefuse using NB…

    I´m sure I could´n get it without this simple tutorial…. Thanks !!!

  7. Great tutorial for a noob like me. I have been working with the examples and unraveling them to apply to my application. My question is: I notice on the back end of NetBean the ability for SQL and queries, have you created a tutorial for tying data in SQL to something like the TreeView.java? Or point me to one on another site?

    • I gave up on prefuse and moved on the D3. Sorry.
      I would recommend to do the same if you can shift into an web environment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s