New: Java API for UML diagrams

As part of the Patternity effort, I spent some time creating a simple Java API to generate UML diagrams programmatically from Java, in SVG format.

This small API called for now Patternity Graphic is working and available here: patternitygraphic_src as a source Zip (alpha release of course).

It can render small class diagrams with hierarchic, flow and radial layouts, and arbitrary sequence diagrams with unlimited nesting of method calls and embedded comments. My focus was to support the subset of diagram elements and capabilities required to display patterns occurrences.

Here is a sample sequence diagram with a nice call stack:


And here is a class diagram for a simple dummy hierarchy:


Boxes and links have various styles, defined in a template.svg template file, here is a random display of the boxes styles:


Apart from unit tests there is no documentation. If you are interested to reuse that please contact me for help. The Zip was exported in Eclipse with the project Export… function, and the project requires Commons Collections. Svg diagrams can be converted into images using Batik.

Other projects you might consider to generate UML diagrams: UMLGraph, modsl, umlspeed, jsigner, MetaUML, and of course GraphViz.

Any feedback appreciated!


Software development, Domain-Driven Design, patterns and agile principles enthusiast

3 thoughts on “New: Java API for UML diagrams

  1. can you please explain me how to use the api in generating sequence diagrams from java code and the generated images should be in one of the image format(png, jpg etc)

  2. Hi, this API only generates svg files, so if you’d like to convert from svg to a raster format you need to use another tool, e.g. Batik. Note however than svg is a standard file format that you could use for the web for example.

    To use the API you just build your call stack by appending nodes. It was just for me but I spent a lot of time on the layout ! If you do anything with it please let me know :)

Comments are closed.