Problem with saving GEF diagram as image [message #541948] |
Wed, 23 June 2010 06:31  |
Eclipse User |
|
|
|
Hello,
I have a problem with saving big GEF diagram as image to file, diagram
contains about 1000 connected nodes.
(this is critical problem for us, as diagrams can be significantly bigger).
I'm using following code to save diagram:
GraphicalViewer graphicalViewer = ...;
String saveLocation = ...;
ScalableFreeformRootEditPart rootEditPart =
(ScalableFreeformRootEditPart)
graphicalViewer.getEditPartRegistry().get(LayerManager.ID);
IFigure rootFigure = ((LayerManager)
rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
Rectangle rootFigureBounds = rootFigure.getBounds();
Control figureCanvas = graphicalViewer.getControl();
Image img = new Image(Display.getDefault(), rootFigureBounds.width,
rootFigureBounds.height);
GC imageGC = new GC(img);
figureCanvas.print(imageGC);
ImageLoader imgLoader = new ImageLoader();
imgLoader.data = new ImageData[] { img.getImageData() };
imgLoader.save(saveLocation, SWT.IMAGE_JPEG);
When saving image I got "org.eclipse.swt.SWTError: No more handles"
error in img.getImageData():
org.eclipse.swt.SWTError: No more handles
at org.eclipse.swt.SWT.error(SWT.java:3910)
at org.eclipse.swt.SWT.error(SWT.java:3799)
at org.eclipse.swt.SWT.error(SWT.java:3770)
at org.eclipse.swt.graphics.Image.getImageData(Image.java:1453)
If diagram contains lower number of nodes it's successfully saved.
I have enough memory in Eclipse, about 1500MB, OS: Windows 7.
Could you please advice how to correctly store big diagrams, possibly I
need to use some incremental saving approach?
--
Best regards,
Igor Burilo
|
|
|
|
Re: Problem with saving GEF diagram as image [message #542262 is a reply to message #541978] |
Thu, 24 June 2010 07:13   |
Eclipse User |
|
|
|
Hello vijay,
As I understand from your words this is a known problem, could you
please provide a place where it's stated, e.g. link to it in tracker or
some discussions (I searched in Internet but unfortunately didn't find
any notes)? Is this a problem of GEF, Draw2d or some other component,
e.g. SWT?
It's strange as my exported image size would be about 3Mb which I
suppose is not too much to throw such exceptions.
Thanks for pointing to CopyToImageUtil, I'll look at it. BTW will it
resolve my problem?
P.S. I suppose that such functionality as saving GEF diagrams as image
should be a part of GEF itself, of course, I saw bug about it in GEF
tracker.
> There is no solution for this,only solution would be to cut the images
> into managable size and tile it in an html to show it.
> or
> export the image as svg.
>
> refer org.eclipse.gmf.runtime.diagram.ui.render.util.CopyToImageUt il
> class
>
--
Best regards,
Igor Burilo
|
|
|
|
|
|
|
|
|
|
|
Re: Problem with saving GEF diagram as image [message #646949 is a reply to message #541948] |
Mon, 03 January 2011 08:00   |
Eclipse User |
|
|
|
On 23/06/2010 11:31, Igor Burilo wrote:
> Hello,
>
> I have a problem with saving big GEF diagram as image to file, diagram
> contains about 1000 connected nodes.
> (this is critical problem for us, as diagrams can be significantly bigger).
> I'm using following code to save diagram:
> GraphicalViewer graphicalViewer = ...;
> String saveLocation = ...;
> ScalableFreeformRootEditPart rootEditPart =
> (ScalableFreeformRootEditPart)
> graphicalViewer.getEditPartRegistry().get(LayerManager.ID);
> IFigure rootFigure = ((LayerManager)
> rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
> Rectangle rootFigureBounds = rootFigure.getBounds();
> Control figureCanvas = graphicalViewer.getControl();
>
> Image img = new Image(Display.getDefault(), rootFigureBounds.width,
> rootFigureBounds.height);
> GC imageGC = new GC(img);
> figureCanvas.print(imageGC);
>
> ImageLoader imgLoader = new ImageLoader();
> imgLoader.data = new ImageData[] { img.getImageData() };
> imgLoader.save(saveLocation, SWT.IMAGE_JPEG);
>
> When saving image I got "org.eclipse.swt.SWTError: No more handles"
> error in img.getImageData():
> org.eclipse.swt.SWTError: No more handles
> at org.eclipse.swt.SWT.error(SWT.java:3910)
> at org.eclipse.swt.SWT.error(SWT.java:3799)
> at org.eclipse.swt.SWT.error(SWT.java:3770)
> at org.eclipse.swt.graphics.Image.getImageData(Image.java:1453)
> If diagram contains lower number of nodes it's successfully saved.
> I have enough memory in Eclipse, about 1500MB, OS: Windows 7.
>
> Could you please advice how to correctly store big diagrams, possibly I
> need to use some incremental saving approach?
>
Are you disposing of your resources properly? You need to dispose of the
GC and Image when finished.
|
|
|
|
Re: Problem with saving GEF diagram as image [message #647019 is a reply to message #646949] |
Mon, 03 January 2011 23:35  |
Eclipse User |
|
|
|
I am getting Swt Nomore handells at the
" Image img = new Image(Display.getDefault(), rootFigureBounds.width,rootFigureBounds.height);"
yes I am disposing properly, and it works fine for small figures, when my figure grows big, it throws exception on image creation
my image size is width=1500 and height=2000.
Thanks,
Niranjan Babu
|
|
|
Powered by
FUDForum. Page generated in 0.05084 seconds