Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Graphiti » SVG Export(Save Image as SVG)
SVG Export [message #644015] Thu, 09 December 2010 00:08 Go to next message
Murthy Bhat is currently offline Murthy Bhat
Messages: 159
Registered: July 2009
Senior Member
Hello,

I have been trying out GRAPHITI for some time now and exploring in graphiti some common features available in GEF/GMF. I have a requirement to save the image as 'SVG', Well I could easily export my IFigure into svg in gef and gmf, I am not finding a way in graphiti to do it.

I tried to export the IFigure as I would normally do in GEF( as below) but am hitting some exceptions.

public static void saveAsSVG(String saveLocation, IFigure rootFigure) {
Rectangle rootFigureBounds = rootFigure.getBounds();
GraphicsSVG graphics = GraphicsSVG.getInstance(rootFigureBounds.getTranslated(rootF igureBounds.getLocation().negate()));
SVGIDGenerator generator = new SVGIDGenerator();

graphics.getSVGGraphics2D().getGeneratorContext().setIDGener ator(generator);
graphics.translate(rootFigureBounds.getLocation().negate());
rootFigure.paint(graphics);
OutputStream outputStream = null;
try {
outputStream = new FileOutputStream (saveLocation);
graphics.getSVGGraphics2D().stream(new BufferedWriter(new OutputStreamWriter(outputStream)));
} catch (Exception e) {
e.printStackTrace();
}
}

It appears to me like some controls in graphiti do not support the same graphics element . Could someone please help me out here.

Thanks in advance.

Regards,
Murthy
Re: SVG Export [message #644028 is a reply to message #644015] Thu, 09 December 2010 02:32 Go to previous messageGo to next message
Murthy Bhat is currently offline Murthy Bhat
Messages: 159
Registered: July 2009
Senior Member
After a little investigation I was able to find that the svg export works perfectly fine if my diagram does not contain any Texts,Labels. I am hitting a 'NotImplemented' exception from graphics exactly at line graphics.setTextAntialias(SWT.ON); in GFText.java

Any thoughts ?

Re: SVG Export [message #644030 is a reply to message #644028] Thu, 09 December 2010 02:54 Go to previous messageGo to next message
Matthias Gorning is currently offline Matthias Gorning
Messages: 80
Registered: April 2010
Location: Germany
Member
If you install the graphiti plugin "org.eclipse.graphiti.export.batik" it is possible to save the diagram (or only selected parts) as type svg. From the context menu choose "Export Diagram...".

But we faced the same problem: Text and Labels are not exported.
Re: SVG Export [message #644047 is a reply to message #644030] Thu, 09 December 2010 04:02 Go to previous messageGo to next message
Tim Kaiser is currently offline Tim Kaiser
Messages: 118
Registered: July 2009
Senior Member
Hi Murthy

you can install the new feature

org.eclipse.graphiti.sdk.plus.feature

from our update site.
It contains the svg export functionality.

Text should be rendered correctly if you export the whole diagram.

Does it work?

Best, Tim





"Matthias Gorning" <matthias.gorning@sap.com> wrote in message
news:idq1m9$fj3$1@news.eclipse.org...
> If you install the graphiti plugin "org.eclipse.graphiti.export.batik" it
> is possible to save the diagram (or only selected parts) as type svg. From
> the context menu choose "Export Diagram...".
> But we faced the same problem: Text and Labels are not exported.
Re: SVG Export [message #644049 is a reply to message #644047] Thu, 09 December 2010 04:29 Go to previous message
Murthy Bhat is currently offline Murthy Bhat
Messages: 159
Registered: July 2009
Senior Member
Hello Tim,

Thanks. It helped. It works lbeautifully.

Regards,
Murthy
Previous Topic:rectilinear connection routing
Next Topic:Grid width and resizing
Goto Forum:
  


Current Time: Sat Jul 26 13:20:28 EDT 2014

Powered by FUDForum. Page generated in 0.01917 seconds