Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Rendering SVG Image in GEF
Rendering SVG Image in GEF [message #520170] Thu, 11 March 2010 12:38 Go to next message
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
Hello,

I am trying to display a svg image in an edit part in my gef application. I am trying to get the figure like below

RenderInfo renderInfo = RenderedImageFactory.createInfo(20, 40, false, false, new RGB(255, 255, 255), new RGB(0, 0, 0));
figure = new ScalableImageFigure(RenderedImageFactory.getInstance("C:\\temp1\\test.svg ",renderInfo));

However the quality of the image being rendered is very bad. Is there any better way to have an svg image in my edit part with quality.

I would also like to say that the image quality is as expected when i export the image to another svg. I export as below

Rectangle rootFigureBounds = rootFigure.getBounds();
GraphicsSVG graphics = GraphicsSVG.getInstance(rootFigureBounds.getTranslated(rootF igureBounds.getLocation().negate()));

graphics.translate(rootFigureBounds.getLocation().negate());
rootFigure.paint(graphics);
OutputStream outputStream;
try {
outputStream = new FileOutputStream (saveLocation);
graphics.getSVGGraphics2D().stream(new BufferedWriter(new OutputStreamWriter(outputStream)));

} catch (Exception e) {
e.printStackTrace();
}

[The resultant svg image out of the above code is as expected though the svg contents in editor were distorted]
Could anyone please point me in the direction of displaying the svg image in gef .

Thanks in advance for help


Regards,
Bhat
Re: Rendering SVG Image in GEF [message #649242 is a reply to message #520170] Tue, 18 January 2011 10:55 Go to previous messageGo to next message
Deepak Singla is currently offline Deepak SinglaFriend
Messages: 27
Registered: December 2009
Junior Member
Hi,

I have same question. Can we use SVG fimages in drawing the images(figures) for drawing the GEF Figures.

In some blogs, somebody has mentioned that GMF can use SVG Images for rendering via the ScalableImageFigure class.

But is it possible use SVG Image in GEF Figures (that used Draw2D) for rendering its figures.

If possible, give any hint or sample code.

Thanks in advance.
Deepak
Re: Rendering SVG Image in GEF [message #649244 is a reply to message #649242] Tue, 18 January 2011 11:14 Go to previous messageGo to next message
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
Hello Deepak,

Below is a small snippet which i created that exports a Ifigure created from draw2d into an svg

public void exportToSVG(String saveLocation, IFigure rootFigure, IProgressMonitor monitor) {
SubProgressMonitor subProgressMonitor = new SubProgressMonitor(monitor, 10);
subProgressMonitor.setTaskName("Creating SVG image...");
Rectangle rootFigureBounds = rootFigure.getBounds();
GraphicsSVG graphics = GraphicsSVG.getInstance(rootFigureBounds.getTranslated(rootF igureBounds.getLocation().negate()));
SVGIDGenerator generator = new SVGIDGenerator();

subProgressMonitor.worked(2);
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)));
subProgressMonitor.worked(4);
subProgressMonitor.done();
} catch (Exception e) {
e.printStackTrace();
}
subProgressMonitor.done();

}

Hope it helps.


Regards,
Bhat
Re: Rendering SVG Image in GEF [message #649248 is a reply to message #649244] Tue, 18 January 2011 11:42 Go to previous messageGo to next message
Deepak Singla is currently offline Deepak SinglaFriend
Messages: 27
Registered: December 2009
Junior Member
Hi Bhat,

Thanks for your reply.

Right now we are using draw2d for rendering the figures in GEF Editor.
But my question is that can we use SVG Images for rendering our images on the GEF Editor.

Any ides or sample code would be helpful.

Regards
Deepak Singla
Re: Rendering SVG Image in GEF [message #649249 is a reply to message #649248] Tue, 18 January 2011 11:49 Go to previous messageGo to next message
Murthy Bhat is currently offline Murthy BhatFriend
Messages: 159
Registered: July 2009
Senior Member
I guess in GMF you can render a svg image. So if you look at the way how gmf does it, you could use the same thing.

Regards,
Bhat
Re: Rendering SVG Image in GEF [message #649266 is a reply to message #649248] Tue, 18 January 2011 13:26 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.gmp/or g.eclipse.gmf.tooling/plugins/org.eclipse.gmf.runtime.lite.s vg/src/org/eclipse/gmf/runtime/lite/svg/SVGFigure.java?view= markup&root=Modeling_Project

Seems like there is no dependency over GMF. You can re-use this Figure as-it.

HTH

Le 18/01/2011 12:42, Deepak Singla a écrit :
> Hi Bhat,
>
> Thanks for your reply.
>
> Right now we are using draw2d for rendering the figures in GEF Editor. But my question is that can we use SVG Images for rendering our images on the GEF Editor.
>
> Any ides or sample code would be helpful.
>
> Regards
> Deepak Singla


--
Mickael Istria -- BonitaSoft S.A.
http://www.bonitasoft.com/products/BPM_download.php
Re: Rendering SVG Image in GEF [message #1495817 is a reply to message #649249] Tue, 02 December 2014 14:41 Go to previous message
vignesh ramani is currently offline vignesh ramaniFriend
Messages: 2
Registered: December 2014
Junior Member
Hey,

Could you please let me know on how i could bring in the SVG / .JPG figures in my GEF palette? Thanks in advance

Previous Topic:Add a MouseListener to a GraphNode
Next Topic: startup opening editor exception
Goto Forum:
  


Current Time: Tue Apr 23 11:13:00 GMT 2024

Powered by FUDForum. Page generated in 0.02855 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top