views:

215

answers:

2

Does anyone know of any templating engines for generating images, preferably Java-based?

What I have in mind is something like StringTemplate where a you have a set of parameterized templates that render to an image (or SVG, etc) rather than text. It needs to be more general purpose than "insert text here to generate a sign". Primitives would be various shapes, other images, text, etc.

I realize I can build this pretty easily myself with a text template engine that generates SVG, but I'm looking for something that works "out of the box".

Thanks!

To elaborate a bit, here's some totally made up syntax for what I'm looking for. Image I want to generate an icon with some status overlays (like icons in Eclipse):

iconTemplate(base, status, svn) {
    image($base), // the base icon
    // create a 2x2 grid for status overlays
    gridlayout(2, 2) {
        // conditionally add overlays in corners based on parameters
        if($status == "error") {
            image("error.png") {
                layoutInfo : cell(1, 0)
            }
        }
        if($svn == "changed") {
            image("changed.png") {
                layoutInfo : cell(1, 1)
            }
        }
    }
}

Note this syntax is completed made up and obviously sucks, but maybe it gets the idea across :)

A: 

Not sure if it is what you are looking for but maybe something like Graphviz, Grappa or Zest could help?

Fabian Steeg
Although they're all cool, they're more for rendering graphs. I'm looking for more general image composition.
Dave Ray
+1  A: 

I'm not sure I understand your needs, but how about creating a JPanel (you can use layouts, labels, other shapes ...) and save it as an image?

Here you can find information about how to save a JPanel as an image.

asalamon74