Question

Is there a way to show an SVG image in a GEF editor? I found that one can convert the SVG image in a SWT image but I need it to be in vector format, so that when I zoom in I don't get quality loss.

Was it helpful?

Solution 2

Ok, I finally found something that works. It seems like using org.eclipse.gmf.runtime.draw2d.ui.render.figures.ScalableImageFigure ist the answer. ScalableImageFigure is a sublcass of Figure so it works like a normal GEF Figure. You cand find this in the runtime library pack from GMF.

Using ScalableImageFigure you can show an SVG image in GEF but when you zoom in you still get quality loss. To overcome this you need to sublcass ScalableImageFigure and implement org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode. When you zoom in the scalable figure will be repainted, and the image rerendered. org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode.LPtoDP(Translatable) will return the scale for the image to be rendered. I didn't have enough time to properly implement this interface, I just needed to check if it works so i simply created a field in the subclass(int named scale with default value 1) which is incremented each time LPtoDP is called

   public Translatable LPtoDP(Translatable t) {
  t.performScale(scale++);
  return t;

}

This is totally experimental, when I will implement this feature in our application I'll revisit this Question and post a functional and corect implementation of this interface and class.Until then I hope this will help others who are looking into something like this.

OTHER TIPS

According to this site, you should be able to use the SVGFigure class of GMF.

This class does not have dependencies to GMF.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top