This post intends to serve a similar purpose as my mscgen post A tool that I sometimes like to use for simple UML diagrams is MetaUML. The documentation for this tool is unfortunately a bit sparse, so I thought I’d put some notes up here so I can find them more easily in the future.
Step One, Installation
On Ubuntu, the following two packages need to be installed:
If you neglect the texlive-fonts-recommended package, you will receive the following cryptic error when trying to compile a simple metauml diagram:
Step Two, Create a Source File
The syntax for MetaUML is quite a bit more involved than mscgen, but with some appropriate examples lying around, you can quickly cross reference them to find what you’re looking for.
NOTE - Make sure to include
prologues := 2; at the start of the metauml document.
If you forget this step, convert will not be able to read the postscript file after
running it through mpost.
This bit of magic is due to the following: “If prologues is set to 2, any used fonts in the output file are automatically re-encoded, and the encoding vector file specified in the fontmap entry will be embedded in the output file. If prologues is set to 3, MetaPost will also attempt to include (a subset of) the used PostScript fonts. For this to work, it needs to acquire font map information.”
Step Three, Make Pretty Pictures
First, compile the MetaUML source into a postscript figure:
Now you will have an example.1 file. You can view the contents of the file to see the raw postscript output - pretty ugly, huh?
Now we need to convert that postscript file into a png - you know, to make sure that the graphics are portable across networks. For this, we will use ImageMagick’s excellent convert utility.
To get a larger or smaller image, adjust the density parameter passed to convert. If you try using scaling or transforms instead, the image will be blurry and of poor quality.