Saturday, 28 March 2009

EIP Shapes for OpenOffice Draw

If you’ve read the excellent Enterprise Integration Patterns (EIP) book by Gregor Hohpe and Bobby Woolf, you may also know that free VISIO stencils are available for the EIP shapes, from the download page.

This is great for those who have a copy of VISIO (or whose employer pays for a copy), but for those of us who don’t want to pay however many hundreds of dollars Microsoft wants for VISIO these days, an alternative (especially a free one) is always welcome.  OpenOffice (OOo) Draw, though hardly as functional or attractive as VISIO, is both free and good enough for many diagrams.

So I decided to see if I could create a set of OOo Draw shapes from the VISIO stencil, and see whether Draw could be practical for integration diagramming.  In short, I succeeded in converting the stencil, and I think Draw is just about good enough. For those not interested in the background, I’ve made the material freely available from this page on my website, so just go ahead and download/install.  Otherwise, read on.

Exporting the VISIO Shapes

One way to get shape data into Draw is via SVG. So I started with the VISIO shapes, freely downloadable from the EIP site, and as I use VISIO at work I was able to load up the stencil and export it as SVG. 

You need to install an OpenOffice extension for importing SVG. I’m using OOo 3.0: the extension installed without incident and the import was straightforward. I was surprised at how good the resulting shapes looked in Draw.  Each shape is composed of drawing primitives, so you need to select and group them to create a shape you can place and move easily. I’ve done this for all the shapes in the download.

So now we have the shapes, where can we put them to make them easily reusable?  In Draw, there’s no stencil feature as such: the only option is the Gallery:

image

The Gallery

The gallery feature in Draw isn’t very appealing, initially. When you first install OOo, the gallery contains some spectacularly awful materials: nasty backgrounds and bullets which I cannot imagine ever wanting to use, and it even contains some pointless sound-clips that surely only a 5-year old might use (and only then if they were desperate). The shapes and graphics are reminiscent of shareware software from the Windows 95 era.  And what is the point of the built-in media player?  Why can’t OpenOffice grow up?  It’s so very close to being excellent in many respects: things like this just make it look silly and dated.

Anyway, back to the gallery feature. The one saving grace of this feature is that you can create new gallery themes and add your own shapes to them. To do this, create a new theme, give it a name and then drag your shapes into it.  Note that when you drag/drop your shape you must hold down the mouse button and pause a second or two before dragging: this pause changes the drag-mode from a simple shape move to the required move/copy.

I’ve done this for all the EIP shapes, creating an EIP gallery theme:

image

Sharing the EIP Theme

Unfortunately, Draw doesn’t implement a theme export facility so to share this new theme with others requires some irritating file copying.  The contents of the Gallery are stored in your profile (or home) folder. On Windows this is likely to be:

C:\Documents and Settings\<user>\Application Data\OpenOffice.org\3\user\gallery

On Unix/Linux, check your home folder. There are several file types in here and (unusually for OOo) they are binary, not XML. This makes it difficult to reverse-engineer their purpose and relationship but fortunately it doesn’t seem to be necessary to understand fully what’s going on. The key thing to note is that the numbers in the file names bind together related files.  When you create a new theme, a new set of files appears to be created.

For the EIP theme I have manually renamed the files to use numbers which I hope won’t clash with any existing gallery files you may have.  Check the zip contents before you extract the files into your OOo folder and if you have existing files with the same name, simply rename the files in my zip to be unique in your environment. 

The Result

I think the result is pretty good.  As a test, I have (partially) reproduced the diagram from the end-cover of the EIP book in a Draw file (.odg) which is included in the download zip:

image

I hope this may be some use to other folk.  Download from this page.

9 comments:

  1. I'm stumbled while trying to use OOo Draw to something very similar to what I've done with Visio, then I come across your post here. Really helpful, and it just make my day. Thank you!

    ReplyDelete
  2. hi Roger,
    i'm trying to do the same with UML stencils (http://softwarestencils.com/uml/index.html)

    how did you manage to export to SVG from Visio? i tried from the stecils panel context menu -> save as, but it just creates a bad svg file.

    any help really appreciated! thanks.
    -Jacopo-

    ReplyDelete
  3. Hi,
    Is it possible for you to create a zip with just the exported svg?

    Best regards,
    Mats

    ReplyDelete
  4. Great! Thank you for your effort!!! Norbert

    ReplyDelete
  5. Hi Roger, How's life? Dull blog considering how interesting you are in person. Still that's work blogs for you I suppose. Really ought to met up for a drink sometime. Michael

    ReplyDelete
  6. Thank-you very much...
    I was just looking for how to convert the EIP stencil for use in OpenOffice.org and I stumbled across your website and you've done it for me already :-)

    Chris Selwyn

    ReplyDelete
  7. Hi Roger!

    thanks a lot for the shapes!

    being able to use LibreOffice for my EIP diagrams has an inestimable value for me!

    great job!

    ReplyDelete
  8. Thanks Roger!
    You saved me the day, for producing EIP diagrams on Linux

    Lorenzo

    ReplyDelete
  9. You can also find some diagram templates in the diagram resource (creately diagram community). There are 1000s of templates and examples available to draw diagrams faster.

    ReplyDelete