Home » Eclipse Projects » GEF » Problem with saving GEF diagram as image
Problem with saving GEF diagram as image [message #541948] |
Wed, 23 June 2010 10:31 |
Igor Burilo Messages: 435 Registered: July 2009 |
Senior Member |
|
|
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 #541978 is a reply to message #541948] |
Wed, 23 June 2010 12:48 |
Vijay Raj Messages: 608 Registered: July 2009 |
Senior Member |
|
|
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
---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
|
|
|
Re: Problem with saving GEF diagram as image [message #542262 is a reply to message #541978] |
Thu, 24 June 2010 11:13 |
Igor Burilo Messages: 435 Registered: July 2009 |
Senior Member |
|
|
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 #542284 is a reply to message #542262] |
Thu, 24 June 2010 12:57 |
Vijay Raj Messages: 608 Registered: July 2009 |
Senior Member |
|
|
Quote: | 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.
|
Exactly
http://www.eclipse.org/forums/index.php?t=msg&goto=51133 7&#msg_511337
i faced the problem and found the solution in GMF and assumed its as it is.
it is related to swt image size which can not be more then a certain size.i already wasted a lot of time on this so i assumed if GMF guys could not achive it,who am i.
the copy image util will help u..u have to modify the code for getting the root figure...
it helped me,but then if the image size is real huge then svg is the best solution,the size is also small(file size) and u can embed it in an html with zoom and pan tools and many more to make it intresting.
But then again for svg u have to go thru hell to extract the class from GMF GraphicsSVG.
(again why is'nt all this in GEF also? )
Note: svg plugin for browser has to be downloaded to view the svg image.
---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
[Updated on: Thu, 24 June 2010 13:02] Report message to a moderator
|
|
| | | | | | | |
Re: Problem with saving GEF diagram as image [message #646949 is a reply to message #541948] |
Mon, 03 January 2011 13:00 |
h1055071 Messages: 335 Registered: July 2009 |
Senior Member |
|
|
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.
|
|
| | |
Goto Forum:
Current Time: Thu Mar 28 22:23:11 GMT 2024
Powered by FUDForum. Page generated in 0.02814 seconds
|