2009-07-02

Generate diagrams from Emacs

ditaa is a command-line utility written in Java that can converts text into diagram. It works pretty well in Emacs. If you don't need fancy diagrams, it should be a handy tool for you that can quickly capture your idea and convert into diagram. For example, the following text is a ditaa input text that illustrates the lifetime of a activity in Android.
#+begin_ditaa ~/public_html/activity.png -s 0.8
:                 /----------\
:                 | Activity |
:                 |  starts  |
:                 |   cBLU   |
:                 \-----+----/
:                       |
:                       v
:                 +-----+-----+
:                 | onCreate()|
:                 +-----+-----+
:                       |
:                       v
:                 +-----+-----+    +-------------+
:                 | onStart() |<---+ onRestart() |
:                 | o start1  |    |    cYEL     |
:                 | o start2  |    \-------------/
:                 | cRED      |
:                 +-----+-----+
:                       |
:                       v
:                 +-----+-----+
:                 | onResume()|<------+
:                 +-----------+       
#+end_ditaa

ditaa converts it into an image file activity.png at ~/public_html.

Cool. But it is still cumbersome to draw text in this format. Don't worry!!! The built-in artist-mode provides text-based drawing in Emacs so that we can save a lot of time on this. If you think ditaa is useful, you must try artist-mode.