Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to create the FigureDescriptor for this final state figure with GMF Graph
How to create the FigureDescriptor for this final state figure with GMF Graph [message #759231] Sun, 27 November 2011 21:45 Go to next message
Hoang  is currently offline Hoang Friend
Messages: 45
Registered: September 2011
Location: Milan
Member
Hi everyone,

I have created the Initial State with this FigureDescriptor.
index.php/fa/6261/0/
<descriptors
name="InitFigure">
<actualFigure
xsi:type="gmfgraph:Ellipse"
name="InitFigure">
<foregroundColor
xsi:type="gmfgraph:RGBColor"/>
<backgroundColor
xsi:type="gmfgraph:ConstantColor"
value="black"/>
<preferredSize
dx="22"
dy="22"/>
<insets
top="5"
left="5"
bottom="5"
right="5"/>
<border
xsi:type="gmfgraph:MarginBorder">
<insets
top="5"
left="5"
bottom="5"
right="5"/>
</border>
</actualFigure>
</descriptors>

Now I want to create the Final State the same as this one:
index.php/fa/6262/0/

But it seems that I have problems with designing the GMF Graph for this state. I am new to Draw2d. Someone please could help me figure out how to do so?
The Final State is slighly bigger than the Initial State. I think it's 30x30, compares to 22x22 of Initial State.

Thanks,

[Updated on: Tue, 29 November 2011 18:34]

Report message to a moderator

Re: How to create the FigureDescriptor for this final state figure with GMF Graph [message #759773 is a reply to message #759231] Tue, 29 November 2011 23:01 Go to previous messageGo to next message
Hoang  is currently offline Hoang Friend
Messages: 45
Registered: September 2011
Location: Milan
Member
Hi everyone,

Is the question lack some details or no one is interested in giving the answer?

If you want to test the graph then you can navigate to this GitHub project: https://github.com/pnhoang/Selflet
Import the SelfletBehavior* projects and then you will be able to test your change.

I am thinking of putting the .svg file as the default image, but I am eager to also learn how to draw in draw2d with this specific situation. Thanks.
Re: How to create the FigureDescriptor for this final state figure with GMF Graph [message #759852 is a reply to message #759773] Wed, 30 November 2011 10:22 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 30/11/2011 00:01, Hoang wrote:
> Hi everyone,

Hi

> Is the question lack some details or no one is interested in giving the
> answer?

It's probably that AFAIK the best way to get this working is to try and
see, but that's too much time consuming for people reading the forum.

> If you want to test the graph then you can navigate to this GitHub
> project: https://github.com/pnhoang/Selflet
> Import the SelfletBehavior* projects and then you will be able to test
> your change.

Seems like we met that same issues about reducing development loop in
..gmfgraph:

You should have a look at this bug to help you creating your GMFGraph:
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=363449
It shows you a preview of what you're creating. You can get in from the
2.4.x-maintenance branch of GIT GMF-Tooling repository. It will probably
be part of the 3.0 release, and maybe of a 2.4.1.
If you like it, drop a comment or vote for it, it will be easier for me
to convince the project lead to put it in a 2.4.1 ;)

Also I made another tool that is useful for any Draw2d figure:
http://marketplace.eclipse.org/content/draw2d-preview .

Hope you'll find them interesting. And if you're motivated, feel free to
suggest feature requests to GMF Tooling via the tracker.
https://bugs.eclipse.org/bugs/enter_bug.cgi?product=GMF-Tooling

> I am thinking of putting the .svg file as the default image, but I am
> eager to also learn how to draw in draw2d with this specific situation.
> Thanks.

Draw2d follows the same principles as SWT for layouting. Spending a
couple of hours to create some Draw2d figures by hand will for sure make
you save you even more hours in your future usage of gmfgraph.

Regards,


--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
Re: How to create the FigureDescriptor for this final state figure with GMF Graph [message #759861 is a reply to message #759852] Wed, 30 November 2011 11:20 Go to previous messageGo to next message
Hoang  is currently offline Hoang Friend
Messages: 45
Registered: September 2011
Location: Milan
Member
Hi Mickael,

Thanks for the response, I have dropped a message in the bug report for previewing the figure at design phase. I think it's very helpful.

I know that Draw2d has the same principles with SWT, but I am new to this Java world in general. That's the point. But thanks for your suggestion, I will come back to learn SWT before proceeding ahead.
Re: How to create the FigureDescriptor for this final state figure with GMF Graph [message #765214 is a reply to message #759861] Tue, 13 December 2011 16:33 Go to previous messageGo to next message
Hoang  is currently offline Hoang Friend
Messages: 45
Registered: September 2011
Location: Milan
Member
I have finally come up with the solution to use SVGFigure to save my time.

Basically these are what I do:
- Create the SVG image by using Inskcape to convert from PNG to SVG image.
- In the .gmfgraph:
+ Add a new Figure Gallery with name : Images
+ Under this Figure Gallery, add a Figure Descriptor with name SVGFinalStateFigure
+ Under this Figure Descriptor, add a new Custom Figure name SVGFinalStateFigure, Qualified Class Name: org.eclipse.gmf.runtime.draw2d.ui.render.figures.ScalableImageFigure
+ In the Canvas of this .gmfgraph, add a new Node name SVG Final State, this Node points to the SVGFinalStateFigure created above
- In the .gmfmap:
+ Map the Node Mapping of Diagram Node to this SVG Final State (SVGFinalStateFigure)
- Transform the .gmfmap to .gmfgen
- Regenerate the .diagram project
- Add the Final.svg image created above to the .diagram project
- Add dependencies to the .diagram project org.eclipse.gmf.runtime.draw2d.ui.render
- Update the createNodeShape() function of FinalStateEditPart to the following:


	/**
	 * @generated NOT
	 */
	protected IFigure createNodeShape() {
		URL url = FileLocator.find(SelfletBehaviorDiagramEditorPlugin
				.getInstance().getBundle(), new Path("icons/Final.svg"), null); //$NON-NLS-1$
		return new ScalableImageFigure(RenderedImageFactory.getInstance(url),
				true, true, true);
	}



- Add the corresponding imports to this java file
- Ready to go!

The whole commit for this code is located at this GitHub page
Don't be threatened by the generated codes. Just look at the steps above and compare the codes. Some files are generated automatically by GMF Frameworks, so we don't need to care about, e.s. .gmfgen file.

The solution comes from following this tutorial. Thanks everyone.

Hope this helps someone.

[Updated on: Tue, 13 December 2011 16:35]

Report message to a moderator

Re: How to create the FigureDescriptor for this final state figure with GMF Graph [message #765224 is a reply to message #765214] Tue, 13 December 2011 16:55 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

Not sure if it matches your use case, but documentation tells an easier
way to leverage SVG Figures:
http://wiki.eclipse.org/Graphical_Modeling_Framework/Tutorial/Part_2#Use_SVGFigure
--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
Re: How to create the FigureDescriptor for this final state figure with GMF Graph [message #765263 is a reply to message #765224] Tue, 13 December 2011 18:11 Go to previous messageGo to next message
Hoang  is currently offline Hoang Friend
Messages: 45
Registered: September 2011
Location: Milan
Member
Hi Mickael,

Somehow I enjoyed hacking the .diagram project than installing an Experimental SDK. Is that part of the tutorial still valid (i.e. installing the Experimental SDK, )? In the previous section, I tried to use the ImageFigure as suggested but did not see any ImageFigure in the gmfgraph.

[Updated on: Tue, 13 December 2011 18:12]

Report message to a moderator

Re: How to create the FigureDescriptor for this final state figure with GMF Graph [message #765570 is a reply to message #765263] Wed, 14 December 2011 10:12 Go to previous messageGo to next message
Mickael Istria is currently offline Mickael IstriaFriend
Messages: 865
Registered: July 2009
Location: Grenoble, France
Senior Member

On 13/12/2011 19:11, Hoang wrote:
> Somehow I enjoyed hacking the .diagram project than installing an
> Experimental SDK.

Sure, that's a good thing to learn. However, you'll discover that the
less you modify generated code, the more agile you are. Then you'll like
to see simple way to achieve things by configurating GMF files ;)
Don't be afraid of using the experimental SDK, it is not that much
"experimental", it has the same level of quality than the rest of GMF.
You can rely on it for your apps without risks.

> Is that part of the tutorial still valid?

I hope so, this is the main tutorial and docuementation.

> I tried to use the ImageFigure as suggested but did not see any ImageFigure in the gmfgraph.

Indeed, there is no such ImageFigure in gmfmap. I updated the wiki to
fix that.
Here are more relevant inputs about ImageFigure:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=131910

Regards
--
http://mickaelistria.wordpress.com
http://twitter.com/#!/mickaelistria
http://www.petalslink.com
Re: How to create the FigureDescriptor for this final state figure with GMF Graph [message #765781 is a reply to message #765570] Wed, 14 December 2011 17:12 Go to previous message
Hoang  is currently offline Hoang Friend
Messages: 45
Registered: September 2011
Location: Milan
Member
Hi Mickael,

Thanks for the good advice on doing all configurations in GMF. Sometimes, I do feel that I need to use the Git rewrite history function a lot just to update the changes I made in the past to the .diagram project, because once I deleted the .diagram project, all changes I made to this project are gone. I have to rewrite the history of Git to update the changes. That's not good for an open source project.

Now I have totally get rid of the habit of deleting .diagram project when there is any error generating from the gmfgen. I feel that it's generally better to do everything in GMF configuration files.

Thanks,
Previous Topic:How to link GMF Diagrams to Dawn Explorer or CDO Sessions window
Next Topic:How to set properties of an object automatically when it is created in the diagram?
Goto Forum:
  


Current Time: Thu Apr 25 10:51:29 GMT 2024

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

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

Back to the top