Dot to Png

User ClicksFor fun I wasted some time creating diagrams using the dot language. It's pretty fast to get a diagram out, except that there are a lot of things you can't do, like make shadows or rounded and filled rectangles. With this dot code:
digraph "User Clicks" {
node [
shape="rectangle"
style="filled"
]

server [label="Server"]
java [shape="ellipse" label="Java\nCode"]
provider [label="Service\nProvider"]
browser [label="Firefox"]

browser->server[label=<&#9312; AJAX Sends Session ID>];
server->java[label=<&#9313; Confirms Session ID>];
java->provider[label=<&#9314; Makes HTTPS call>];
provider->java[label=<&#9315; Results>];
java->server[label=<&#9316; Results>];
server->browser[label=<&#9317; Results>];
}

You can click on the image to see the SVG rendered in Firefox, if you use that. I wrote a little python program to call the dot command outputting the diagram as an SVG file. Then I used the batik-rasterizer to convert SVG into PNG. Unfortunately, dot doesn't do an excellent job on the SVG that it outputs. The biggest problem is the font ends up being the wrong size. Another small issues is that is uses instead of for it's rectangles. My little program fixes these issues and rounds rectangles and adds shadows to rectangles and ellipses.

Comments

Anonymous said…
Dot can create PNG ...maybe it could not in 2006, but now it can.
Scott Kirkwood said…
Yes, I realize that, but it doesn't do shadows, that's why I went to svg first.
Nice Idea! Anywy, Even without their discounts www.jvmhost.com seems to be the cheapest Java provider on the market.
Mikrowelle said…
SVG?... I am not totally familiar with such thing... Can you share to me that scott?...

Popular posts from this blog

Shortest Sudoku solver in Python

Seven Segment Display in Inkscape