Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Image as a Node
Image as a Node [message #653371] Wed, 09 February 2011 14:58 Go to next message
akoeck is currently offline akoeckFriend
Messages: 62
Registered: December 2010
Member
I want to use a image as my node.

But I'm not realy sure how to do this. My image is a simple PNG-image. So how do I make this? Using an SVGFigure, a CustomFigure or what else?
Maybe there is an official or unoffical tutorial. But I couldn't find one.

Thanks in advance.

[Updated on: Wed, 09 February 2011 14:58]

Report message to a moderator

Re: Image as a Node [message #653822 is a reply to message #653371] Fri, 11 February 2011 12:39 Go to previous messageGo to next message
akoeck is currently offline akoeckFriend
Messages: 62
Registered: December 2010
Member
Has no one ever done this?

I tried it this way http://www.eclipse.org/forums/index.php?t=msg&S=082922f7 a046dab9b1f41dae1a1e9303&th=75482&goto=235707#msg_23 5707 but there is no node appearing.
It freezes for a few seconds and then I get a Class Not Found Exception for org.eclipse.gmf.runtime.draw2d.ui.render.figures.ScalableIma geFigure.

My bad, i got it. The Dependency in the plugin.xml was missing.

[Updated on: Fri, 11 February 2011 13:13]

Report message to a moderator

Re: Image as a Node [message #653867 is a reply to message #653822] Fri, 11 February 2011 16:00 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 3
Registered: February 2011
Junior Member
Hi,

I don't understand why no one is answering this simple question. Very sad.

I also need to know how to add images, but I was afraid to ask because lots of questions aren't answered here, although there are lots of viewers. I didn't had this experience in other expert forums so far. Can't believe no one knows the answer, too. But maybe there aren't enough active experts in here.

If the question is too easy and already came up hundreds of times so that the mods are tired of it, there should be a FAQ or some sticky thread with this topic. And one could a least give a hint if this question already has been answered somewhere. It's not always easy to find the right stuff (especially without an advanced search)


To the thread starter:
I tried to do it as described in the linked thread too but it's not working. There are no errors showing up since I added the missing import statements etc, but there's also no image showing up in my rectangle.
Some questions:

1) Does it only work for svg images?

2) Did you specify anything else in your figure descriptor than mentioned in that rough explanation from the thread you posted? (some property, child access or anything else)

3) How do I have to specify the image folder correctly? Is it like
"icons/..." or
"/icons/..." or
"package_name/icons/..."
or do I need to specify a
new path("icons/...")
first?? How can I even check if it's correct without trying and compiling over and over again? I just don't know if the path is correct.

4) What "dependency" exactly do I have to add in the plugin.xml?


Thanks & regards,
Alex

[Updated on: Fri, 11 February 2011 16:03]

Report message to a moderator

Re: Image as a Node [message #653971 is a reply to message #653867] Sat, 12 February 2011 07:50 Go to previous messageGo to next message
akoeck is currently offline akoeckFriend
Messages: 62
Registered: December 2010
Member
No Real Name wrote on Fri, 11 February 2011 11:00
Hi,
1) Does it only work for svg images?



I'm using PNG's, so it chould also work with other types of images.
Quote:


2) Did you specify anything else in your figure descriptor than mentioned in that rough explanation from the thread you posted? (some property, child access or anything else)



Only the normal stuff:
Figure Gallery
--Figure Descriptor
----Rectangle
------CustomFigure (with the properties from the link)
Node (MyFigure)

Quote:

3) How do I have to specify the image folder correctly? Is it like
"icons/..." or
"/icons/..." or
"package_name/icons/..."
or do I need to specify a
new path("icons/...")
first?? How can I even check if it's correct without trying and compiling over and over again? I just don't know if the path is correct.


This is how I add my image:
URL url = Platform.getBundle("Your_Plug-In_ID").getEntry("/images/image.png");
ScalableImageFigure mYFigure = new ScalableImageFigure(RenderedImageFactory.getInstance(url), true, true, true);
this.add(mYFigure);

Quote:

4) What "dependency" exactly do I have to add in the plugin.xml?


The missing Dependency was org.eclipse.gmf.runtime.draw2d.ui.render

[Updated on: Sat, 12 February 2011 07:52]

Report message to a moderator

Re: Image as a Node [message #653975 is a reply to message #653971] Sat, 12 February 2011 09:17 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 3
Registered: February 2011
Junior Member
Thanks for your reply!

Unfortunately the image is still not appearing in the node Sad

I think something must be wrong about the URL.

No Real Name wrote on Sat, 12 February 2011 02:50

This is how I add my image:
URL url = Platform.getBundle("Your_Plug-In_ID").getEntry("/images/image.png");
ScalableImageFigure mYFigure = new ScalableImageFigure(RenderedImageFactory.getInstance(url), true, true, true);
this.add(mYFigure);


"Your_Plug-In_ID" is the value from "plugin.xml -> overview -> ID", right?
In your example, the folder "/images" is on the same level as the "src" folder in your plugin-project, right?

Do you have any other suggestions how I could create the URL? (there seem to be several different possibilities)

Cheers,
Alex
Re: Image as a Node [message #654110 is a reply to message #653975] Mon, 14 February 2011 09:11 Go to previous message
akoeck is currently offline akoeckFriend
Messages: 62
Registered: December 2010
Member
No Real Name wrote on Sat, 12 February 2011 04:17
Thanks for your reply!

Unfortunately the image is still not appearing in the node Sad

I think something must be wrong about the URL.

No Real Name wrote on Sat, 12 February 2011 02:50

This is how I add my image:
URL url = Platform.getBundle("Your_Plug-In_ID").getEntry("/images/image.png");
ScalableImageFigure mYFigure = new ScalableImageFigure(RenderedImageFactory.getInstance(url), true, true, true);
this.add(mYFigure);


"Your_Plug-In_ID" is the value from "plugin.xml -> overview -> ID", right?
In your example, the folder "/images" is on the same level as the "src" folder in your plugin-project, right?

Do you have any other suggestions how I could create the URL? (there seem to be several different possibilities)

Cheers,
Alex

Yes, the ID is the value from the plugin.xml.

My Images folder is on the same level like the plugin.xml.

Don't know if there is another way to get the correct path.

Are you sure you got the dependencys all right?
Previous Topic:Reference graphical Elements from different diagrams
Next Topic:binding gmf editor with workspace resource in eclipse runtime enviornment
Goto Forum:
  


Current Time: Tue Mar 09 05:15:14 GMT 2021

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

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

Back to the top