tags:

views:

1166

answers:

3

Is there a good example of how to include an SVG canvas into a Java SWT project (particularly Holongate, though I would be interested in any other options)? Additionally, I would need to support this SVG canvas on Mac OS X, Windows and Linux clients, in case an implementation relies on native libraries. Thanks for any pointers.

+3  A: 

Use batik (http://xmlgraphics.apache.org/batik/). Render SVG into the image. Display it in SWT container. Portable.

san
I think Batik is Swing, not SWT.
Alex Reynolds
"I think Batik is Swing"... No... Use batik to render JPEG (or whatever) and then display that in swt (or whatever)... the fun part is generating the region map to support interactivity.
corlettk
This seems like a hack that doesn't really answer the question.
Alex Reynolds
it is how it works, it is not a hack. 99% of batik is SVG rendering algorithm. How to embed it into particular framework - is technical details.
san
+1  A: 

We implemented this functionality by embedding a Batik Swing canvas into an SWT composite, see here. It worked fine on Windows, but we couldn't scroll the canvas on Mac OS X.
However, the vast majority of our users were on Windows, so we didn't spend too much time trying to fix the Mac OS X bug.

Zsolt Török
A: 

Look at: eclipse GMF they has written a class witch renders through org.eclipse.gmf.runtime.draw2d.ui.render.awt.internal.graphics.Graphics2DToGraphicsAdaptor and Source code is in org.eclipse.gmf.runtime.draw2d.ui.render.awt.internal.svg. SWTImageTranscoder.

KlausMeier