Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Igor Burilo is currently offline Igor BuriloFriend
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 Go to previous messageGo to next message
Vijay RajFriend
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 Go to previous messageGo to next message
Igor Burilo is currently offline Igor BuriloFriend
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 Go to previous messageGo to next message
Vijay RajFriend
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? Evil or Very Mad )

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 #542539 is a reply to message #542284] Fri, 25 June 2010 09:14 Go to previous messageGo to next message
Igor Burilo is currently offline Igor BuriloFriend
Messages: 435
Registered: July 2009
Senior Member
Hello vijay,

Thanks a lot for information, I'll look at GMF but as I can see saving
diagram as image is very coupled with GMF classes and quite complicated.
If you already did this job could you please provide a link to your code
or any notes about it taking into account that I can't depend on GMF
classes?

> 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 are all this in GEF also? :evil: )
>
> Note: svg plugin for browser has to be downloaded to view the svg image.


--
Best regards,
Igor Burilo
Re: Problem with saving GEF diagram as image [message #542648 is a reply to message #542539] Fri, 25 June 2010 14:23 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
i can provide u the code itself,but give me a safe way to mail you that code(instead of publishing our mail ids here).

---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Problem with saving GEF diagram as image [message #543340 is a reply to message #542648] Tue, 29 June 2010 07:44 Go to previous messageGo to next message
Igor Burilo is currently offline Igor BuriloFriend
Messages: 435
Registered: July 2009
Senior Member
Hello vijay,

My email: igor.burilo@polarion.org, I'd greatly appreciate you. By the
way, despite that our emails are not visible through web, they are
visible through other client, e.g. I can see your email.

> i can provide u the code itself,but give me a safe way to mail you that
> code(instead of publishing our mail ids here).


--
Best regards,
Igor Burilo
Re: Problem with saving GEF diagram as image [message #543663 is a reply to message #543340] Wed, 30 June 2010 08:55 Go to previous messageGo to next message
Vijay RajFriend
Messages: 608
Registered: July 2009
Senior Member
Code mailed,

for any querys pls reply back here.


---------------------
why, mr. Anderson, why, why do you persist?
Because I Choose To.
Regards,
Vijay
Re: Problem with saving GEF diagram as image [message #543956 is a reply to message #543663] Thu, 01 July 2010 08:08 Go to previous messageGo to next message
Igor Burilo is currently offline Igor BuriloFriend
Messages: 435
Registered: July 2009
Senior Member
Hello vijay,

Thanks a lot. I'll check it.

> Code mailed,
>
> for any querys pls reply back here.


--
Best regards,
Igor Burilo
Re: Problem with saving GEF diagram as image [message #646943 is a reply to message #543956] Mon, 03 January 2011 11:42 Go to previous messageGo to next message
Niranjan Babu .H.S is currently offline Niranjan Babu .H.SFriend
Messages: 17
Registered: July 2009
Junior Member
Hello Both,

I am also facing the same problem, Can any of you mail me the code to export image from the GEF figure.

I did try to do on what is explained in your post, but the image that I am getting is very small and blur.


my email id is : Niranjan.Babu@in.bosch.com.

Thanks in advance,
Niranjan Babu
Re: Problem with saving GEF diagram as image [message #646944 is a reply to message #543956] Mon, 03 January 2011 11:42 Go to previous messageGo to next message
Niranjan Babu .H.S is currently offline Niranjan Babu .H.SFriend
Messages: 17
Registered: July 2009
Junior Member
Hello Both,

I am also facing the same problem, Can any of you mail me the code to export image from the GEF figure.

I did try to do on what is explained in your post, but the image that I am getting is very small and blur.


my email id is : Niranjan.Babu@in.bosch.com.

Thanks in advance,
Niranjan Babu
Re: Problem with saving GEF diagram as image [message #646949 is a reply to message #541948] Mon, 03 January 2011 13:00 Go to previous messageGo to next message
h1055071 is currently offline h1055071Friend
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.
Re: Problem with saving GEF diagram as image [message #647018 is a reply to message #646949] Tue, 04 January 2011 04:32 Go to previous messageGo to next message
Niranjan Babu .H.S is currently offline Niranjan Babu .H.SFriend
Messages: 17
Registered: July 2009
Junior Member
No Message Body
Re: Problem with saving GEF diagram as image [message #647019 is a reply to message #646949] Tue, 04 January 2011 04:35 Go to previous message
Niranjan Babu .H.S is currently offline Niranjan Babu .H.SFriend
Messages: 17
Registered: July 2009
Junior Member
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
Previous Topic:Label Provider position
Next Topic:text editor sample - status
Goto Forum:
  


Current Time: Thu Mar 28 22:23:11 GMT 2024

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

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

Back to the top