Prefuse + Jython = Keren

English version of this post can be read at http://ngoprek.fajran.web.id/2009/07/using-prefuse-through-jython.html

Setelah semalem nyobain Jython, jadi kepikiran tuk make Prefuse dari Jython. Ternyata bisa! Utak-atik dikit lagi, dan jadilah sesuatu yg lebih menarik. Silakan lihat di screencast berikut =P

Kodingan bisa dilihat di http://gist.github.com/32288

Kalau mau nyoba:

  1. Download dan install Jython 2.5b0

    $ wget http://downloads.sourceforge.net/jython/jython_installer-2.5b0.jar
    $ java -jar jython_installer-2.5b0.jar
    

    Silakan atur sendiri lokasi instalasi.

  2. Download library prefuse.

    $ wget http://labs.fajran.web.id/p/ubuntu-pkg-vis/lib/prefuse.jar
    
  3. Atur environment variable

    $ export PATH=$PATH:/path/ke/lokasi/instalasi/jython
    $ export JYTHONPATH=$JYTHONPATH:prefuse.jar
    

    Pastikan kalo jalanin jython, muncul interactive shell-nya. Dan bisa ngejalanin yang berikut

    >>> import prefuse
    
  4. Download kodingan yg saya buat.

    $ wget -O igv.py http://gist.github.com/raw/32288/503d011d94c564ffbdca91296b3fc204cf7b5186
    
  5. Jalanin deh..

    $ jython
    >>> from igv import InteractiveGraphVisualization
    >>> ig = InteractiveGraphVisualization()
    
  6. Tambahin node dan edge

    >>> n1 = ig.add_node("satu")
    >>> n2 = ig.add_node("dua")
    >>> n3 = ig.add_node("tiga")
    >>> ig.add_edge(n1, n2)
    >>> ig.add_edge(n1, n3)
    >>> ig.add_edge(n2, n3)
    

Selamat menikmati =D

6 thoughts on “Prefuse + Jython = Keren”

  1. Thanks for the demo/screencast. With a little help from google I managed to read your site.

    I wanted to mention that you need to install Jython in a directory the user has write access to. I installed it as root and it had some Java library errors.

  2. @ernie: thanks for the information, I didn't know that 🙂 Since I installed jython using my own user, I didn't face any problem.

Leave a Reply